KWMineHomeOrderListCell.m 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. //
  2. // KWMineHomeOrderListCell.m
  3. // westkissMob
  4. //
  5. // Created by iOS on 2022/9/15.
  6. //
  7. #import "KWMineHomeOrderListCell.h"
  8. #import "KWMineHomeOrderSubView.h"
  9. @interface KWMineHomeOrderListCell ()
  10. @property (nonatomic, strong) UIStackView *prodStackV;
  11. @property (nonatomic, strong) UIView *bgV;
  12. @property (nonatomic, strong) UILabel *orderNoNameLB;
  13. @property (nonatomic, strong) UILabel *orderNoLB;
  14. @property (nonatomic, strong) UILabel *timeLB;
  15. @property (nonatomic, strong) UIButton *viewBt;
  16. @property (nonatomic, strong) KWMineHomeOrderModel *m;
  17. @end
  18. @implementation KWMineHomeOrderListCell
  19. - (void)setData:(KWMineHomeOrderModel *)model {
  20. self.m = model;
  21. self.timeLB.text = model.created_at;
  22. self.orderNoLB.text = model.increment_id;
  23. for (UIView*item in self.prodStackV.arrangedSubviews) {
  24. if (item.superview) {
  25. [item removeFromSuperview];
  26. }
  27. }
  28. for (KWMineOrderProInfoModel *info in model.items) {
  29. KWMineHomeOrderSubView *subV = [[KWMineHomeOrderSubView alloc] init];
  30. [subV setData:info canEdit:false];
  31. [self.prodStackV addArrangedSubview:subV];
  32. }
  33. }
  34. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
  35. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  36. if (self) {
  37. [self configSubV];
  38. }
  39. return self;
  40. }
  41. - (void)awakeFromNib {
  42. [super awakeFromNib];
  43. // Initialization code
  44. }
  45. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  46. [super setSelected:selected animated:animated];
  47. // Configure the view for the selected state
  48. }
  49. - (void)configSubV {
  50. self.selectionStyle = UITableViewCellSelectionStyleNone;
  51. self.contentView.backgroundColor = Col_FFF;
  52. self.bgV = [UIView new];
  53. self.bgV.layer.cornerRadius = 4;
  54. self.bgV.layer.masksToBounds = true;
  55. self.bgV.backgroundColor = [UIColor colorWithHexString:@"#F8F8F8"];
  56. [self.contentView addSubview:self.bgV];
  57. [self.bgV mas_makeConstraints:^(MASConstraintMaker *make) {
  58. make.left.equalTo(self.contentView).offset(10);
  59. make.right.equalTo(self.contentView).offset(-10);
  60. make.top.equalTo(self.contentView).offset(0);
  61. make.bottom.equalTo(self.contentView).offset(-10);
  62. }];
  63. self.prodStackV = [[UIStackView alloc] init];
  64. self.prodStackV.axis = UILayoutConstraintAxisVertical;
  65. self.prodStackV.spacing = 20;
  66. self.prodStackV.distribution = UIStackViewDistributionFillEqually;
  67. self.prodStackV.alignment = UIStackViewAlignmentFill;
  68. [self.bgV addSubview:self.prodStackV];
  69. [self.prodStackV mas_makeConstraints:^(MASConstraintMaker *make) {
  70. make.top.equalTo(self.bgV).offset(20);
  71. make.left.equalTo(self.bgV).offset(10);
  72. make.right.equalTo(self.bgV).offset(-15);
  73. }];
  74. [self.bgV addSubview:self.orderNoNameLB];
  75. [self.bgV addSubview:self.orderNoLB];
  76. [self.bgV addSubview:self.timeLB];
  77. [self.bgV addSubview:self.viewBt];
  78. [self.orderNoNameLB mas_makeConstraints:^(MASConstraintMaker *make) {
  79. make.left.equalTo(self.prodStackV.mas_left);
  80. make.top.equalTo(self.prodStackV.mas_bottom).offset(21);
  81. make.height.equalTo(@16);
  82. }];
  83. [self.orderNoNameLB setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
  84. [self.orderNoLB mas_makeConstraints:^(MASConstraintMaker *make) {
  85. make.centerY.equalTo(self.orderNoNameLB);
  86. make.left.equalTo(self.orderNoNameLB.mas_right);
  87. make.right.equalTo(self.prodStackV.mas_right);
  88. make.height.equalTo(@16);
  89. }];
  90. [self.timeLB mas_makeConstraints:^(MASConstraintMaker *make) {
  91. make.left.equalTo(self.prodStackV);
  92. make.top.equalTo(self.orderNoNameLB.mas_bottom).offset(5);
  93. make.height.equalTo(@14);
  94. make.bottom.equalTo(self.bgV.mas_bottom).offset(-20);
  95. }];
  96. [self.viewBt mas_makeConstraints:^(MASConstraintMaker *make) {
  97. make.left.equalTo(self.timeLB.mas_right).offset(10);
  98. make.right.equalTo(self.prodStackV);
  99. make.bottom.equalTo(self.bgV.mas_bottom).offset(-20);
  100. make.height.equalTo(@17);
  101. make.width.equalTo(@75);
  102. }];
  103. }
  104. - (UILabel *)orderNoNameLB {
  105. if (!_orderNoNameLB) {
  106. UILabel *lb = [[UILabel alloc] init];
  107. lb.font = [UIFont fontWithName:Rob_Regular size:12];
  108. lb.textColor = [UIColor colorWithHexString:@"#666666"];
  109. lb.backgroundColor = [UIColor clearColor];
  110. lb.textAlignment = NSTextAlignmentLeft;
  111. lb.text = @"Order Number:";
  112. _orderNoNameLB = lb;
  113. }
  114. return _orderNoNameLB;
  115. }
  116. - (UILabel *)orderNoLB {
  117. if (!_orderNoLB) {
  118. UILabel *lb = [[UILabel alloc] init];
  119. lb.font = [UIFont fontWithName:Rob_Regular size:12];
  120. lb.textColor = [UIColor colorWithHexString:@"#666666"];
  121. lb.backgroundColor = [UIColor clearColor];
  122. _orderNoLB = lb;
  123. }
  124. return _orderNoLB;
  125. }
  126. - (UILabel *)timeLB {
  127. if (!_timeLB) {
  128. UILabel *lb = [[UILabel alloc] init];
  129. lb.font = [UIFont fontWithName:Rob_Regular size:12];
  130. lb.textColor = [UIColor colorWithHexString:@"#666666"];
  131. lb.backgroundColor = [UIColor clearColor];
  132. lb.textAlignment = NSTextAlignmentLeft;
  133. _timeLB = lb;
  134. }
  135. return _timeLB;
  136. }
  137. - (UIButton *)viewBt {
  138. if (!_viewBt) {
  139. UIButton *bt = [UIButton buttonWithType:UIButtonTypeCustom];
  140. NSMutableAttributedString *attStr = [[NSMutableAttributedString alloc] initWithString:@"View Order"];
  141. [attStr addAttributes:@{
  142. NSFontAttributeName:[UIFont fontWithName:Rob_Regular size:14],
  143. NSUnderlineStyleAttributeName:@(NSUnderlineStyleSingle),
  144. NSUnderlineColorAttributeName:[UIColor colorWithHexString:@"#000000"],
  145. NSForegroundColorAttributeName:[UIColor colorWithHexString:@"#000000"],
  146. } range:NSMakeRange(0, attStr.length)];
  147. [bt setAttributedTitle:attStr forState:UIControlStateNormal];
  148. [bt addTarget:self action:@selector(viewBtAction) forControlEvents:UIControlEventTouchUpInside];
  149. _viewBt = bt;
  150. }
  151. return _viewBt;
  152. }
  153. -(void)viewBtAction {
  154. if (self.viewOrderCall) {
  155. self.viewOrderCall(0, self.m);
  156. }
  157. }
  158. @end