SPSBChooseBankTableViewController.m 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. //
  2. // SPSBChooseBankTableViewController.m
  3. // 我的社保
  4. //
  5. // Created by shanp on 2021/5/19.
  6. //
  7. #import "SPSBChooseBankTableViewController.h"
  8. #import "SPSBUIGeneralHeader.h"
  9. #import "SPSBBusinessManager.h"
  10. #import "SPSBInputBankViewController.h"
  11. @interface SPSBChooseBankTableViewController (){
  12. NSArray *_dataArray;
  13. UIView *_footView;
  14. }
  15. @end
  16. @implementation SPSBChooseBankTableViewController
  17. - (instancetype)init {
  18. self = [super initWithStyle:UITableViewStyleGrouped backgroundColor:SPSBTableViewBackgroundColorGray];
  19. if (!self) return nil;
  20. return self;
  21. }
  22. - (void)viewDidLoad {
  23. [super viewDidLoad];
  24. [self initData];
  25. [self setupUI];
  26. }
  27. - (void)initData {
  28. _dataArray = spsb_bankArray();
  29. }
  30. #pragma mark - Action
  31. - (void)footAction {
  32. SPSBInputBankViewController *vc = SPSBInputBankViewController.new;
  33. vc.spsb_completionAction = _spsb_completionAction;
  34. [self.navigationController pushViewController:vc animated:true];
  35. }
  36. #pragma mark - Network Action
  37. #pragma mark - Delegate & DataSource
  38. static NSString * const reuseIdentifier = @"SPSBChooseBankTableViewCell";
  39. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  40. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuseIdentifier];
  41. if (!cell) {
  42. cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifier];
  43. UIImageView *icon = UIImageView.new;
  44. icon.tag = 3000;
  45. [cell.contentView addSubview:icon];
  46. [icon makeConstraints:^(JXHConstraintMaker *make) {
  47. make.leading.equalTo(20);
  48. make.centerY.equalTo(0);
  49. }];
  50. UILabel *label = [UILabel convenienceWithFont:spsb_font(16) text:@"" textColor:spsb_333333_color()];
  51. label.tag = 3001;
  52. [cell.contentView addSubview:label];
  53. [label makeConstraints:^(JXHConstraintMaker *make) {
  54. make.leading.equalTo(60);
  55. make.centerY.equalTo(cell.contentView);
  56. }];
  57. [cell.contentView createLineWithLocation:JXHLineLocationBottom headOffset:20 footOffset:0];
  58. }
  59. UIImageView *icon = [cell.contentView viewWithTag:3000];
  60. UILabel *label = [cell.contentView viewWithTag:3001];
  61. label.text = _dataArray[indexPath.row];
  62. icon.image = [UIImage imageNamed:spsb_bankIconDictionary()[label.text]];
  63. return cell;
  64. }
  65. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  66. return _dataArray.count;
  67. }
  68. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  69. [tableView deselectRowAtIndexPath:indexPath animated:false];
  70. _spsb_completionAction(_dataArray[indexPath.row]);
  71. [self.navigationController popViewControllerAnimated:true];
  72. }
  73. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
  74. return 12;
  75. }
  76. - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
  77. return UIView.new;
  78. }
  79. - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
  80. return 150;
  81. }
  82. - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
  83. if (!_footView) {
  84. _footView = UIView.new;
  85. UIButton *footButton = [UIButton convenienceWithTarget:self action:@selector(footAction)];
  86. footButton.backgroundColor = spsb_FFFFFF_color(1.f);
  87. [_footView addSubview:footButton];
  88. [footButton makeConstraints:^(JXHConstraintMaker *make) {
  89. make.top.and.leading.and.trailing.equalTo(0);
  90. make.height.equalTo(50);
  91. }];
  92. UILabel *label = [UILabel convenienceWithFont:spsb_font(16) text:@"其他银行" textColor:spsb_333333_color()];
  93. [footButton addSubview:label];
  94. [label makeConstraints:^(JXHConstraintMaker *make) {
  95. make.leading.equalTo(20);
  96. make.centerY.equalTo(0);
  97. }];
  98. }
  99. return _footView;
  100. }
  101. #pragma mark - UI
  102. - (void)setupUI {
  103. self.title = @"选择银行";
  104. [self setupTableView];
  105. }
  106. - (void)setupTableView {
  107. self.tableView.rowHeight = 50.f;
  108. }
  109. @end