瀏覽代碼

自动登录

apple 6 年之前
父節點
當前提交
ede58943ec

二進制
ios/JianYuIOS/JianYuIOS.xcworkspace/xcuserdata/apple.xcuserdatad/UserInterfaceState.xcuserstate


+ 7 - 1
ios/JianYuIOS/JianYuIOS/AppDelegate.m

@@ -262,6 +262,13 @@ didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
             // 跳转到该链接
             [[NSNotificationCenter defaultCenter] postNotificationName:kRequestWebViewWithUrl object:temp userInfo:nil];
             
+            if(self.wakeUpBool) {
+                //刚启动
+                [[NSUserDefaults standardUserDefaults]setObject:temp forKey:@"NotiDict"];
+                self.wakeUpBool = NO;
+            }
+            
+            
              if([info[@"type"] isEqualToString:@"message"]) {
                  
                  [[LXDataBaseManager shareDataBaseManager] changeCatagoryTypeWithURL:info[@"url"]];
@@ -269,7 +276,6 @@ didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
                  NSDictionary * infoDic;
                  if(self.wakeUpBool) {
                      //刚启动
-                     [[NSUserDefaults standardUserDefaults]setObject:temp forKey:@"NotiDict"];
                      infoDic = @{@"url":info[@"url"],
                                  @"rectype":@"A",
                                  @"openid":info[@"openid"],

+ 12 - 0
ios/JianYuIOS/JianYuIOS/Classes(模块)/JYExpViewController.m

@@ -41,6 +41,9 @@ JSExportAs(business, -(NSInteger)jsBusiness:(NSInteger)shooID shopType:(NSIntege
 JSExportAs(hiddenBottom, -(void)jsHiddenBottom:(NSString*)hidden);
 
 
+JSExportAs(checkLab, -(void)jsCheckLab:(NSString*)str);
+
+
 @end
 
 
@@ -126,6 +129,10 @@ NSString *const AesKey_2 = @"mGlAgnIBB8bx2nch";
     
     NSString *current_url = [self.webView stringByEvaluatingJavaScriptFromString:@"document.location.href"];
     NSLog(@"当前页面:%@",current_url);
+    
+    if([current_url containsString:@"jyapp/free/login"]) {
+        return;
+    }
     //    NSString *current_url = self.webView.request.URL.absoluteString;
     if([current_url isEqualToString:[NSString stringWithFormat:@"%@jyapp/free/me",kHost]]||[current_url isEqualToString:[NSString stringWithFormat:@"%@jyapp/jylab/index",kHost]]||[current_url isEqualToString:[NSString stringWithFormat:@"%@jyapp/wxkeyset/keyset/index",kHost]]||[current_url isEqualToString:[NSString stringWithFormat:@"%@jyapp/jylab/mainSearch",kHost]]){
         return;
@@ -811,6 +818,11 @@ NSString *const AesKey_2 = @"mGlAgnIBB8bx2nch";
 
 
 
+-(void)jsCheckLab:(NSString*)str
+{
+    [[NSNotificationCenter defaultCenter] postNotificationName:@"refreshSS" object:nil userInfo:nil];
+}
+
 
 /*
  #pragma mark - Navigation

+ 4 - 0
ios/JianYuIOS/JianYuIOS/Classes(模块)/JYMineViewController.m

@@ -144,6 +144,10 @@ NSString *const AesKey_3 = @"mGlAgnIBB8bx2nch";
     
     NSString *current_url = [self.webView stringByEvaluatingJavaScriptFromString:@"document.location.href"];
     NSLog(@"当前页面:%@",current_url);
+    if([current_url containsString:@"jyapp/free/login"]) {
+        return;
+    }
+    
     //    NSString *current_url = self.webView.request.URL.absoluteString;
     if([current_url isEqualToString:[NSString stringWithFormat:@"%@jyapp/free/me",kHost]]||[current_url isEqualToString:[NSString stringWithFormat:@"%@jyapp/jylab/index",kHost]]||[current_url isEqualToString:[NSString stringWithFormat:@"%@jyapp/wxkeyset/keyset/index",kHost]]||[current_url isEqualToString:[NSString stringWithFormat:@"%@jyapp/jylab/mainSearch",kHost]]){
         return;

+ 40 - 0
ios/JianYuIOS/JianYuIOS/Classes(模块)/JYSearchViewController.m

@@ -67,6 +67,7 @@ JSExportAs(redirectKeyset, -(void)jsRedirectKeyset:(NSString*)str);
     NSInteger _timeTick;
     NSInteger _time;
     
+    BOOL autologin;
 }
 
 
@@ -138,6 +139,15 @@ NSString *const AesKey_0 = @"mGlAgnIBB8bx2nch";
         self.timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(timeFireMethod) userInfo:nil repeats:YES];
     }
     
+    
+    //新增刷新通知
+    
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(refreshSS:) name:@"refreshSS" object:nil];
+    
+   
+    
+    
+    
 }
 -(void)timeFireMethod{
     _timeTick++;
@@ -190,8 +200,18 @@ NSString *const AesKey_0 = @"mGlAgnIBB8bx2nch";
         return;
     }
     
+    
+    
+    
+    
     NSString *current_url = [self.webView stringByEvaluatingJavaScriptFromString:@"document.location.href"];
     NSLog(@"当前页面:%@",current_url);
+    
+    
+    if([current_url containsString:@"jyapp/free/login"]) {
+        return;
+    }
+    
     //    NSString *current_url = self.webView.request.URL.absoluteString;
     if([current_url isEqualToString:[NSString stringWithFormat:@"%@jyapp/free/me",kHost]]||[current_url isEqualToString:[NSString stringWithFormat:@"%@jyapp/jylab/index",kHost]]||[current_url isEqualToString:[NSString stringWithFormat:@"%@jyapp/wxkeyset/keyset/index",kHost]]||[current_url isEqualToString:[NSString stringWithFormat:@"%@jyapp/jylab/mainSearch",kHost]]){
         return;
@@ -544,6 +564,19 @@ NSString *const AesKey_0 = @"mGlAgnIBB8bx2nch";
     
     NSString *url = webView.request.URL.absoluteString;
     [self doSomeWithLoadUrl:url];
+    
+    
+    
+    
+    
+    //加载第一次成功的时候 调JS
+    if(!autologin&&[LXUserDefaults token]) {
+        autologin = YES;
+        NSString *textJS =  [NSString stringWithFormat:@"refAutoLogin('%@')",@"S"];
+        JSContext *context = [self.webView valueForKeyPath:@"documentView.webView.mainFrame.javaScriptContext"];
+        [context evaluateScript:textJS];
+    }
+    
 }
 
 //15737190152
@@ -1000,6 +1033,13 @@ NSString *const AesKey_0 = @"mGlAgnIBB8bx2nch";
     [self webViewFirstRequest];
 }
 
+
+//通知刷新页面
+-(void)refreshSS:(NSNotification *)notificaition{
+    [self webViewFirstRequest];
+}
+
+
 /*
 #pragma mark - Navigation
 

+ 4 - 0
ios/JianYuIOS/JianYuIOS/Classes(模块)/JYSubViewController.m

@@ -128,6 +128,10 @@ NSString *const AesKey_1 = @"mGlAgnIBB8bx2nch";
     
     NSString *current_url = [self.webView stringByEvaluatingJavaScriptFromString:@"document.location.href"];
     NSLog(@"当前页面:%@",current_url);
+    
+    if([current_url containsString:@"jyapp/free/login"]) {
+        return;
+    }
     //    NSString *current_url = self.webView.request.URL.absoluteString;
     if([current_url isEqualToString:[NSString stringWithFormat:@"%@jyapp/free/me",kHost]]||[current_url isEqualToString:[NSString stringWithFormat:@"%@jyapp/jylab/index",kHost]]||[current_url isEqualToString:[NSString stringWithFormat:@"%@jyapp/wxkeyset/keyset/index",kHost]]||[current_url isEqualToString:[NSString stringWithFormat:@"%@jyapp/jylab/mainSearch",kHost]]){
         return;

+ 9 - 4
ios/JianYuIOS/JianYuIOS/JYTabBarController.m

@@ -75,10 +75,15 @@
 //        return NO;
 //    }
     if (![LXUserDefaults token]) {
-        NSLog(@"没有token前往登录");
-        NSString *index = [NSString stringWithFormat:@"%ld",tabBarController.tabBar.selectedItem.tag];
-        [[NSNotificationCenter defaultCenter] postNotificationName:@"isLoginTabBar" object:nil userInfo:@{@"item_index":index}];
-        return NO;
+        
+        if(tabBarController.tabBar.selectedItem.tag!=0) {
+            NSLog(@"没有token前往登录");
+            NSString *index = [NSString stringWithFormat:@"%ld",tabBarController.tabBar.selectedItem.tag];
+            [[NSNotificationCenter defaultCenter] postNotificationName:@"isLoginTabBar" object:nil userInfo:@{@"item_index":index}];
+            return NO;
+        }else {
+            NSLog(@"没有token,当前在搜索页面");
+        }
     }
     return YES;