MyOrderTableViewCell.m 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. //
  2. // MyOrderTableViewCell.m
  3. // DSH
  4. //
  5. // Created by 张毅成 on 2018/10/8.
  6. // Copyright © 2018 WZX. All rights reserved.
  7. //
  8. #import "MyOrderTableViewCell.h"
  9. @implementation MyOrderTableViewCell
  10. - (void)awakeFromNib {
  11. [super awakeFromNib];
  12. self.backgroundColor = kBackgroundColor;
  13. self.translatesAutoresizingMaskIntoConstraints = false;
  14. [self.viewBG setCorner];
  15. [self.arrayButtonBottom enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
  16. UIButton *button = obj;
  17. if (button.tag == 0) {
  18. [button setShadow];
  19. }else
  20. [button setCorner];
  21. [button addEventHandler:^(id sender) {
  22. switch (idx) {
  23. case 0:
  24. if (self.blockDidTouchButton0) {
  25. self.blockDidTouchButton0();
  26. }
  27. break;
  28. case 1:
  29. if (self.blockDidTouchButton1) {
  30. self.blockDidTouchButton1();
  31. }
  32. break;
  33. case 2:
  34. if (self.blockDidTouchButton2) {
  35. self.blockDidTouchButton2();
  36. }
  37. break;
  38. default:
  39. break;
  40. }
  41. } forControlEvents:(UIControlEventTouchUpInside)];
  42. }];
  43. self.backgroundColor = [UIColor whiteColor];
  44. [self.buttonDelete addEventHandler:^(id sender) {
  45. if (self.blockDidTouchButtonDelete) {
  46. self.blockDidTouchButtonDelete();
  47. }
  48. } forControlEvents:(UIControlEventTouchUpInside)];
  49. }
  50. - (void)setModel:(MyOrderModel *)model {
  51. if (model.orderType == 2) {
  52. [self setButtonBottomWithType:4];
  53. }else if (model.orderType == 3) {
  54. [self setButtonBottomWithType:5];
  55. }else
  56. [self setButtonBottomWithType:model.orderType];
  57. self.labelType.text = model.arrayTypeTitle[model.orderType]?:@"暂无";
  58. self.labelBookName.text = model.productName?:@"暂无";
  59. // [self.imageViewIcon sd_setImageWithURL:model.coverImgUrl placeholderImage:[UIImage imageNamed:@"加载中"]];
  60. self.labelAuthor.text = model.author?:@"暂无";
  61. self.labelMoney.text = [NSString stringWithFormat:@"¥%0.2f",model.totalPrice];
  62. }
  63. - (void)setButtonBottomWithType:(NSInteger)type {
  64. [self.arrayButtonBottom enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
  65. UIButton *button = obj;
  66. switch (type) {
  67. case MyOrderTableViewCellTypeAll:
  68. if (button.tag == 0) {
  69. [button setTitle:@"付款" forState:(UIControlStateNormal)];
  70. }else if (button.tag == 1) {
  71. [button setTitle:@"取消" forState:(UIControlStateNormal)];
  72. button.hidden = true;
  73. }else if (button.tag == 2) {
  74. button.hidden = true;
  75. }
  76. break;
  77. case MyOrderTableViewCellTypeObligation:
  78. if (button.tag == 0) {
  79. [button setTitle:@"付款" forState:(UIControlStateNormal)];
  80. }else if (button.tag == 1) {
  81. [button setTitle:@"取消" forState:(UIControlStateNormal)];
  82. button.hidden = true;
  83. }else if (button.tag == 2) {
  84. button.hidden = true;
  85. }
  86. break;
  87. case MyOrderTableViewCellTypeSendGoods:
  88. if (button.tag == 0) {
  89. [button setTitle:@"物流" forState:(UIControlStateNormal)];
  90. }else if (button.tag == 1) {
  91. [button setTitle:@"退款" forState:(UIControlStateNormal)];
  92. }else if (button.tag == 2) {
  93. button.hidden = true;
  94. }
  95. break;
  96. case MyOrderTableViewCellTypeForTheGoods:
  97. if (button.tag == 0) {
  98. [button setTitle:@"收货" forState:(UIControlStateNormal)];
  99. }else if (button.tag == 1) {
  100. [button setTitle:@"物流" forState:(UIControlStateNormal)];
  101. }else if (button.tag == 2) {
  102. [button setTitle:@"退款" forState:(UIControlStateNormal)];
  103. button.hidden = false;
  104. }
  105. break;
  106. case MyOrderTableViewCellTypeEvaluate:
  107. if (button.tag == 0) {
  108. [button setTitle:@"评价" forState:(UIControlStateNormal)];
  109. }else if (button.tag == 1) {
  110. button.hidden = true;
  111. }else if (button.tag == 2) {
  112. button.hidden = true;
  113. }
  114. break;
  115. case MyOrderTableViewCellTypeCancel:
  116. if (button.tag == 0) {
  117. [button setTitle:@"再次购买" forState:(UIControlStateNormal)];
  118. }else if (button.tag == 1) {
  119. button.hidden = true;
  120. }else if (button.tag == 2) {
  121. button.hidden = true;
  122. }
  123. break;
  124. default:
  125. break;
  126. }
  127. }];
  128. }
  129. + (instancetype)cellWithTableView:(UITableView *)tableView AndIndex:(NSInteger)index {
  130. NSString *ID = [NSString stringWithFormat:@"MyOrderTableViewCell%ld",(long)index];
  131. MyOrderTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
  132. if (cell == nil) {
  133. cell = [[NSBundle mainBundle] loadNibNamed:@"MyOrderTableViewCell" owner:self options:nil][index];
  134. }
  135. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  136. return cell;
  137. }
  138. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  139. [super setSelected:selected animated:animated];
  140. // Configure the view for the selected state
  141. }
  142. @end