ASOrderListCell.m 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  1. //
  2. // ASOrderListCell.m
  3. // Asteria
  4. //
  5. // Created by iOS on 2024/5/14.
  6. //
  7. #import "ASOrderListCell.h"
  8. #import "KWMineHomeOrderSubView.h"
  9. @interface ASOrderListCell ()
  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) UIButton *trackBt;
  17. @property (nonatomic, strong) UIButton *reorderBt;
  18. @property (nonatomic, strong) UIButton *paynowBt;
  19. @property (nonatomic, strong) UILabel *statusLb;
  20. @property (nonatomic, strong) UILabel *totalTiLb;
  21. @property (nonatomic, strong) UILabel *totalNumLb;
  22. @property (nonatomic, strong) UIView *lineV;
  23. @property (nonatomic, strong) KWMineHomeOrderModel *m;
  24. @end
  25. @implementation ASOrderListCell
  26. - (void)setData:(KWMineHomeOrderModel *)model {
  27. self.m = model;
  28. self.statusLb.text = model.state;
  29. self.timeLB.text = [NSString stringWithFormat:@"Date: %@", model.created_at];
  30. self.orderNoLB.text = model.increment_id;
  31. self.totalNumLb.text = [NSString stringWithFormat:@"%@%@", model.currency_symbol, model.grand_total];
  32. for (UIView*item in self.prodStackV.arrangedSubviews) {
  33. if (item.superview) {
  34. [item removeFromSuperview];
  35. }
  36. }
  37. for (KWMineOrderProInfoModel *info in model.items) {
  38. KWMineHomeOrderSubView *subV = [[KWMineHomeOrderSubView alloc] init];
  39. [subV setData:info canEdit:true];
  40. [self.prodStackV addArrangedSubview:subV];
  41. }
  42. }
  43. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
  44. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  45. if (self) {
  46. [self configSubV];
  47. }
  48. return self;
  49. }
  50. - (void)awakeFromNib {
  51. [super awakeFromNib];
  52. // Initialization code
  53. }
  54. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  55. [super setSelected:selected animated:animated];
  56. // Configure the view for the selected state
  57. }
  58. - (void)configSubV {
  59. self.selectionStyle = UITableViewCellSelectionStyleNone;
  60. self.contentView.backgroundColor = _F8F8F8;
  61. self.bgV = [UIView new];
  62. self.bgV.layer.cornerRadius = 4;
  63. self.bgV.layer.masksToBounds = true;
  64. self.bgV.backgroundColor = Col_FFF;
  65. [self.contentView addSubview:self.bgV];
  66. [self.bgV mas_makeConstraints:^(MASConstraintMaker *make) {
  67. make.left.equalTo(self.contentView).offset(10);
  68. make.right.equalTo(self.contentView).offset(-10);
  69. make.top.equalTo(self.contentView).offset(0);
  70. make.bottom.equalTo(self.contentView).offset(-10);
  71. }];
  72. self.prodStackV = [[UIStackView alloc] init];
  73. self.prodStackV.axis = UILayoutConstraintAxisVertical;
  74. self.prodStackV.spacing = 20;
  75. self.prodStackV.distribution = UIStackViewDistributionFillEqually;
  76. self.prodStackV.alignment = UIStackViewAlignmentFill;
  77. [self.bgV addSubview:self.prodStackV];
  78. [self.bgV addSubview:self.orderNoNameLB];
  79. [self.bgV addSubview:self.orderNoLB];
  80. [self.bgV addSubview:self.timeLB];
  81. [self.bgV addSubview:self.viewBt];
  82. [self.bgV addSubview:self.statusLb];
  83. [self.bgV addSubview:self.totalTiLb];
  84. [self.bgV addSubview:self.totalNumLb];
  85. [self.bgV addSubview:self.lineV];
  86. UIStackView *btStv = [[UIStackView alloc] init];
  87. btStv.axis = UILayoutConstraintAxisHorizontal;
  88. btStv.spacing = 20;
  89. btStv.distribution = UIStackViewDistributionFillEqually;
  90. btStv.alignment = UIStackViewAlignmentFill;
  91. [self.bgV addSubview:btStv];
  92. // [btStv addArrangedSubview:self.trackBt];
  93. [btStv addArrangedSubview:self.reorderBt];
  94. [btStv addArrangedSubview:self.viewBt];
  95. [btStv addArrangedSubview:self.paynowBt];
  96. [self.statusLb mas_makeConstraints:^(MASConstraintMaker *make) {
  97. make.left.equalTo(@10);
  98. make.right.equalTo(@(-10));
  99. make.top.equalTo(self.bgV).offset(20);
  100. make.height.equalTo(@17);
  101. }];
  102. [self.orderNoNameLB mas_makeConstraints:^(MASConstraintMaker *make) {
  103. make.left.equalTo(self.statusLb);
  104. make.top.equalTo(self.statusLb.mas_bottom).offset(10);
  105. make.height.equalTo(@16);
  106. }];
  107. [self.orderNoLB mas_makeConstraints:^(MASConstraintMaker *make) {
  108. make.left.equalTo(self.orderNoNameLB.mas_right);
  109. make.centerY.equalTo(self.orderNoNameLB);
  110. make.height.equalTo(@16);
  111. }];
  112. [self.orderNoLB setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
  113. [self.orderNoNameLB setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
  114. [self.timeLB mas_makeConstraints:^(MASConstraintMaker *make) {
  115. make.left.equalTo(self.orderNoLB.mas_right).offset(10);
  116. make.centerY.equalTo(self.orderNoNameLB);
  117. make.height.equalTo(@16);
  118. make.right.equalTo(self.bgV).offset(-10);
  119. }];
  120. [self.lineV mas_makeConstraints:^(MASConstraintMaker *make) {
  121. make.left.right.equalTo(self.statusLb);
  122. make.height.equalTo(@1);
  123. make.top.equalTo(self.orderNoNameLB.mas_bottom).offset(10);
  124. }];
  125. [self.prodStackV mas_makeConstraints:^(MASConstraintMaker *make) {
  126. make.top.equalTo(self.lineV.mas_bottom).offset(10);
  127. make.left.equalTo(self.bgV).offset(10);
  128. make.right.equalTo(self.bgV).offset(-10);
  129. }];
  130. [self.totalTiLb mas_makeConstraints:^(MASConstraintMaker *make) {
  131. make.left.equalTo(self.prodStackV.mas_left);
  132. make.top.equalTo(self.prodStackV.mas_bottom).offset(21);
  133. make.height.equalTo(@16);
  134. }];
  135. [self.totalNumLb setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
  136. [self.totalNumLb mas_makeConstraints:^(MASConstraintMaker *make) {
  137. make.centerY.equalTo(self.totalTiLb);
  138. make.left.equalTo(self.totalTiLb.mas_right);
  139. make.right.equalTo(self.prodStackV.mas_right);
  140. make.height.equalTo(@16);
  141. }];
  142. [btStv mas_makeConstraints:^(MASConstraintMaker *make) {
  143. make.right.equalTo(self.statusLb);
  144. make.bottom.equalTo(self.bgV.mas_bottom).offset(-30);
  145. make.height.equalTo(@36);
  146. make.top.equalTo(self.totalTiLb.mas_bottom).offset(30);
  147. }];
  148. [self.viewBt mas_makeConstraints:^(MASConstraintMaker *make) {
  149. make.height.equalTo(@36);
  150. make.width.equalTo(@76);
  151. }];
  152. }
  153. - (UIView *)lineV {
  154. if (!_lineV) {
  155. UIView *v = [UIView baseV];
  156. v.backgroundColor = _F4F4F4;
  157. _lineV = v;
  158. }
  159. return _lineV;
  160. }
  161. - (UILabel *)statusLb {
  162. if (!_statusLb) {
  163. UILabel *lb = [[UILabel alloc] init];
  164. lb.font = [UIFont fontWithName:Rob_Bold size:14];
  165. lb.textColor = Col_000;
  166. lb.backgroundColor = [UIColor clearColor];
  167. _statusLb = lb;
  168. }
  169. return _statusLb;
  170. }
  171. - (UILabel *)totalTiLb {
  172. if (!_totalTiLb) {
  173. UILabel *lb = [[UILabel alloc] init];
  174. lb.font = [UIFont fontWithName:Rob_Regular size:14];
  175. lb.textColor = Col_000;
  176. lb.backgroundColor = [UIColor clearColor];
  177. lb.textAlignment = NSTextAlignmentRight;
  178. lb.text = @"Order Total:";
  179. _totalTiLb = lb;
  180. }
  181. return _totalTiLb;
  182. }
  183. - (UILabel *)totalNumLb {
  184. if (!_totalNumLb) {
  185. UILabel *lb = [[UILabel alloc] init];
  186. lb.font = [UIFont fontWithName:Rob_Bold size:14];
  187. lb.textColor = Col_000;
  188. lb.backgroundColor = [UIColor clearColor];
  189. _totalNumLb = lb;
  190. }
  191. return _totalNumLb;
  192. }
  193. - (UILabel *)orderNoNameLB {
  194. if (!_orderNoNameLB) {
  195. UILabel *lb = [[UILabel alloc] init];
  196. lb.font = [UIFont fontWithName:Rob_Regular size:12];
  197. lb.textColor = [UIColor colorWithHexString:@"#666666"];
  198. lb.backgroundColor = [UIColor clearColor];
  199. lb.textAlignment = NSTextAlignmentLeft;
  200. lb.text = @"Order Number:";
  201. _orderNoNameLB = lb;
  202. }
  203. return _orderNoNameLB;
  204. }
  205. - (UILabel *)orderNoLB {
  206. if (!_orderNoLB) {
  207. UILabel *lb = [[UILabel alloc] init];
  208. lb.font = [UIFont fontWithName:Rob_Regular size:12];
  209. lb.textColor = [UIColor colorWithHexString:@"#666666"];
  210. lb.backgroundColor = [UIColor clearColor];
  211. _orderNoLB = lb;
  212. }
  213. return _orderNoLB;
  214. }
  215. - (UILabel *)timeLB {
  216. if (!_timeLB) {
  217. UILabel *lb = [[UILabel alloc] init];
  218. lb.font = [UIFont fontWithName:Rob_Regular size:12];
  219. lb.textColor = [UIColor colorWithHexString:@"#666666"];
  220. lb.backgroundColor = [UIColor clearColor];
  221. lb.textAlignment = NSTextAlignmentLeft;
  222. _timeLB = lb;
  223. }
  224. return _timeLB;
  225. }
  226. - (UIButton *)viewBt {
  227. if (!_viewBt) {
  228. UIButton *bt = [UIButton buttonWithType:UIButtonTypeCustom];
  229. NSMutableAttributedString *attStr = [[NSMutableAttributedString alloc] initWithString:@"View Order"];
  230. [attStr addAttributes:@{
  231. NSFontAttributeName:[UIFont fontWithName:Rob_Regular size:14],
  232. NSUnderlineStyleAttributeName:@(NSUnderlineStyleSingle),
  233. NSUnderlineColorAttributeName:[UIColor colorWithHexString:@"#000000"],
  234. NSForegroundColorAttributeName:[UIColor colorWithHexString:@"#000000"],
  235. } range:NSMakeRange(0, attStr.length)];
  236. bt.tag = 10000;
  237. [bt setAttributedTitle:attStr forState:UIControlStateNormal];
  238. [bt addTarget:self action:@selector(viewBtAction:) forControlEvents:UIControlEventTouchUpInside];
  239. _viewBt = bt;
  240. }
  241. return _viewBt;
  242. }
  243. - (UIButton *)trackBt {
  244. if (!_trackBt) {
  245. UIButton *bt = [UIButton buttonWithType:UIButtonTypeCustom];
  246. NSMutableAttributedString *attStr = [[NSMutableAttributedString alloc] initWithString:@"Track Order"];
  247. [attStr addAttributes:@{
  248. NSFontAttributeName:[UIFont fontWithName:Rob_Regular size:14],
  249. NSUnderlineStyleAttributeName:@(NSUnderlineStyleSingle),
  250. NSUnderlineColorAttributeName:[UIColor colorWithHexString:@"#000000"],
  251. NSForegroundColorAttributeName:[UIColor colorWithHexString:@"#000000"],
  252. } range:NSMakeRange(0, attStr.length)];
  253. bt.tag = 10001;
  254. [bt setAttributedTitle:attStr forState:UIControlStateNormal];
  255. [bt addTarget:self action:@selector(viewBtAction:) forControlEvents:UIControlEventTouchUpInside];
  256. _trackBt = bt;
  257. }
  258. return _trackBt;
  259. }
  260. - (UIButton *)reorderBt {
  261. if (!_reorderBt) {
  262. UIButton *bt = [UIButton buttonWithType:UIButtonTypeCustom];
  263. NSMutableAttributedString *attStr = [[NSMutableAttributedString alloc] initWithString:@"Reorder"];
  264. [attStr addAttributes:@{
  265. NSFontAttributeName:[UIFont fontWithName:Rob_Regular size:14],
  266. NSUnderlineStyleAttributeName:@(NSUnderlineStyleSingle),
  267. NSUnderlineColorAttributeName:[UIColor colorWithHexString:@"#000000"],
  268. NSForegroundColorAttributeName:[UIColor colorWithHexString:@"#000000"],
  269. } range:NSMakeRange(0, attStr.length)];
  270. bt.tag = 10002;
  271. [bt setAttributedTitle:attStr forState:UIControlStateNormal];
  272. [bt addTarget:self action:@selector(viewBtAction:) forControlEvents:UIControlEventTouchUpInside];
  273. _reorderBt = bt;
  274. }
  275. return _reorderBt;
  276. }
  277. - (UIButton *)paynowBt {
  278. if (!_paynowBt) {
  279. UIButton *bt = [UIButton buttonWithType:UIButtonTypeCustom];
  280. bt.tag = 10003;
  281. bt.hidden = true;
  282. bt.titleLabel.font = [UIFont fontWithName:Rob_Regular size:14];
  283. [bt setTitle:@"Pay Now" forState:UIControlStateNormal];
  284. [bt addTarget:self action:@selector(viewBtAction:) forControlEvents:UIControlEventTouchUpInside];
  285. _viewBt = bt;
  286. }
  287. return _viewBt;
  288. }
  289. -(void)viewBtAction:(UIButton *)bt {
  290. if (self.viewOrderCall) {
  291. self.viewOrderCall(bt.tag-10000, self.m);
  292. }
  293. }
  294. @end