// // SPSBQueryListDetailsTransactionTableViewController.m // 我的社保 // // Created by jiaxian_he on 2021/5/29. // #import "SPSBQueryListDetailsTransactionTableViewController.h" #import "SPSBUIGeneralHeader.h" #import "SPSBQueryListDetailsTransactionModel.h" #import "SPSBHorizontalListTableView.h" #import "SPSBOrderBalanceViewController.h" @interface SPSBQueryListDetailsTransactionTableViewCell : UITableViewCell { UILabel *_title; UILabel *_status; SPSBHorizontalListTableView *_contentView; } @end @implementation SPSBQueryListDetailsTransactionTableViewCell - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (!self) return nil; self.selectionStyle = UITableViewCellSelectionStyleNone; _title = [UILabel convenienceWithFont:spsb_font(17) text:nil textColor:spsb_333333_color()]; [self.contentView addSubview:_title]; [_title makeConstraints:^(JXHConstraintMaker *make) { make.leading.equalTo(15); make.top.equalTo(20); }]; _status = [UILabel convenienceWithFont:spsb_font(17) text:nil textColor:spsb_FF5E5E_color() textAlignment:NSTextAlignmentRight]; [self.contentView addSubview:_status]; [_status makeConstraints:^(JXHConstraintMaker *make) { make.trailing.equalTo(-15); make.centerY.equalTo(self->_title); }]; _contentView = [[SPSBHorizontalListTableView alloc] initWithData:nil isContentRightAlignment:true isLittleLayout:true]; [self.contentView addSubview:_contentView]; [_contentView makeConstraints:^(JXHConstraintMaker *make) { make.top.equalTo(self->_title.bottom).offset(6); make.leading.and.trailing.equalTo(0); make.bottom.equalTo(-17); make.height.equalTo(0); }]; UIView *intervalView = UIView.new; intervalView.backgroundColor = spsb_F5F5F5_color(); [self.contentView addSubview:intervalView]; [intervalView makeConstraints:^(JXHConstraintMaker *make) { make.bottom.and.leading.and.trailing.equalTo(0); make.height.equalTo(10); }]; return self; } - (void)reloadRefundData:(SPSBQueryListDetailsTransactionRefundModel *)data { _title.text = @"退款金额"; [_contentView reloadData:data.spsba_dataDic]; [_contentView makeConstraints:^(JXHConstraintMaker *make) { make.height.update(self->_contentView.spsb_height); }]; _status.text = [NSString stringWithFormat:@"¥%.2f", [data.spsb_price floatValue]]; _status.font = spsb_font(17); _status.textColor = spsb_FF5E5E_color(); } - (void)reloadOrderBalanceData:(SPSBQueryListDetailsTransactionOrderBalanceModel *)data { _title.text = @"补差额状态"; [_contentView reloadData:data.spsba_dataDic]; [_contentView makeConstraints:^(JXHConstraintMaker *make) { make.height.update(self->_contentView.spsb_height); }]; _status.text = [data.spsb_status isEqualToString:@"1"] ? @"等待付款" : @"交易成功"; _status.font = spsb_font(16); _status.textColor = [data.spsb_status isEqualToString:@"1"] ? spsb_FF5E5E_color() : spsb_3AB261_color(); } @end @interface SPSBQueryListDetailsTransactionTableViewController () { UIView *_orderBalanceFooter; } @end @implementation SPSBQueryListDetailsTransactionTableViewController - (instancetype)init { self = [super initWithStyle:UITableViewStyleGrouped backgroundColor:SPSBTableViewBackgroundColorGray]; if (!self) return nil; return self; } - (void)viewDidLoad { [super viewDidLoad]; } #pragma mark - Action - (void)payAction { SPSBOrderBalanceViewController *vc = SPSBOrderBalanceViewController.new; [self.navigationController pushViewController:vc animated:true]; } #pragma mark - Delegate & DataSource static NSString * const reuseIdentifier = @"SPSBQueryListDetailsTransactionTableViewCell"; - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { SPSBQueryListDetailsTransactionTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuseIdentifier]; if (!cell) { cell = [[SPSBQueryListDetailsTransactionTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifier]; } if (_spsb_type == SPSBQueryListDetailsTransactionTypeOrderBalance) { [cell reloadOrderBalanceData:_spsb_orderBalanceData[indexPath.row]]; } else if (_spsb_type == SPSBQueryListDetailsTransactionTypeRefund) { [cell reloadRefundData:_spsb_refundData[indexPath.row]]; } return cell; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { if (_spsb_type == SPSBQueryListDetailsTransactionTypeOrderBalance) { return _spsb_orderBalanceData.count; } else if (_spsb_type == SPSBQueryListDetailsTransactionTypeRefund) { return _spsb_refundData.count; } return 0; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [tableView deselectRowAtIndexPath:indexPath animated:false]; } - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { return 10; } - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { return UIView.new; } - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section { if (_spsb_type == SPSBQueryListDetailsTransactionTypeOrderBalance && _spsb_isHaveWaitForPay) { return 80; } return jxh_onePixe(); } - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section { if (_spsb_type == SPSBQueryListDetailsTransactionTypeOrderBalance && _spsb_isHaveWaitForPay) { if (!_orderBalanceFooter) { _orderBalanceFooter = UIView.new; UIButton *button = [UIButton convenienceWithFont:spsb_semiboldFont(16) target:self action:@selector(payAction)]; [button setTitle:@"立即补缴" titleColor:spsb_FFFFFF_color(1.f) image:nil backgroundImage:jxh_getImage(confirm_n) state:JXHButtonControlStateNormal]; [button setBackgroundImage:jxh_getImage(confirm_h) state:JXHButtonControlStateHighlighted]; [button setLayerCornerRadius:22.5 clipToBounds:true]; [_orderBalanceFooter addSubview:button]; [button makeConstraints:^(JXHConstraintMaker *make) { make.leading.equalTo(15); make.trailing.equalTo(-15); make.top.equalTo(24); make.height.equalTo(45); }]; } return _orderBalanceFooter; } return UIView.new; } #pragma mark - UI - (void)setupTableView { } @end