AccountViewController.mm 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. //
  2. // AccountViewController.m
  3. // FunSDKDemo
  4. //
  5. // Created by XM on 2018/11/29.
  6. // Copyright © 2018年 XM. All rights reserved.
  7. //
  8. #import "AccountViewController.h"
  9. #import "RegisterViewController.h"
  10. #import "ChangePasswordViewController.h"
  11. #import "UserAccountModel.h"
  12. #import "ForgetPasswordViewController.h"
  13. #import "UserInfoViewController.h"
  14. #import "PasswordSaveViewController.h"
  15. #import "LoginViewController.h"
  16. @interface AccountViewController () <UITableViewDelegate,UITableViewDataSource>
  17. {
  18. UserAccountModel *accountModel;
  19. NSMutableArray *titleArray;
  20. UITableView *mainTableView;
  21. }
  22. @end
  23. @implementation AccountViewController
  24. - (void)viewDidLoad {
  25. [super viewDidLoad];
  26. //设置导航栏样式
  27. [self setNaviStyle];
  28. [self initData];
  29. //配置子试图
  30. [self configSubView];
  31. }
  32. - (void)setNaviStyle {
  33. self.navigationItem.title = TS("About_User");
  34. }
  35. - (void)initData {
  36. accountModel = [[UserAccountModel alloc] init];
  37. titleArray = (NSMutableArray*)@[TS("Register_User"),TS("Login_User"),TS("Modify_pwd"),
  38. TS("Forget_Pwd"),TS("Info_User"),TS("Save_Pwd")];
  39. }
  40. - (void)configSubView {
  41. [self.view addSubview:self.mainTableView];
  42. }
  43. #pragma mark -- UITableViewDelegate/dataSource
  44. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  45. return 50;
  46. }
  47. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  48. return titleArray.count;
  49. }
  50. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  51. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"mainCell"];
  52. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  53. cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
  54. cell.textLabel.text = [titleArray objectAtIndex:indexPath.row];
  55. return cell;
  56. }
  57. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  58. NSString *title = [titleArray objectAtIndex:indexPath.row];
  59. if ([title isEqualToString:TS("Register_User")]) {
  60. //用户注册
  61. RegisterViewController *registerVC = [[RegisterViewController alloc] init];
  62. [self.navigationController pushViewController:registerVC animated:YES];
  63. }
  64. if ([title isEqualToString:TS("Login_User")]) {
  65. //用户登录
  66. if ([[LoginShowControl getInstance] getLoginType] != loginTypeNone) {
  67. [accountModel loginOut];
  68. [[LoginShowControl getInstance] setLoginType:loginTypeNone];
  69. }
  70. LoginViewController *loginV = [[LoginViewController alloc] initWithNibName:@"LoginViewController" bundle:nil];
  71. [self.navigationController pushViewController:loginV animated:YES];
  72. loginV.userNameTf.text = @"";
  73. loginV.passwordTf.text = @"";
  74. }
  75. if ([title isEqualToString:TS("Modify_pwd")]) {
  76. //修改密码
  77. ChangePasswordViewController *changePwdVC = [[ChangePasswordViewController alloc] init];
  78. [self.navigationController pushViewController:changePwdVC animated:YES];
  79. }
  80. if ([title isEqualToString:TS("Forget_Pwd")]) {
  81. //忘记密码
  82. ForgetPasswordViewController *forgetPwdVC = [[ForgetPasswordViewController alloc] init];
  83. [self.navigationController pushViewController:forgetPwdVC animated:YES];
  84. }
  85. if ([title isEqualToString:TS("Info_User")]) {
  86. //用户信息
  87. UserInfoViewController *userInfoVC = [[UserInfoViewController alloc] init];
  88. [self.navigationController pushViewController:userInfoVC animated:YES];
  89. }
  90. if ([title isEqualToString:TS("Save_Pwd")]) {
  91. //保存密码
  92. PasswordSaveViewController *passwordSaveVC = [[PasswordSaveViewController alloc] init];
  93. [self.navigationController pushViewController:passwordSaveVC animated:YES];
  94. }
  95. }
  96. - (UITableView *)mainTableView {
  97. if (!mainTableView) {
  98. mainTableView = [[UITableView alloc] initWithFrame:CGRectMake(10, 0, ScreenWidth - 20, ScreenHeight) style:UITableViewStylePlain];
  99. mainTableView.delegate = self;
  100. mainTableView.dataSource = self;
  101. [mainTableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"mainCell"];
  102. }
  103. return mainTableView;
  104. }
  105. - (void)didReceiveMemoryWarning {
  106. [super didReceiveMemoryWarning];
  107. // Dispose of any resources that can be recreated.
  108. }
  109. @end