소스 검색

挤账号处理优化

Steven 8 달 전
부모
커밋
c0b3e9b902
18개의 변경된 파일88개의 추가작업 그리고 90개의 파일을 삭제
  1. 1 1
      KulexiuForStudent/KulexiuForStudent/AppDelegate.m
  2. 1 1
      KulexiuForStudent/KulexiuForStudent/Common/Base/KSNetworkingManager.h
  3. 11 13
      KulexiuForStudent/KulexiuForStudent/Common/Base/KSNetworkingManager.m
  4. 6 0
      KulexiuForStudent/KulexiuForStudent/Common/Base/LoadingManager/KSHudLoagingManager.m
  5. 2 2
      KulexiuForStudent/KulexiuForStudent/Common/Base/LoginManger/KSLoginManager.h
  6. 53 19
      KulexiuForStudent/KulexiuForStudent/Common/Base/LoginManger/KSLoginManager.m
  7. 4 4
      KulexiuForStudent/KulexiuForStudent/Common/Base/LoginManger/TXIMLinsenter.m
  8. 1 1
      KulexiuForStudent/KulexiuForStudent/Common/Base/WebView/KSBaseWKWebViewController.m
  9. 1 1
      KulexiuForStudent/KulexiuForStudent/InstitutionModule/Mine/Controller/INSSettingViewController.m
  10. 1 6
      KulexiuForStudent/KulexiuForStudent/Module/Chat/Search/KSSearchViewController.m
  11. 1 1
      KulexiuForStudent/KulexiuForStudent/Module/Login/Controller/InstrumentChooseViewController.m
  12. 0 35
      KulexiuForStudent/KulexiuForStudent/Module/Login/Model/UserInfoManager.m
  13. 1 1
      KulexiuForStudent/KulexiuForStudent/Module/Mine/Setting/Controller/ModifyPhoneChangeController.m
  14. 1 1
      KulexiuForStudent/KulexiuForStudent/Module/Mine/Setting/Controller/ModifyViewController.m
  15. 1 1
      KulexiuForStudent/KulexiuForStudent/Module/Mine/Setting/Controller/PasswordModify/NewPwdModifyViewController.m
  16. 1 1
      KulexiuForStudent/KulexiuForStudent/Module/Mine/Setting/Controller/SettingViewController.m
  17. 1 1
      KulexiuForStudent/KulexiuForStudent/Module/Mine/Setting/Controller/UserSettingViewController.m
  18. 1 1
      KulexiuForStudent/KulexiuForStudent/Module/Mine/Setting/DeleteAccount/Controller/AccountDeleteViewController.m

+ 1 - 1
KulexiuForStudent/KulexiuForStudent/AppDelegate.m

@@ -161,7 +161,7 @@
 }
 
 - (void)configRootVC {
-
+    [APPLOGIN_MANAGER configSetting];
     BOOL hasLaunchGuide = UserDefaultBoolForKey(FIRST_LOGIN_KEY);
     if (hasLaunchGuide == NO) {
         GuideViewController *guideVC = [[GuideViewController alloc] init];

+ 1 - 1
KulexiuForStudent/KulexiuForStudent/Common/Base/KSNetworkingManager.h

@@ -25,7 +25,7 @@ NS_ASSUME_NONNULL_BEGIN
 // 设置json提交方式
 + (void)configRequestMethodJSON;
 // 退出登录操作
-+ (void)logoutAction;
++ (void)logoutActionWithMsg:(NSString *)msg;
 
 // 取消所有请求操作
 + (void)cancelAllRequest;

+ 11 - 13
KulexiuForStudent/KulexiuForStudent/Common/Base/KSNetworkingManager.m

@@ -113,13 +113,13 @@
             NSLog(@"-------resonse -- %@", dic);
             if ([dic ks_integerValueForKey:@"code"] == 403) { // token验证失败
                 [self logOutWithType:YES];
-                [dic setValue:@"请重新登录" forKey:@"msg"];
+                [dic setValue:@"" forKey:@"msg"];
                 success(dic);
                 return;
             }
             else if ([dic ks_integerValueForKey:@"code"] == 401) {
                 [self logOutWithType:NO];
-                [dic setValue:@"请重新登录" forKey:@"msg"];
+                [dic setValue:@"" forKey:@"msg"];
                 success(dic);
                 return ;
             }
@@ -150,13 +150,13 @@
             NSLog(@"-------resonse -- %@", dic);
             if ([dic ks_integerValueForKey:@"code"] == 403) { // token验证失败
                 [self logOutWithType:YES];
-                [dic setValue:@"请重新登录" forKey:@"msg"];
+                [dic setValue:@"" forKey:@"msg"];
                 success(dic);
                 return;
             }
             else if ([dic ks_integerValueForKey:@"code"] == 401) {
                 [self logOutWithType:NO];
-                [dic setValue:@"请重新登录" forKey:@"msg"];
+                [dic setValue:@"" forKey:@"msg"];
                 success(dic);
                 return;
             }
@@ -178,21 +178,19 @@
 }
 
 + (void)logOutWithType:(BOOL)isDisable {
-    // 移除所有的loadView
-    [[VoNetworking sharedManager] cancleAllRequest];
-    [LOADING_MANAGER removeCustomLoading];
-    [LOADING_MANAGER removeHUD];
+    
+    NSString *tipsMessage = @"";
     if (isDisable) {
-        [LOADING_MANAGER MBShowAUTOHidingInWindow:@"登录过期,请重新登录"];
+        tipsMessage = @"登录过期,请重新登录";
     }
     else {
-        [LOADING_MANAGER MBShowAUTOHidingInWindow:@"未认证"];
+        tipsMessage = @"未认证";
     }
-    [self logoutAction];
+    [self logoutActionWithMsg:tipsMessage];
 }
 
-+ (void)logoutAction {
-    [APPLOGIN_MANAGER logoutAction];
++ (void)logoutActionWithMsg:(NSString *)msg {
+    [APPLOGIN_MANAGER logoutActionWithMsg:msg];
 }
 
 /// 移除所以当前请求

+ 6 - 0
KulexiuForStudent/KulexiuForStudent/Common/Base/LoadingManager/KSHudLoagingManager.m

@@ -99,10 +99,16 @@
 
 
 - (void)MBShowInWindow:(NSString *)str {
+    if ([NSString isEmptyString:str]) {
+        return;
+    }
     [self showHud:str inView:[NSObject getKeyWindow] autoHide:NO];
 }
 
 - (void)MBShowAUTOHidingInWindow:(NSString *)str {
+    if ([NSString isEmptyString:str]) {
+        return;
+    }
     [self showHud:str inView:[NSObject getKeyWindow] autoHide:YES];
 }
 

+ 2 - 2
KulexiuForStudent/KulexiuForStudent/Common/Base/LoginManger/KSLoginManager.h

@@ -16,9 +16,9 @@ NS_ASSUME_NONNULL_BEGIN
 
 + (instancetype)shareInstance;
 
-- (void)loginAction;
+- (void)configSetting;
 
-- (void)logoutAction;
+- (void)logoutActionWithMsg:(NSString *)msg;
 
 - (NSString *)getVisableControllerName;
 

+ 53 - 19
KulexiuForStudent/KulexiuForStudent/Common/Base/LoginManger/KSLoginManager.m

@@ -16,6 +16,12 @@
 
 #import "CoursewareDownloadManager.h"
 
+@interface KSLoginManager ()
+
+@property (nonatomic, assign) BOOL isQuitting; // 是否正在退出
+
+@end
+
 @implementation KSLoginManager
 
 + (instancetype)shareInstance {
@@ -35,17 +41,35 @@
     return self;
 }
 
+- (void)configSetting {
+    NSLog(@"------configSetting ");
+}
+
 - (void)otherLogin {
     dispatch_main_async_safe(^{
+        UIWindow *window = [NSObject getKeyWindow];
+        UIViewController *vc = [UIApplication sharedApplication].keyWindow.rootViewController;
         
+        if ([vc isKindOfClass:[UITabBarController class]]) {
+            UITabBarController *tab = (UITabBarController *)window.rootViewController;
+            CustomNavViewController *ctrl = (CustomNavViewController *)tab.selectedViewController;
+            if ([ctrl.visibleViewController isKindOfClass:NSClassFromString(@"TXClassroomViewController")]) {
+                [[NSNotificationCenter defaultCenter] postNotificationName:@"classroomLogout" object:nil];
+
+                return;
+            }
+            else if ([vc.presentedViewController isKindOfClass:NSClassFromString(@"CustomNavViewController")]) {
+                CustomNavViewController *nav = (CustomNavViewController *)vc.presentedViewController;
+                if ([nav.visibleViewController isKindOfClass:NSClassFromString(@"TXLiveRoomViewController")]) {
+                    [[NSNotificationCenter defaultCenter] postNotificationName:@"liveroomLogout" object:nil];
+                    return;
+                }
+            }
+            [APPLOGIN_MANAGER logoutActionWithMsg:@"登录过期,请重新登录"];
+        }
     });
 }
 
-- (void)loginAction {
-    
-}
-
-
 - (void)clearUMCount {
     [USER_MANAGER sendUMEvent:@"klx_logout"];
     [USER_MANAGER stopCountUMEvent];
@@ -57,12 +81,19 @@
     }
 }
 
-- (void)logoutAction {
-    [self closeDownload];
+- (void)logoutActionWithMsg:(NSString *)msg {
+    if (self.isQuitting) {
+        NSLog(@"----1");
+        return;
+    }
+    self.isQuitting = YES;
 
-    [[NSNotificationCenter defaultCenter] postNotificationName:@"refreshLiveClickStatus" object:nil];
+    [self closeDownload];
     [self clearUMCount];
+    
+    [KSNetworkingManager cancelAllRequest];
     [KSNetworkingManager clearRequestHeader];
+    [[NSNotificationCenter defaultCenter] postNotificationName:@"refreshLiveClickStatus" object:nil];
     
     // 取消推送别名
     [JPUSHService deleteAlias:nil seq:0];
@@ -87,37 +118,36 @@
         if (ctrl.presentedViewController) {
             UIViewController *presentCtrl = ctrl.presentedViewController;
             [presentCtrl dismissViewControllerAnimated:YES completion:^{
-                [ctrl popToRootViewControllerAnimated:YES];
-                [self resetToLoginViewController:tab];
+                [ctrl popToRootViewControllerAnimated:NO];
+                [self performSelector:@selector(resetToLoginViewController:) withObject:msg afterDelay:0.1];
             }];
         }
         else {
-            [ctrl popToRootViewControllerAnimated:YES];
-            [self resetToLoginViewController:tab];
+            [ctrl popToRootViewControllerAnimated:NO];
+            [self performSelector:@selector(resetToLoginViewController:) withObject:msg afterDelay:0.1];
         }
     }
     else if ([vc isKindOfClass:NSClassFromString(@"CustomNavViewController")]) {
-        // dismiss
         if (vc.presentedViewController) {
             UIViewController *presentCtrl = vc.presentedViewController;
             [presentCtrl dismissViewControllerAnimated:YES completion:^{
                 CustomNavViewController *ctrl = (CustomNavViewController *)vc;
-                [ctrl popToRootViewControllerAnimated:YES];
+                [ctrl popToRootViewControllerAnimated:NO];
+                self.isQuitting = NO;
             }];
         }
         else {
             CustomNavViewController *ctrl = (CustomNavViewController *)vc;
-            [ctrl popToRootViewControllerAnimated:YES];
+            [ctrl popToRootViewControllerAnimated:NO];
+            self.isQuitting = NO;
         }
     }
 }
 
-- (void)resetToLoginViewController:(UITabBarController *)tab {
+- (void)resetToLoginViewController:(NSString *)tipsMsg {
     LoginViewController *logonVC = [[LoginViewController alloc] init];
     CustomNavViewController *navCtrl = [[CustomNavViewController alloc] initWithRootViewController:logonVC];
-    navCtrl.modalPresentationStyle = UIModalPresentationFullScreen;
-    [tab.selectedViewController presentViewController:navCtrl animated:YES completion:nil];
-
+    [AppDelegate shareAppDelegate].window.rootViewController = navCtrl;
     // 切换到横屏
     AppDelegate* delegate = [AppDelegate shareAppDelegate];
     if (delegate.allowAutoRotate) {
@@ -127,6 +157,10 @@
         }
         [UIDevice switchNewOrientation:UIInterfaceOrientationPortrait inController:logonVC];
     }
+    if (![NSString isEmptyString:tipsMsg]) {
+        [LOADING_MANAGER MBShowAUTOHidingInWindow:tipsMsg];
+    }
+    self.isQuitting = NO;
 }
 
 - (NSString *)getVisableControllerName {

+ 4 - 4
KulexiuForStudent/KulexiuForStudent/Common/Base/LoginManger/TXIMLinsenter.m

@@ -120,11 +120,11 @@
 - (void)onKickedOffline {
     // 被踢下线
     NSLog(@"----- 被踢下线");
-#ifdef DEBUG
-
-#else
+//#ifdef DEBUG
+//
+//#else
     [[NSNotificationCenter defaultCenter] postNotificationName:@"otherLogin" object:nil];
-#endif
+//#endif
 }
 
 - (void)onUserSigExpired {

+ 1 - 1
KulexiuForStudent/KulexiuForStudent/Common/Base/WebView/KSBaseWKWebViewController.m

@@ -1111,7 +1111,7 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
     UserDefaultSetObjectForKey(webUrl, FAIL_WEB_URL);
     
     // 退出登录
-    [APPLOGIN_MANAGER logoutAction];
+    [APPLOGIN_MANAGER logoutActionWithMsg:@""];
 }
  
 #pragma mark ----- WKWebView delegate

+ 1 - 1
KulexiuForStudent/KulexiuForStudent/InstitutionModule/Mine/Controller/INSSettingViewController.m

@@ -310,7 +310,7 @@
 
 
 - (void)clearSource {
-    [APPLOGIN_MANAGER logoutAction];
+    [APPLOGIN_MANAGER logoutActionWithMsg:@""];
 }
 
 #pragma mark ----- lazying

+ 1 - 6
KulexiuForStudent/KulexiuForStudent/Module/Chat/Search/KSSearchViewController.m

@@ -39,13 +39,8 @@ static NSString *const HFId = @"HFId";
     _dataProvider.delegate = self;
     [self setupViews];
     [TUITool addUnsupportNotificationInVC:self];
-    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(otherLogin) name:@"otherLogin" object:nil];
-}
-- (void)otherLogin {
-    [self.navigationController dismissViewControllerAnimated:YES completion:^{
-        [APPLOGIN_MANAGER logoutAction];
-    }];
 }
+
 - (void)dealloc {
     NSLog(@"%s dealloc", __FUNCTION__);
     [[NSNotificationCenter defaultCenter] removeObserver:self];

+ 1 - 1
KulexiuForStudent/KulexiuForStudent/Module/Login/Controller/InstrumentChooseViewController.m

@@ -51,7 +51,7 @@
 
 - (void)logoutAction {
     [self backAction];
-    [APPLOGIN_MANAGER logoutAction];
+    [APPLOGIN_MANAGER logoutActionWithMsg:@""];
 }
 
 - (void)configUI {

+ 0 - 35
KulexiuForStudent/KulexiuForStudent/Module/Login/Model/UserInfoManager.m

@@ -36,7 +36,6 @@
 - (instancetype)init {
     if (self = [super init]) {
         self.userInfo = [[UserInfo alloc] init];
-        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(otherLogin) name:@"otherLogin" object:nil];
         [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(refreshLiveClickStatus) name:@"refreshLiveClickStatus" object:nil];
     }
     return self;
@@ -46,40 +45,6 @@
     [KSEnterLiveroomManager refreshClickStatus];
 }
 
-- (void)otherLogin {
-    dispatch_main_async_safe(^{
-        UIWindow *window = [NSObject getKeyWindow];
-        UIViewController *vc = [UIApplication sharedApplication].keyWindow.rootViewController;
-        
-        if ([vc isKindOfClass:[UITabBarController class]]) {
-            UITabBarController *tab = (UITabBarController *)window.rootViewController;
-            CustomNavViewController *ctrl = (CustomNavViewController *)tab.selectedViewController;
-            if ([ctrl.visibleViewController isKindOfClass:NSClassFromString(@"TXClassroomViewController")]) {
-                
-                [[NSNotificationCenter defaultCenter] postNotificationName:@"classroomLogout" object:nil];
-                return;
-            }
-            else if ([vc.presentedViewController isKindOfClass:NSClassFromString(@"CustomNavViewController")]) {
-                CustomNavViewController *nav = (CustomNavViewController *)vc.presentedViewController;
-                if ([nav.visibleViewController isKindOfClass:NSClassFromString(@"TXLiveRoomViewController")] || [nav.visibleViewController isKindOfClass:NSClassFromString(@"KSLiveWebViewController")]) {
-                    
-                    [[NSNotificationCenter defaultCenter] postNotificationName:@"liveroomLogout" object:nil];
-                    return;
-                }
-            }
-            [LOADING_MANAGER MBShowAUTOHidingInWindow:@"登录过期,请重新登录"];
-            [APPLOGIN_MANAGER logoutAction];
-        }
-    });
-}
-
-- (void)showTipsAlert {
-    [KSTipsAlert shareInstanceWithTitle:@"提示" descMessage:@"聊天功能已断开,是否重新连接?" leftTitle:@"取消" rightTitle:@"连接" callback:^(BOOL isSure) {
-        if (isSure) {
-            [self connectIM];
-        }
-    }];
-}
 
 // 获取信息回调
 - (void)queryUserInfoCallback:(UserInfoCallback)callback {

+ 1 - 1
KulexiuForStudent/KulexiuForStudent/Module/Mine/Setting/Controller/ModifyPhoneChangeController.m

@@ -91,7 +91,7 @@
 }
 
 - (void)successChangeBack {
-    [APPLOGIN_MANAGER logoutAction];
+    [APPLOGIN_MANAGER logoutActionWithMsg:@""];
 }
 
 

+ 1 - 1
KulexiuForStudent/KulexiuForStudent/Module/Mine/Setting/Controller/ModifyViewController.m

@@ -82,7 +82,7 @@
 
 // 重新登录
 - (void)toLoginView {
-    [APPLOGIN_MANAGER logoutAction];
+    [APPLOGIN_MANAGER logoutActionWithMsg:@""];
 }
 
 #pragma mark --- 验证码

+ 1 - 1
KulexiuForStudent/KulexiuForStudent/Module/Mine/Setting/Controller/PasswordModify/NewPwdModifyViewController.m

@@ -78,7 +78,7 @@
 }
 // 重新登录
 - (void)toLoginView {
-    [APPLOGIN_MANAGER logoutAction];
+    [APPLOGIN_MANAGER logoutActionWithMsg:@""];
 }
 
 #pragma mark --- 验证码

+ 1 - 1
KulexiuForStudent/KulexiuForStudent/Module/Mine/Setting/Controller/SettingViewController.m

@@ -176,7 +176,7 @@
 }
 
 - (void)clearSource {
-    [APPLOGIN_MANAGER logoutAction];
+    [APPLOGIN_MANAGER logoutActionWithMsg:@""];
 }
 /*
 #pragma mark - Navigation

+ 1 - 1
KulexiuForStudent/KulexiuForStudent/Module/Mine/Setting/Controller/UserSettingViewController.m

@@ -339,7 +339,7 @@
 }
 
 - (void)clearSource {
-    [APPLOGIN_MANAGER logoutAction];
+    [APPLOGIN_MANAGER logoutActionWithMsg:@""];
 }
 
 #pragma mark --- RSKImageCropViewControllerDelegate

+ 1 - 1
KulexiuForStudent/KulexiuForStudent/Module/Mine/Setting/DeleteAccount/Controller/AccountDeleteViewController.m

@@ -98,7 +98,7 @@
 
 - (void)successDeleteBack {
 
-    [APPLOGIN_MANAGER logoutAction];
+    [APPLOGIN_MANAGER logoutActionWithMsg:@""];
 }
 
 #pragma mark --- 验证码