// // SPSBAccountSettingTableViewController.m // 我的社保 // // Created by shanp on 2021/5/21. // #import "SPSBAccountSettingTableViewController.h" #import "SPSBUIGeneralHeader.h" #import "SPSBKeyProfile.h" #import "SPSBLoginStatusManager.h" #import "SPSBNotificationDelegateManager.h" #import "SPSBChangePasswordTableViewController.h" #import "SPSBChangePhoneTableViewController.h" #import "SPSBSafeCenterTableViewController.h" @interface SPSBAccountSettingTableViewController () @end @implementation SPSBAccountSettingTableViewController - (instancetype)init { self = [super initWithStyle:UITableViewStyleGrouped backgroundColor:SPSBTableViewBackgroundColorGray]; if (!self) return nil; return self; } - (void)viewDidLoad { [super viewDidLoad]; [self setupUI]; } - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; [self.tableView reloadData]; } #pragma mark - Action - (void)loginOut { [SPSBLoginStatusManager handleLogout]; spsb_postNotification(SPSBLoggingNotificationKey, @selector(spsb_loggingStatusChanged:needCheckOrderBalanceNotPayOrders:), spsb_loggingStatusChanged:SPSBLoggingStatusLogout needCheckOrderBalanceNotPayOrders:false); [self.navigationController popViewControllerAnimated:true]; } #pragma mark - Network Action #pragma mark - Delegate & DataSource - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { NSArray *titleArray = @[@"修改密码", @"更换手机号", @"安全中心"]; UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil]; UILabel *titleLabel = [UILabel convenienceWithFont:spsb_font(16) text:titleArray[indexPath.row + indexPath.section * 2] textColor:spsb_333333_color()]; [cell.contentView addSubview:titleLabel]; [titleLabel makeConstraints:^(JXHConstraintMaker *make) { make.leading.equalTo(15); make.centerY.equalTo(0); }]; UIImageView *arrow = [[UIImageView alloc] initWithImage:jxh_getImage(list_arrow)]; [cell.contentView addSubview:arrow]; [arrow makeConstraints:^(JXHConstraintMaker *make) { make.trailing.equalTo(-15); make.centerY.equalTo(0); }]; if (indexPath.row == 1) { UILabel *contentLabel = [UILabel convenienceWithFont:spsb_font(16) text:[jxh_userDefaults() objectForKey:SPSBUserName] textColor:spsb_808080_color() textAlignment:NSTextAlignmentRight]; [cell.contentView addSubview:contentLabel]; [contentLabel makeConstraints:^(JXHConstraintMaker *make) { make.trailing.equalTo(-33); make.centerY.equalTo(0); }]; [cell.contentView createLineWithLocation:JXHLineLocationTop headOffset:15 footOffset:0]; } return cell; } - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 2; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { if (section == 1) return 1; return 2; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [tableView deselectRowAtIndexPath:indexPath animated:false]; switch (indexPath.row + indexPath.section * 2) { case 0: [self.navigationController pushViewController:SPSBChangePasswordTableViewController.new animated:true]; break; case 1: { [self.navigationController pushViewController:SPSBChangePhoneTableViewController.new animated:true]; } break; case 2: { [self.navigationController pushViewController:SPSBSafeCenterTableViewController.new animated:true]; } default: break; } } - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { return 12; } - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { return UIView.new; } - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section { return jxh_onePixe(); } - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section { return UIView.new; } #pragma mark - UI - (void)setupUI { self.title = @"账户设置"; [self setupTableView]; } - (void)setupTableView { self.tableView.rowHeight = 50.f; UIView *footerView = [[UIView alloc] initWithFrame:(CGRect){0, 0, jxh_screenWidth(), 50}]; UIButton *loginOutButton = [UIButton convenienceWithFont:spsb_font(16) target:self action:@selector(loginOut)]; [loginOutButton setTitle:@"退出登录" titleColor:spsb_FF5E5E_color() state:JXHButtonControlStateNormal]; loginOutButton.backgroundColor = spsb_FFFFFF_color(1.f); [footerView addSubview:loginOutButton]; [loginOutButton makeConstraints:^(JXHConstraintMaker *make) { make.top.equalTo(12); make.leading.and.trailing.equalTo(0); make.height.equalTo(50); }]; self.tableView.tableFooterView = footerView; } @end