KWMineHomeOrderSubView.m 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. //
  2. // KWMineHomeOrderSubView.m
  3. // westkissMob
  4. //
  5. // Created by iOS on 2022/10/12.
  6. //
  7. #import "KWMineHomeOrderSubView.h"
  8. @interface KWMineHomeOrderSubView ()
  9. @property (nonatomic, strong) UILabel *titleLB;
  10. @property (nonatomic, strong) UILabel *priceLb;
  11. @property (nonatomic, strong) UILabel *xLB;
  12. @property (nonatomic, strong) UILabel *numLB;
  13. @property (nonatomic, strong) UIImageView *imgV;
  14. @property (nonatomic, strong) KWMineOrderProInfoModel *m;
  15. @end
  16. @implementation KWMineHomeOrderSubView
  17. - (void)setData:(KWMineOrderProInfoModel *)model {
  18. self.m = model;
  19. self.titleLB.text = model.product_name;
  20. self.priceLb.text = [NSString stringWithFormat:@"%@",model.product_price];
  21. self.numLB.text = model.qty;
  22. [self.imgV sd_setImageWithURL:[NSURL URLWithString:model.product_img.urlEncode]];
  23. }
  24. -(instancetype)init {
  25. self = [super init];
  26. if (self) {
  27. [self loadSubV];
  28. }
  29. return self;
  30. }
  31. - (void)loadSubV {
  32. self.backgroundColor = UIColor.clearColor;
  33. [self addSubview:self.imgV];
  34. [self addSubview:self.titleLB];
  35. [self addSubview:self.priceLb];
  36. [self addSubview:self.xLB];
  37. [self addSubview:self.numLB];
  38. [_imgV mas_makeConstraints:^(MASConstraintMaker *make) {
  39. make.top.equalTo(self).offset(0);
  40. make.left.equalTo(self).offset(0);
  41. make.bottom.equalTo(self).offset(0);
  42. make.width.height.equalTo(@86);
  43. }];
  44. [_titleLB mas_makeConstraints:^(MASConstraintMaker *make) {
  45. make.top.equalTo(self.imgV);
  46. make.left.equalTo(self.imgV.mas_right).offset(10);
  47. make.right.equalTo(self).offset(0);
  48. make.height.equalTo(@35);
  49. }];
  50. [self.priceLb setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
  51. [self.priceLb mas_makeConstraints:^(MASConstraintMaker *make) {
  52. make.bottom.equalTo(self.imgV);
  53. make.left.equalTo(self.titleLB);
  54. make.height.equalTo(@17);
  55. }];
  56. [self.xLB mas_makeConstraints:^(MASConstraintMaker *make) {
  57. make.width.equalTo(@17);
  58. make.height.equalTo(@17);
  59. make.left.equalTo(self.priceLb.mas_right);
  60. make.centerY.equalTo(self.priceLb);
  61. }];
  62. [self.numLB mas_makeConstraints:^(MASConstraintMaker *make) {
  63. make.width.equalTo(@25);
  64. make.height.equalTo(@17);
  65. make.left.equalTo(self.xLB.mas_right);
  66. make.centerY.equalTo(self.priceLb);
  67. }];
  68. }
  69. - (UIImageView *)imgV {
  70. if (!_imgV) {
  71. UIImageView *imgV = [[UIImageView alloc] init];
  72. _imgV = imgV;
  73. }
  74. return _imgV;
  75. }
  76. - (UILabel *)titleLB {
  77. if (!_titleLB) {
  78. UILabel *lb = [[UILabel alloc] init];
  79. lb.font = [UIFont fontWithName:Rob_Regular size:12];
  80. lb.textColor = [UIColor blackColor];
  81. lb.backgroundColor = [UIColor clearColor];
  82. lb.numberOfLines = 2;
  83. _titleLB = lb;
  84. }
  85. return _titleLB;
  86. }
  87. - (UILabel *)priceLb {
  88. if (!_priceLb) {
  89. UILabel *lb = [[UILabel alloc] init];
  90. lb.font = [UIFont fontWithName:Rob_Bold size:14];
  91. lb.textColor = _0B0B0B;
  92. lb.backgroundColor = [UIColor clearColor];
  93. _priceLb = lb;
  94. }
  95. return _priceLb;
  96. }
  97. - (UILabel *)xLB {
  98. if (!_xLB) {
  99. UILabel *lb = [[UILabel alloc] init];
  100. lb.font = [UIFont fontWithName:Rob_Regular size:14];
  101. lb.textColor = _0B0B0B;
  102. lb.backgroundColor = [UIColor clearColor];
  103. lb.textAlignment = NSTextAlignmentCenter;
  104. lb.text = @"x";
  105. _xLB = lb;
  106. }
  107. return _xLB;
  108. }
  109. - (UILabel *)numLB {
  110. if (!_numLB) {
  111. UILabel *lb = [[UILabel alloc] init];
  112. lb.font = [UIFont fontWithName:Rob_Regular size:14];
  113. lb.textColor = _0B0B0B;
  114. lb.backgroundColor = [UIColor clearColor];
  115. _numLB = lb;
  116. }
  117. return _numLB;
  118. }
  119. @end