No Description

FKPersonOrderSummaryCell.m 8.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. //
  2. // FKPersonOrderSummaryCell.m
  3. // FirstLink
  4. //
  5. // Created by ascii on 16/2/23.
  6. // Copyright © 2016年 FirstLink. All rights reserved.
  7. //
  8. #import "FKPersonOrderSummaryCell.h"
  9. #import "FKPersonOrderViewModel.h"
  10. #import "FKOrderPaymentItem.h"
  11. @interface FKPersonOrderSummaryCell ()
  12. @property (nonatomic, strong) UILabel *totalPriceTipLabel;
  13. @property (nonatomic, strong) UILabel *totalPriceLabel;
  14. @end
  15. @implementation FKPersonOrderSummaryCell
  16. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
  17. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  18. if (self) {
  19. self.contentView.backgroundColor = [UIColor whiteColor];
  20. [self addAllSubviews];
  21. }
  22. return self;
  23. }
  24. #pragma mark - Layout
  25. - (void)addAllSubviews {
  26. [self.contentView addSubview:self.paymentButton];
  27. [self.paymentButton mas_makeConstraints:^(MASConstraintMaker *make) {
  28. make.right.equalTo(self.contentView).offset(-15);
  29. make.centerY.equalTo(self.contentView).offset(-1);
  30. make.width.mas_equalTo(80);
  31. make.height.mas_equalTo(28);
  32. }];
  33. [self.contentView addSubview:self.cancelButton];
  34. [self.cancelButton mas_makeConstraints:^(MASConstraintMaker *make) {
  35. make.centerY.equalTo(self.paymentButton);
  36. make.right.equalTo(self.paymentButton.mas_left).offset(-10);
  37. make.width.mas_equalTo(80);
  38. make.height.mas_equalTo(28);
  39. }];
  40. [self.contentView addSubview:self.deleteButton];
  41. [self.deleteButton mas_makeConstraints:^(MASConstraintMaker *make) {
  42. make.right.equalTo(self.contentView).offset(-15);
  43. make.centerY.equalTo(self.contentView).offset(-1);
  44. make.width.mas_equalTo(80);
  45. make.height.mas_equalTo(28);
  46. }];
  47. [self.contentView addSubview:self.uploadIDCardButton];
  48. [self.uploadIDCardButton mas_makeConstraints:^(MASConstraintMaker *make) {
  49. make.right.equalTo(self.contentView).offset(-15);
  50. make.centerY.equalTo(self.contentView).offset(-1);
  51. make.width.mas_equalTo(80);
  52. make.height.mas_equalTo(28);
  53. }];
  54. [self.contentView addSubview:self.shareButton];
  55. [self.shareButton mas_makeConstraints:^(MASConstraintMaker *make) {
  56. make.centerY.equalTo(self.uploadIDCardButton);
  57. make.right.equalTo(self.uploadIDCardButton.mas_left).offset(-10);
  58. make.width.mas_equalTo(80);
  59. make.height.mas_equalTo(28);
  60. }];
  61. [self.contentView addSubview:self.totalPriceTipLabel];
  62. [self.totalPriceTipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  63. make.left.equalTo(self.contentView).with.offset(15);
  64. make.centerY.equalTo(self.paymentButton);
  65. }];
  66. [self.contentView addSubview:self.totalPriceLabel];
  67. [self.totalPriceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  68. make.left.equalTo(self.totalPriceTipLabel.mas_right);
  69. make.centerY.equalTo(self.paymentButton);
  70. }];
  71. }
  72. #pragma mark - FKPersonOrderCellDelegate
  73. - (void)configPersonOrderCell:(NSIndexPath *)indexPath classify:(FKPersonOrderClassify)classify viewModel:(FKPersonOrderViewModel *)viewModel {
  74. FKOrderPaymentItem *paymentItem = [viewModel paymentItemAtIndex:indexPath.section classify:classify];
  75. self.totalPriceLabel.text = [NSString stringWithFormat:@"¥%@", [FLStringHelper convertFenToYuan:paymentItem.totalFee]];
  76. /**
  77. * 根据状态显示按钮
  78. */
  79. [self hideAllActionButton];
  80. switch ((FKOrderStatus)([paymentItem.status intValue])) {
  81. case FKOrderStatusUnpay: {
  82. self.paymentButton.hidden = NO;
  83. self.cancelButton.hidden = NO;
  84. break;
  85. }
  86. case FKOrderStatusCancel:
  87. case FKOrderStatusIgnore:
  88. case FKOrderStatusInvalid: {
  89. self.deleteButton.hidden = NO;
  90. break;
  91. }
  92. case FKOrderStatusFinish:
  93. case FKOrderStatusRefund:
  94. case FKOrderStatusWaitDeliver:
  95. case FKOrderStatusWaitReceipt:
  96. case FKOrderStatusDenied:
  97. if (![paymentItem hasContainPindan]) self.shareButton.hidden = NO;
  98. break;
  99. default:
  100. break;
  101. }
  102. self.uploadIDCardButton.hidden = ![paymentItem isIDCardInvailid];
  103. if (self.uploadIDCardButton.hidden){
  104. [self.shareButton mas_remakeConstraints:^(MASConstraintMaker *make) {
  105. make.right.equalTo(self.contentView).offset(-15);
  106. make.centerY.equalTo(self.contentView).offset(-1);
  107. make.width.mas_equalTo(80);
  108. make.height.mas_equalTo(28);
  109. }];
  110. } else {
  111. [self.shareButton mas_remakeConstraints:^(MASConstraintMaker *make) {
  112. make.centerY.equalTo(self.uploadIDCardButton);
  113. make.right.equalTo(self.uploadIDCardButton.mas_left).offset(-10);
  114. make.width.mas_equalTo(80);
  115. make.height.mas_equalTo(28);
  116. }];
  117. }
  118. [self.contentView setNeedsLayout];
  119. [self.contentView layoutIfNeeded];
  120. }
  121. #pragma mark - Method
  122. - (void)hideAllActionButton {
  123. self.paymentButton.hidden = YES;
  124. self.cancelButton.hidden = YES;
  125. self.deleteButton.hidden = YES;
  126. self.uploadIDCardButton.hidden = YES;
  127. self.shareButton.hidden = YES;
  128. }
  129. #pragma mark - Property
  130. - (UIButton *)paymentButton {
  131. if (!_paymentButton) {
  132. _paymentButton = [UIButton buttonWithType:UIButtonTypeCustom];
  133. [_paymentButton setTitle:@"立即付款" forState:UIControlStateNormal];
  134. [_paymentButton.titleLabel setFont:[UIFont systemFontOfSize:14]];
  135. [_paymentButton setTitleColor:UIColorFromRGB(0xffffff)
  136. forState:UIControlStateNormal];
  137. [_paymentButton setBackgroundColor:UIColorFromRGB(0xff6362)];
  138. _paymentButton.layer.cornerRadius = 2;
  139. }
  140. return _paymentButton;
  141. }
  142. - (UIButton *)cancelButton {
  143. if (!_cancelButton) {
  144. _cancelButton = [UIButton buttonWithType:UIButtonTypeCustom];
  145. [_cancelButton setTitle:@"取消订单" forState:UIControlStateNormal];
  146. [_cancelButton.titleLabel setFont:[UIFont systemFontOfSize:14]];
  147. [_cancelButton setTitleColor:UIColorFromRGB(0x666666)
  148. forState:UIControlStateNormal];
  149. _cancelButton.layer.cornerRadius = 2;
  150. _cancelButton.layer.borderWidth = 1;
  151. _cancelButton.layer.borderColor = UIColorFromRGB(0xcccccc).CGColor;
  152. }
  153. return _cancelButton;
  154. }
  155. - (UIButton *)deleteButton {
  156. if (!_deleteButton) {
  157. _deleteButton = [UIButton buttonWithType:UIButtonTypeCustom];
  158. [_deleteButton setTitle:@"删除订单" forState:UIControlStateNormal];
  159. [_deleteButton.titleLabel setFont:[UIFont systemFontOfSize:14]];
  160. [_deleteButton setTitleColor:UIColorFromRGB(0x666666)
  161. forState:UIControlStateNormal];
  162. _deleteButton.layer.cornerRadius = 2;
  163. _deleteButton.layer.borderWidth = 1;
  164. _deleteButton.layer.borderColor = UIColorFromRGB(0xcccccc).CGColor;
  165. }
  166. return _deleteButton;
  167. }
  168. - (UIButton *)uploadIDCardButton {
  169. if (!_uploadIDCardButton) {
  170. _uploadIDCardButton = [UIButton buttonWithType:UIButtonTypeCustom];
  171. [_uploadIDCardButton setTitle:@"完善身份证" forState:UIControlStateNormal];
  172. [_uploadIDCardButton.titleLabel setFont:[UIFont systemFontOfSize:14]];
  173. [_uploadIDCardButton setTitleColor:UIColorFromRGB(0xffffff)
  174. forState:UIControlStateNormal];
  175. [_uploadIDCardButton setBackgroundColor:UIColorFromRGB(0xff6362)];
  176. _uploadIDCardButton.layer.cornerRadius = 2;
  177. }
  178. return _uploadIDCardButton;
  179. }
  180. - (UIButton *)shareButton{
  181. if (_shareButton == nil) {
  182. _shareButton = [UIButton buttonWithType:UIButtonTypeCustom];
  183. [_shareButton setTitle:@"分享赚积分" forState:UIControlStateNormal];
  184. [_shareButton.titleLabel setFont:[UIFont systemFontOfSize:14]];
  185. [_shareButton setTitleColor:UIColorFromRGB(0x666666)
  186. forState:UIControlStateNormal];
  187. _shareButton.layer.cornerRadius = 2;
  188. _shareButton.layer.borderWidth = 1;
  189. _shareButton.layer.borderColor = UIColorFromRGB(0xcccccc).CGColor;
  190. }
  191. return _shareButton;
  192. }
  193. - (UILabel *)totalPriceTipLabel {
  194. if (!_totalPriceTipLabel) {
  195. _totalPriceTipLabel = [UILabel new];
  196. _totalPriceTipLabel.textColor = UIColorFromRGB(0x666666);
  197. _totalPriceTipLabel.font = [UIFont systemFontOfSize:14.0];
  198. _totalPriceTipLabel.text = @"合计:";
  199. }
  200. return _totalPriceTipLabel;
  201. }
  202. - (UILabel *)totalPriceLabel {
  203. if (!_totalPriceLabel) {
  204. _totalPriceLabel = [UILabel new];
  205. _totalPriceLabel.textColor = UIColorFromRGB(0x333333);
  206. _totalPriceLabel.font = [UIFont boldSystemFontOfSize:14];
  207. }
  208. return _totalPriceLabel;
  209. }
  210. @end