KWMineHomeOrderSubView.m 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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) UIButton *editBt;
  15. @property (nonatomic, strong) KWMineOrderProInfoModel *m;
  16. @end
  17. @implementation KWMineHomeOrderSubView
  18. - (void)setData:(KWMineOrderProInfoModel *)model canEdit:(BOOL)canEdit {
  19. self.m = model;
  20. self.titleLB.text = model.name;
  21. self.priceLb.text = [NSString stringWithFormat:@"%@%@", model.currency_symbol, model.price];
  22. self.numLB.text = model.qty_ordered;
  23. NSString *imageStr = [NSString stringWithFormat:@"https:%@%@%@",HostPath,ProductImgPath,model.image];
  24. [self.imgV sd_setImageWithURL:[NSURL URLWithString:imageStr.urlEncode] placeholderImage:[UIImage imageNamed:@"product_defualtImg"]];
  25. self.editBt.hidden = !canEdit;
  26. }
  27. - (void)btAction:(UIButton *)bt {
  28. if (self.m && self.toAddCommentBlock) {
  29. self.toAddCommentBlock(self.m);
  30. }
  31. UIViewController *vc = [CTMediator.sharedInstance Goods_WriteReview:@{@"entity_id":self.m.product_id}];
  32. [Current_normalTool.currentNav pushViewController:vc animated:true];
  33. }
  34. -(instancetype)init {
  35. self = [super init];
  36. if (self) {
  37. [self loadSubV];
  38. }
  39. return self;
  40. }
  41. - (void)loadSubV {
  42. self.backgroundColor = UIColor.clearColor;
  43. [self addSubview:self.imgV];
  44. [self addSubview:self.titleLB];
  45. [self addSubview:self.priceLb];
  46. [self addSubview:self.xLB];
  47. [self addSubview:self.numLB];
  48. [self addSubview:self.editBt];
  49. [_imgV mas_makeConstraints:^(MASConstraintMaker *make) {
  50. make.top.equalTo(self).offset(0);
  51. make.left.equalTo(self).offset(0);
  52. make.bottom.equalTo(self).offset(0);
  53. make.width.height.equalTo(@86);
  54. }];
  55. [_titleLB mas_makeConstraints:^(MASConstraintMaker *make) {
  56. make.top.equalTo(self.imgV);
  57. make.left.equalTo(self.imgV.mas_right).offset(10);
  58. make.right.equalTo(self).offset(0);
  59. make.height.equalTo(@35);
  60. }];
  61. [self.priceLb setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
  62. [self.priceLb mas_makeConstraints:^(MASConstraintMaker *make) {
  63. make.bottom.equalTo(self.imgV);
  64. make.left.equalTo(self.titleLB);
  65. make.height.equalTo(@17);
  66. }];
  67. [self.xLB mas_makeConstraints:^(MASConstraintMaker *make) {
  68. make.width.equalTo(@17);
  69. make.height.equalTo(@17);
  70. make.left.equalTo(self.priceLb.mas_right);
  71. make.centerY.equalTo(self.priceLb);
  72. }];
  73. [self.numLB mas_makeConstraints:^(MASConstraintMaker *make) {
  74. make.width.equalTo(@25);
  75. make.height.equalTo(@17);
  76. make.left.equalTo(self.xLB.mas_right);
  77. make.centerY.equalTo(self.priceLb);
  78. }];
  79. [self.editBt mas_makeConstraints:^(MASConstraintMaker *make) {
  80. make.bottom.centerY.equalTo(self.priceLb);
  81. make.width.height.equalTo(@24);
  82. make.right.equalTo(self);
  83. }];
  84. }
  85. - (UIImageView *)imgV {
  86. if (!_imgV) {
  87. UIImageView *imgV = [[UIImageView alloc] init];
  88. _imgV = imgV;
  89. }
  90. return _imgV;
  91. }
  92. - (UILabel *)titleLB {
  93. if (!_titleLB) {
  94. UILabel *lb = [[UILabel alloc] init];
  95. lb.font = [UIFont fontWithName:Rob_Regular size:12];
  96. lb.textColor = [UIColor blackColor];
  97. lb.backgroundColor = [UIColor clearColor];
  98. lb.numberOfLines = 2;
  99. _titleLB = lb;
  100. }
  101. return _titleLB;
  102. }
  103. - (UILabel *)priceLb {
  104. if (!_priceLb) {
  105. UILabel *lb = [[UILabel alloc] init];
  106. lb.font = [UIFont fontWithName:Rob_Bold size:14];
  107. lb.textColor = _0B0B0B;
  108. lb.backgroundColor = [UIColor clearColor];
  109. _priceLb = lb;
  110. }
  111. return _priceLb;
  112. }
  113. - (UILabel *)xLB {
  114. if (!_xLB) {
  115. UILabel *lb = [[UILabel alloc] init];
  116. lb.font = [UIFont fontWithName:Rob_Regular size:14];
  117. lb.textColor = _0B0B0B;
  118. lb.backgroundColor = [UIColor clearColor];
  119. lb.textAlignment = NSTextAlignmentCenter;
  120. lb.text = @"x";
  121. _xLB = lb;
  122. }
  123. return _xLB;
  124. }
  125. - (UILabel *)numLB {
  126. if (!_numLB) {
  127. UILabel *lb = [[UILabel alloc] init];
  128. lb.font = [UIFont fontWithName:Rob_Regular size:14];
  129. lb.textColor = _0B0B0B;
  130. lb.backgroundColor = [UIColor clearColor];
  131. _numLB = lb;
  132. }
  133. return _numLB;
  134. }
  135. - (UIButton *)editBt {
  136. if (!_editBt) {
  137. UIButton *bt = [UIButton buttonWithType:UIButtonTypeCustom];
  138. [bt setImage:[UIImage imageNamed:@"mine_add_comment"] forState:UIControlStateNormal];
  139. [bt addTarget:self action:@selector(btAction:) forControlEvents:UIControlEventTouchUpInside];
  140. _editBt = bt;
  141. }
  142. return _editBt;
  143. }
  144. @end