SettingViewController.m 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. //
  2. // SettingViewController.m
  3. // KulexiuForTeacher
  4. //
  5. // Created by Kyle on 2022/3/21.
  6. //
  7. #import "SettingViewController.h"
  8. #import "SettingBodyView.h"
  9. #import "KSBaseWKWebViewController.h"
  10. #import "FeedbackViewController.h"
  11. #import "AboutUsViewController.h"
  12. #import "AddressListViewController.h"
  13. #import "RCConnectionManager.h"
  14. #import "LoginViewController.h"
  15. #import "AppDelegate.h"
  16. #import "CustomNavViewController.h"
  17. #import "JPUSHService.h"
  18. #import "UserInfoManager.h"
  19. #import "AccountDeleteViewController.h"
  20. #import "UserInfoManager.h"
  21. @interface SettingViewController ()
  22. @property (nonatomic, strong) SettingBodyView *bodyView;
  23. @end
  24. @implementation SettingViewController
  25. - (void)viewDidLoad {
  26. [super viewDidLoad];
  27. // Do any additional setup after loading the view.
  28. [self allocTitle:@"设置"];
  29. [self configUI];
  30. }
  31. - (void)viewWillAppear:(BOOL)animated {
  32. [super viewWillAppear:animated];
  33. [self requestUserMemo];
  34. }
  35. - (void)requestUserMemo {
  36. [[UserInfoManager shareInstance] requsetconfigCallback:^(BOOL success) {
  37. [self refreshBodyView:success];
  38. }];
  39. }
  40. - (void)refreshBodyView:(BOOL)isMember {
  41. self.bodyView.isMember = isMember;
  42. }
  43. - (void)configUI {
  44. [self.scrollView mas_remakeConstraints:^(MASConstraintMaker *make) {
  45. make.left.right.mas_equalTo(self.view);
  46. make.top.mas_equalTo(self.view.mas_top);
  47. make.bottom.mas_equalTo(self.view.mas_bottom).offset(-iPhoneXSafeBottomMargin);
  48. }];
  49. self.bodyView = [SettingBodyView shareInstance];
  50. CGFloat viewHeight = KPortraitHeight - kNaviBarHeight - iPhoneXSafeBottomMargin;
  51. [self.scrollView addSubview:self.bodyView];
  52. [self.bodyView mas_makeConstraints:^(MASConstraintMaker *make) {
  53. make.top.mas_equalTo(self.scrollView.mas_top);
  54. make.right.left.mas_equalTo(self.view);
  55. make.height.mas_equalTo(viewHeight);
  56. }];
  57. [self.scrollView setContentSize:CGSizeMake(kScreenWidth, viewHeight)];
  58. KSWeakSelf(weakSelf);
  59. [self.bodyView settingAction:^(SETTINGACTION type) {
  60. [weakSelf operationAction:type];
  61. }];
  62. }
  63. - (void)operationAction:(SETTINGACTION)type {
  64. switch (type) {
  65. case SETTINGACTION_ADDRESS:
  66. {
  67. AddressListViewController *ctrl = [[AddressListViewController alloc] init];
  68. [self.navigationController pushViewController:ctrl animated:YES];
  69. }
  70. break;
  71. case SETTINGACTION_ONLINECHECK:
  72. {
  73. }
  74. break;
  75. case SETTINGACTION_PRIVACY:
  76. {
  77. KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
  78. webCtrl.url = [NSString stringWithFormat:@"%@%@",WEBHOST, @"/#/privacyProtocol"];
  79. [self.navigationController pushViewController:webCtrl animated:YES];
  80. }
  81. break;
  82. case SETTINGACTION_FEEEDBACK:
  83. {
  84. FeedbackViewController *ctrl = [[FeedbackViewController alloc] init];
  85. [self.navigationController pushViewController:ctrl animated:YES];
  86. }
  87. break;
  88. case SETTINGACTION_ABOUTUS:
  89. {
  90. AboutUsViewController *aboutUs = [[AboutUsViewController alloc] init];
  91. [self.navigationController pushViewController:aboutUs animated:YES];
  92. }
  93. break;
  94. case SETTINGACTION_LOGOUT:
  95. {
  96. [self logoutAction];
  97. }
  98. break;
  99. case SETTINGACTION_DELETEACCOUNT:
  100. {
  101. [self toDelteAccountView];
  102. }
  103. break;
  104. default:
  105. break;
  106. }
  107. }
  108. - (void)toDelteAccountView {
  109. AccountDeleteViewController *detailView = [[AccountDeleteViewController alloc] init];
  110. [self.navigationController pushViewController:detailView animated:YES];
  111. }
  112. - (void)logoutAction {
  113. [KSNetworkingManager logoutRequest:KS_GET success:^(NSDictionary * _Nonnull dic) {
  114. [self clearSource];
  115. } faliure:^(NSError * _Nonnull error) {
  116. [self clearSource];
  117. }];
  118. }
  119. - (void)clearUMCount {
  120. [USER_MANAGER sendUMEvent:@"klx_logout"];
  121. [USER_MANAGER stopCountUMEvent];
  122. }
  123. - (void)clearSource {
  124. [self clearUMCount];
  125. USER_MANAGER.hasShowFlash = NO;
  126. [RCConnectionManager shareManager].isNeedJoin = NO;
  127. [RCConnectionManager shareManager].isNeedShowMessage = NO;
  128. [[RCIM sharedRCIM] logout];
  129. [UIApplication sharedApplication].applicationIconBadgeNumber = 0;
  130. // 取消推送别名
  131. [JPUSHService deleteAlias:nil seq:0];
  132. [[NSUserDefaults standardUserDefaults] removeObjectForKey:TokenKey];
  133. [[NSUserDefaults standardUserDefaults] removeObjectForKey:Token_type];
  134. [[NSUserDefaults standardUserDefaults] removeObjectForKey:RefreshToken];
  135. [[NSUserDefaults standardUserDefaults] removeObjectForKey:RongTokenKey];
  136. [[NSUserDefaults standardUserDefaults] synchronize];
  137. [KSNetworkingManager clearRequestHeader];
  138. LoginViewController *loginVC = [[LoginViewController alloc] init];
  139. CustomNavViewController *navCtrl = [[CustomNavViewController alloc] initWithRootViewController:loginVC];
  140. AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
  141. appDelegate.window.rootViewController = navCtrl;
  142. }
  143. /*
  144. #pragma mark - Navigation
  145. // In a storyboard-based application, you will often want to do a little preparation before navigation
  146. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  147. // Get the new view controller using [segue destinationViewController].
  148. // Pass the selected object to the new view controller.
  149. }
  150. */
  151. @end