SPSBQueryListDetailsTransactionTableViewController.m 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. //
  2. // SPSBQueryListDetailsTransactionTableViewController.m
  3. // 我的社保
  4. //
  5. // Created by jiaxian_he on 2021/5/29.
  6. //
  7. #import "SPSBQueryListDetailsTransactionTableViewController.h"
  8. #import "SPSBUIGeneralHeader.h"
  9. #import "SPSBQueryListDetailsTransactionModel.h"
  10. #import "SPSBHorizontalListTableView.h"
  11. #import "SPSBOrderBalanceViewController.h"
  12. @interface SPSBQueryListDetailsTransactionTableViewCell : UITableViewCell {
  13. UILabel *_title;
  14. UILabel *_status;
  15. SPSBHorizontalListTableView *_contentView;
  16. }
  17. @end
  18. @implementation SPSBQueryListDetailsTransactionTableViewCell
  19. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
  20. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  21. if (!self) return nil;
  22. self.selectionStyle = UITableViewCellSelectionStyleNone;
  23. _title = [UILabel convenienceWithFont:spsb_font(17) text:nil textColor:spsb_333333_color()];
  24. [self.contentView addSubview:_title];
  25. [_title makeConstraints:^(JXHConstraintMaker *make) {
  26. make.leading.equalTo(15);
  27. make.top.equalTo(20);
  28. }];
  29. _status = [UILabel convenienceWithFont:spsb_font(17) text:nil textColor:spsb_FF5E5E_color() textAlignment:NSTextAlignmentRight];
  30. [self.contentView addSubview:_status];
  31. [_status makeConstraints:^(JXHConstraintMaker *make) {
  32. make.trailing.equalTo(-15);
  33. make.centerY.equalTo(self->_title);
  34. }];
  35. _contentView = [[SPSBHorizontalListTableView alloc] initWithData:nil isContentRightAlignment:true isLittleLayout:true];
  36. [self.contentView addSubview:_contentView];
  37. [_contentView makeConstraints:^(JXHConstraintMaker *make) {
  38. make.top.equalTo(self->_title.bottom).offset(6);
  39. make.leading.and.trailing.equalTo(0);
  40. make.bottom.equalTo(-17);
  41. make.height.equalTo(0);
  42. }];
  43. UIView *intervalView = UIView.new;
  44. intervalView.backgroundColor = spsb_F5F5F5_color();
  45. [self.contentView addSubview:intervalView];
  46. [intervalView makeConstraints:^(JXHConstraintMaker *make) {
  47. make.bottom.and.leading.and.trailing.equalTo(0);
  48. make.height.equalTo(10);
  49. }];
  50. return self;
  51. }
  52. - (void)reloadRefundData:(SPSBQueryListDetailsTransactionRefundModel *)data {
  53. _title.text = @"退款金额";
  54. [_contentView reloadData:data.spsba_dataDic];
  55. [_contentView makeConstraints:^(JXHConstraintMaker *make) {
  56. make.height.update(self->_contentView.spsb_height);
  57. }];
  58. _status.text = [NSString stringWithFormat:@"¥%.2f", [data.spsb_price floatValue]];
  59. _status.font = spsb_font(17);
  60. _status.textColor = spsb_FF5E5E_color();
  61. }
  62. - (void)reloadOrderBalanceData:(SPSBQueryListDetailsTransactionOrderBalanceModel *)data {
  63. _title.text = @"补差额状态";
  64. [_contentView reloadData:data.spsba_dataDic];
  65. [_contentView makeConstraints:^(JXHConstraintMaker *make) {
  66. make.height.update(self->_contentView.spsb_height);
  67. }];
  68. _status.text = [data.spsb_status isEqualToString:@"1"] ? @"等待付款" : @"交易成功";
  69. _status.font = spsb_font(16);
  70. _status.textColor = [data.spsb_status isEqualToString:@"1"] ? spsb_FF5E5E_color() : spsb_3AB261_color();
  71. }
  72. @end
  73. @interface SPSBQueryListDetailsTransactionTableViewController () {
  74. UIView *_orderBalanceFooter;
  75. }
  76. @end
  77. @implementation SPSBQueryListDetailsTransactionTableViewController
  78. - (instancetype)init {
  79. self = [super initWithStyle:UITableViewStyleGrouped backgroundColor:SPSBTableViewBackgroundColorGray];
  80. if (!self) return nil;
  81. return self;
  82. }
  83. - (void)viewDidLoad {
  84. [super viewDidLoad];
  85. }
  86. #pragma mark - Action
  87. - (void)payAction {
  88. SPSBOrderBalanceViewController *vc = SPSBOrderBalanceViewController.new;
  89. [self.navigationController pushViewController:vc animated:true];
  90. }
  91. #pragma mark - Delegate & DataSource
  92. static NSString * const reuseIdentifier = @"SPSBQueryListDetailsTransactionTableViewCell";
  93. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  94. SPSBQueryListDetailsTransactionTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuseIdentifier];
  95. if (!cell) {
  96. cell = [[SPSBQueryListDetailsTransactionTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifier];
  97. }
  98. if (_spsb_type == SPSBQueryListDetailsTransactionTypeOrderBalance) {
  99. [cell reloadOrderBalanceData:_spsb_orderBalanceData[indexPath.row]];
  100. } else if (_spsb_type == SPSBQueryListDetailsTransactionTypeRefund) {
  101. [cell reloadRefundData:_spsb_refundData[indexPath.row]];
  102. }
  103. return cell;
  104. }
  105. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  106. if (_spsb_type == SPSBQueryListDetailsTransactionTypeOrderBalance) {
  107. return _spsb_orderBalanceData.count;
  108. } else if (_spsb_type == SPSBQueryListDetailsTransactionTypeRefund) {
  109. return _spsb_refundData.count;
  110. }
  111. return 0;
  112. }
  113. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  114. [tableView deselectRowAtIndexPath:indexPath animated:false];
  115. }
  116. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
  117. return 10;
  118. }
  119. - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
  120. return UIView.new;
  121. }
  122. - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
  123. if (_spsb_type == SPSBQueryListDetailsTransactionTypeOrderBalance && _spsb_isHaveWaitForPay) {
  124. return 80;
  125. }
  126. return jxh_onePixe();
  127. }
  128. - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
  129. if (_spsb_type == SPSBQueryListDetailsTransactionTypeOrderBalance && _spsb_isHaveWaitForPay) {
  130. if (!_orderBalanceFooter) {
  131. _orderBalanceFooter = UIView.new;
  132. UIButton *button = [UIButton convenienceWithFont:spsb_semiboldFont(16) target:self action:@selector(payAction)];
  133. [button setTitle:@"立即补缴" titleColor:spsb_FFFFFF_color(1.f) image:nil backgroundImage:jxh_getImage(confirm_n) state:JXHButtonControlStateNormal];
  134. [button setBackgroundImage:jxh_getImage(confirm_h) state:JXHButtonControlStateHighlighted];
  135. [button setLayerCornerRadius:22.5 clipToBounds:true];
  136. [_orderBalanceFooter addSubview:button];
  137. [button makeConstraints:^(JXHConstraintMaker *make) {
  138. make.leading.equalTo(15);
  139. make.trailing.equalTo(-15);
  140. make.top.equalTo(24);
  141. make.height.equalTo(45);
  142. }];
  143. }
  144. return _orderBalanceFooter;
  145. }
  146. return UIView.new;
  147. }
  148. #pragma mark - UI
  149. - (void)setupTableView {
  150. }
  151. @end