KWMineHomeOrderSubView.m 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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.name;
  20. self.priceLb.text = [NSString stringWithFormat:@"%@%@", model.currency_symbol, model.price];
  21. self.numLB.text = model.qty_ordered;
  22. NSString *imageStr = [NSString stringWithFormat:@"https:%@%@%@",HostPath,ProductImgPath,model.image];
  23. [self.imgV sd_setImageWithURL:[NSURL URLWithString:imageStr.urlEncode] placeholderImage:[UIImage imageNamed:@"product_defualtImg"]];
  24. }
  25. -(instancetype)init {
  26. self = [super init];
  27. if (self) {
  28. [self loadSubV];
  29. }
  30. return self;
  31. }
  32. - (void)loadSubV {
  33. self.backgroundColor = UIColor.clearColor;
  34. [self addSubview:self.imgV];
  35. [self addSubview:self.titleLB];
  36. [self addSubview:self.priceLb];
  37. [self addSubview:self.xLB];
  38. [self addSubview:self.numLB];
  39. [_imgV mas_makeConstraints:^(MASConstraintMaker *make) {
  40. make.top.equalTo(self).offset(0);
  41. make.left.equalTo(self).offset(0);
  42. make.bottom.equalTo(self).offset(0);
  43. make.width.height.equalTo(@86);
  44. }];
  45. [_titleLB mas_makeConstraints:^(MASConstraintMaker *make) {
  46. make.top.equalTo(self.imgV);
  47. make.left.equalTo(self.imgV.mas_right).offset(10);
  48. make.right.equalTo(self).offset(0);
  49. make.height.equalTo(@35);
  50. }];
  51. [self.priceLb setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
  52. [self.priceLb mas_makeConstraints:^(MASConstraintMaker *make) {
  53. make.bottom.equalTo(self.imgV);
  54. make.left.equalTo(self.titleLB);
  55. make.height.equalTo(@17);
  56. }];
  57. [self.xLB mas_makeConstraints:^(MASConstraintMaker *make) {
  58. make.width.equalTo(@17);
  59. make.height.equalTo(@17);
  60. make.left.equalTo(self.priceLb.mas_right);
  61. make.centerY.equalTo(self.priceLb);
  62. }];
  63. [self.numLB mas_makeConstraints:^(MASConstraintMaker *make) {
  64. make.width.equalTo(@25);
  65. make.height.equalTo(@17);
  66. make.left.equalTo(self.xLB.mas_right);
  67. make.centerY.equalTo(self.priceLb);
  68. }];
  69. }
  70. - (UIImageView *)imgV {
  71. if (!_imgV) {
  72. UIImageView *imgV = [[UIImageView alloc] init];
  73. _imgV = imgV;
  74. }
  75. return _imgV;
  76. }
  77. - (UILabel *)titleLB {
  78. if (!_titleLB) {
  79. UILabel *lb = [[UILabel alloc] init];
  80. lb.font = [UIFont fontWithName:Rob_Regular size:12];
  81. lb.textColor = [UIColor blackColor];
  82. lb.backgroundColor = [UIColor clearColor];
  83. lb.numberOfLines = 2;
  84. _titleLB = lb;
  85. }
  86. return _titleLB;
  87. }
  88. - (UILabel *)priceLb {
  89. if (!_priceLb) {
  90. UILabel *lb = [[UILabel alloc] init];
  91. lb.font = [UIFont fontWithName:Rob_Bold size:14];
  92. lb.textColor = _0B0B0B;
  93. lb.backgroundColor = [UIColor clearColor];
  94. _priceLb = lb;
  95. }
  96. return _priceLb;
  97. }
  98. - (UILabel *)xLB {
  99. if (!_xLB) {
  100. UILabel *lb = [[UILabel alloc] init];
  101. lb.font = [UIFont fontWithName:Rob_Regular size:14];
  102. lb.textColor = _0B0B0B;
  103. lb.backgroundColor = [UIColor clearColor];
  104. lb.textAlignment = NSTextAlignmentCenter;
  105. lb.text = @"x";
  106. _xLB = lb;
  107. }
  108. return _xLB;
  109. }
  110. - (UILabel *)numLB {
  111. if (!_numLB) {
  112. UILabel *lb = [[UILabel alloc] init];
  113. lb.font = [UIFont fontWithName:Rob_Regular size:14];
  114. lb.textColor = _0B0B0B;
  115. lb.backgroundColor = [UIColor clearColor];
  116. _numLB = lb;
  117. }
  118. return _numLB;
  119. }
  120. @end