SPSBAccountSettingTableViewController.m 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. //
  2. // SPSBAccountSettingTableViewController.m
  3. // 我的社保
  4. //
  5. // Created by shanp on 2021/5/21.
  6. //
  7. #import "SPSBAccountSettingTableViewController.h"
  8. #import "SPSBUIGeneralHeader.h"
  9. #import "SPSBKeyProfile.h"
  10. #import "SPSBLoginStatusManager.h"
  11. #import "SPSBNotificationDelegateManager.h"
  12. #import "SPSBChangePasswordTableViewController.h"
  13. #import "SPSBChangePhoneTableViewController.h"
  14. #import "SPSBSafeCenterTableViewController.h"
  15. @interface SPSBAccountSettingTableViewController ()
  16. @end
  17. @implementation SPSBAccountSettingTableViewController
  18. - (instancetype)init {
  19. self = [super initWithStyle:UITableViewStyleGrouped backgroundColor:SPSBTableViewBackgroundColorGray];
  20. if (!self) return nil;
  21. return self;
  22. }
  23. - (void)viewDidLoad {
  24. [super viewDidLoad];
  25. [self setupUI];
  26. }
  27. - (void)viewWillAppear:(BOOL)animated {
  28. [super viewWillAppear:animated];
  29. [self.tableView reloadData];
  30. }
  31. #pragma mark - Action
  32. - (void)loginOut {
  33. [SPSBLoginStatusManager handleLogout];
  34. spsb_postNotification(SPSBLoggingNotificationKey, @selector(spsb_loggingStatusChanged:needCheckOrderBalanceNotPayOrders:), spsb_loggingStatusChanged:SPSBLoggingStatusLogout needCheckOrderBalanceNotPayOrders:false);
  35. [self.navigationController popViewControllerAnimated:true];
  36. }
  37. #pragma mark - Network Action
  38. #pragma mark - Delegate & DataSource
  39. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  40. NSArray *titleArray = @[@"修改密码", @"更换手机号", @"安全中心"];
  41. UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];
  42. UILabel *titleLabel = [UILabel convenienceWithFont:spsb_font(16) text:titleArray[indexPath.row + indexPath.section * 2] textColor:spsb_333333_color()];
  43. [cell.contentView addSubview:titleLabel];
  44. [titleLabel makeConstraints:^(JXHConstraintMaker *make) {
  45. make.leading.equalTo(15);
  46. make.centerY.equalTo(0);
  47. }];
  48. UIImageView *arrow = [[UIImageView alloc] initWithImage:jxh_getImage(list_arrow)];
  49. [cell.contentView addSubview:arrow];
  50. [arrow makeConstraints:^(JXHConstraintMaker *make) {
  51. make.trailing.equalTo(-15);
  52. make.centerY.equalTo(0);
  53. }];
  54. if (indexPath.row == 1) {
  55. UILabel *contentLabel = [UILabel convenienceWithFont:spsb_font(16) text:[jxh_userDefaults() objectForKey:SPSBUserName] textColor:spsb_808080_color() textAlignment:NSTextAlignmentRight];
  56. [cell.contentView addSubview:contentLabel];
  57. [contentLabel makeConstraints:^(JXHConstraintMaker *make) {
  58. make.trailing.equalTo(-33);
  59. make.centerY.equalTo(0);
  60. }];
  61. [cell.contentView createLineWithLocation:JXHLineLocationTop headOffset:15 footOffset:0];
  62. }
  63. return cell;
  64. }
  65. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  66. return 2;
  67. }
  68. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  69. if (section == 1) return 1;
  70. return 2;
  71. }
  72. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  73. [tableView deselectRowAtIndexPath:indexPath animated:false];
  74. switch (indexPath.row + indexPath.section * 2) {
  75. case 0:
  76. [self.navigationController pushViewController:SPSBChangePasswordTableViewController.new animated:true];
  77. break;
  78. case 1: {
  79. [self.navigationController pushViewController:SPSBChangePhoneTableViewController.new animated:true];
  80. }
  81. break;
  82. case 2: {
  83. [self.navigationController pushViewController:SPSBSafeCenterTableViewController.new animated:true];
  84. }
  85. default:
  86. break;
  87. }
  88. }
  89. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
  90. return 12;
  91. }
  92. - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
  93. return UIView.new;
  94. }
  95. - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
  96. return jxh_onePixe();
  97. }
  98. - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
  99. return UIView.new;
  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. UIView *footerView = [[UIView alloc] initWithFrame:(CGRect){0, 0, jxh_screenWidth(), 50}];
  109. UIButton *loginOutButton = [UIButton convenienceWithFont:spsb_font(16) target:self action:@selector(loginOut)];
  110. [loginOutButton setTitle:@"退出登录" titleColor:spsb_FF5E5E_color() state:JXHButtonControlStateNormal];
  111. loginOutButton.backgroundColor = spsb_FFFFFF_color(1.f);
  112. [footerView addSubview:loginOutButton];
  113. [loginOutButton makeConstraints:^(JXHConstraintMaker *make) {
  114. make.top.equalTo(12);
  115. make.leading.and.trailing.equalTo(0);
  116. make.height.equalTo(50);
  117. }];
  118. self.tableView.tableFooterView = footerView;
  119. }
  120. @end