Explorar o código

修复登录不了的问题

hwt %!s(int64=6) %!d(string=hai) anos
pai
achega
f901c94bb1
Modificáronse 2 ficheiros con 25 adicións e 21 borrados
  1. 24 20
      assets/scripts/LoginCtrl.js
  2. 1 1
      assets/scripts/net/Api.js

+ 24 - 20
assets/scripts/LoginCtrl.js

@@ -48,7 +48,7 @@ cc.Class({
                 this.preloadRes = true
                 // 正在加载图片资源中...
                 this.preloadProgress.progress = completeCount / totalCount;
-                if(this.preloadProgress.progress) {
+                if (this.preloadProgress.progress) {
                     this.preloadLabel.string = (this.preloadProgress.progress * 100).toFixed(0) + '%';
                 }
 
@@ -58,7 +58,7 @@ cc.Class({
                 // 加载完成, 开始进入游戏
                 this.endPreload();
 
-                if(CC_WECHATGAME) {
+                if (CC_WECHATGAME) {
                     this._startWxLogin();
                 } else {
                     Global.user = {
@@ -68,7 +68,7 @@ cc.Class({
                         avatar: "",
                         gender: 1
                     }
-        
+
                     this._getUserInfoAndStartGame();
                 }
             });
@@ -86,7 +86,7 @@ cc.Class({
                 dis = dis < 0.002 ? 0.002 : dis - 0.0001;
                 this.preloadProgress.progress += dis;
             }
-            if(!this.preloadRes) {
+            if (!this.preloadRes) {
                 this.preloadLabel.string = (this.preloadProgress.progress * 100).toFixed(0) + '%'
             }
         }
@@ -100,7 +100,7 @@ cc.Class({
     endPreload() {
         this.preloadProgress.progress = 1;
     },
-    
+
     _startWxLogin() {
         this.loginLabel.node.active = false
         this.updateUI.active = false;
@@ -129,22 +129,26 @@ cc.Class({
     },
 
     _getUserInfoAndStartGame() {
-        LoginApi.getUserInfoPromise().then(({ data, msg }) => {
-            Global.needLogin = false;
-            Global.userData = data
-            Global.devCityId = data.cityId;
-            
-            // 获取存在服务端的用户guideState
-            Api.httpGet({
-                url: "/direct/me.do",
-                data: {},
-                success: res => {
-                    if(res) {
-                        window.guideState = JSON.parse(res)
+        LoginApi.getUserInfoPromise().then(({ code, data }) => {
+            if (code == 0) {
+                Global.needLogin = false;
+                Global.userData = data
+                Global.devCityId = data.cityId;
+
+                // 获取存在服务端的用户guideState
+                Api.httpGet({
+                    url: "/direct/me.do",
+                    data: {},
+                    success: res => {
+                        if (res) {
+                            window.guideState = JSON.parse(res)
+                        }
+                        cc.director.loadScene("game");
                     }
-                    cc.director.loadScene("game");
-                }
-            })
+                })
+            } else {
+                console.log(data.msg);
+            }
         }).catch(({ code, msg }) => {
             if (msg) {
                 console.log(msg);

+ 1 - 1
assets/scripts/net/Api.js

@@ -236,7 +236,7 @@ class Api {
                     if (res.data.code === ResponseStateCode.LOGIN_INVALIDATE) {
                         Global.needLogin = true;
                         cc.director.loadScene('login');
-                        // reject(res.data);
+                        reject(res.data);
                     }
                     resolve(res.data);
                     // if (res.data.code === ResponseStateCode.OK) {