浏览代码

【修改】修改登录逻辑

DESKTOP-VHLO35R\Administrator 1 年之前
父节点
当前提交
d687a8e9f1

+ 4 - 1
assets/edt_scene/scene_login.fire

@@ -538,7 +538,7 @@
538 538
         "__id__": 15
539 539
       }
540 540
     ],
541
-    "_active": false,
541
+    "_active": true,
542 542
     "_components": [
543 543
       {
544 544
         "__id__": 19
@@ -12811,6 +12811,9 @@
12811 12811
     "registerPanel": {
12812 12812
       "__id__": 303
12813 12813
     },
12814
+    "loadProgressBar": {
12815
+      "__id__": 22
12816
+    },
12814 12817
     "_id": "baZpNDkyFPF5yhy3+Dmeah"
12815 12818
   }
12816 12819
 ]

文件差异内容过多而无法显示
+ 4907 - 0
assets/edt_scene/scene_main.fire


+ 7 - 0
assets/edt_scene/scene_main.fire.meta

@@ -0,0 +1,7 @@
1
+{
2
+  "ver": "1.2.6",
3
+  "uuid": "626ef1a7-f2eb-46c9-8d97-955bc43f66f7",
4
+  "asyncLoadAssets": false,
5
+  "autoReleaseAssets": false,
6
+  "subMetas": {}
7
+}

+ 106 - 1
assets/script/app/ctrl/LoginCtr.js

@@ -26,6 +26,7 @@ cc.Class({
26 26
             default: undefined,
27 27
             type: RegisterPanel,
28 28
         },
29
+        loadProgressBar: JMLoadProgressBar,
29 30
     },
30 31
 
31 32
 
@@ -36,6 +37,14 @@ cc.Class({
36 37
         // 进行授权、登录、注册等操作
37 38
         this.initAuth();
38 39
         this.initUI();
40
+
41
+        cc.game.on('e_socket_on_logined', this._handleSocketOnLogined, this);
42
+        cc.game.on('e_socket_on_closed', this._handleSocketOnClosed, this);
43
+    },
44
+
45
+    onDestroy () {
46
+        cc.game.targetOff(this);
47
+        this._super();
39 48
     },
40 49
 
41 50
     initAuth () {
@@ -52,11 +61,107 @@ cc.Class({
52 61
         this.registerPanel.reloadData(()=> {
53 62
             this.showpanel(TagType.LOGIN);
54 63
         });
64
+
65
+        // 隐藏进度
66
+        this.showDownloadProgress(false);
67
+    },
68
+
69
+    /**
70
+     * 是否显示下载进度。不显示下载进度时,展示授权按钮
71
+     *
72
+     * @param {Boolean} isShow
73
+     */
74
+    showDownloadProgress (isShow) {
75
+        // 更新布局
76
+        this.loadProgressBar.node.active = isShow;
77
+
78
+        if (isShow) {
79
+            this.loadProgressBar.progressBar.progress = 0;
80
+            this.loadProgressBar.setProgress(15, 1);
81
+        }
55 82
     },
56 83
 
57 84
     showpanel (tagType) {
58 85
         this._tagType = tagType;
59 86
         this.loginPanel.node.active = tagType == TagType.LOGIN;
60 87
         this.registerPanel.node.active = tagType == TagType.REGISTER;
61
-    }
88
+    },
89
+
90
+    /**
91
+     * 登录成功
92
+     *
93
+     */
94
+    _handleSocketOnLogined () {
95
+        this.didLoginSuccessful();
96
+    },
97
+
98
+    /**
99
+     * 登录成功
100
+     *
101
+     */
102
+    _handleSocketOnClosed () {
103
+        this.didLoginFailed();
104
+    },
105
+
106
+    /**
107
+     * 登录成功
108
+     *
109
+     */
110
+    didLoginSuccessful () {
111
+        G.LogUtils.log('didLoginSuccessful');
112
+        this.enterMainScene();
113
+    },
114
+
115
+    /**
116
+     * 登录失败
117
+     *
118
+     */
119
+    didLoginFailed () {
120
+        G.LogUtils.log('didLoginFailed');
121
+    },
122
+
123
+    // 进入主界面
124
+    enterMainScene () {
125
+        // 避免反复进入
126
+        if (this._alreadyEnterScene)
127
+            return;
128
+
129
+        // 提前预加载大厅场景
130
+        if (!this.didLoadMainScene) {
131
+            this.preLoadMainScene();
132
+        }
133
+
134
+        this._alreadyEnterScene = true;
135
+        this.scheduleOnce(() => {
136
+            G.AppUtils.runScene('scene_main');
137
+        }, 0.1);
138
+
139
+        this.showDownloadProgress(true);
140
+        this.loadProgressBar.setProgress(0.1, 1);
141
+    },
142
+
143
+    // 预加载主界面
144
+    preLoadMainScene () {
145
+        // 加载中、或者加载成功时,不再加载
146
+        if (this.isPreLoading || this.didLoadHomeScene) {
147
+            return;
148
+        }
149
+        this.isPreLoading = true;
150
+
151
+        // 开始预加载资源
152
+        let temp = undefined;
153
+        cc.director.preloadScene('scene_main', (completedCount, totalCount, item)=>{
154
+            temp = G.AppUtils.getLoadProgressInfo(temp, completedCount, totalCount);
155
+            this.downloadPercent = Math.floor(temp.precent * 100);
156
+        }, (error, asset) => {
157
+            this.isPreLoading = false;
158
+            if (error) {
159
+                this.addToast('网络异常!场景加载失败');
160
+                return;
161
+            }
162
+
163
+            this.didLoadMainScene = true;
164
+            this.enterMainScene();
165
+        });
166
+    },
62 167
 });

+ 23 - 0
assets/script/app/ctrl/MainCtr.js

@@ -0,0 +1,23 @@
1
+const SceneCtrlBase = require('SceneCtrlBase');
2
+
3
+cc.Class({
4
+    extends: SceneCtrlBase,
5
+
6
+    editor: {
7
+        menu: 'Ctrl/MainCtrl'
8
+    },
9
+
10
+    properties: {
11
+    
12
+    },
13
+
14
+
15
+    onLoad () {
16
+        this._super();
17
+        this.initUI();
18
+    },
19
+
20
+    initUI() {
21
+
22
+    }
23
+});

+ 9 - 0
assets/script/app/ctrl/MainCtr.js.meta

@@ -0,0 +1,9 @@
1
+{
2
+  "ver": "1.0.8",
3
+  "uuid": "7b41b503-059c-484a-8613-6d9a6b742fed",
4
+  "isPlugin": false,
5
+  "loadPluginInWeb": true,
6
+  "loadPluginInNative": true,
7
+  "loadPluginInEditor": false,
8
+  "subMetas": {}
9
+}

+ 3 - 3
assets/script/app/model/PublicMgr.js

@@ -24,9 +24,9 @@ let PublicMgr = {
24 24
         this.initEventListeners();
25 25
 
26 26
         // 玩家系统信息 20100
27
-        cc.game.on('on_h5user_system_info', this._onPublishUserSystemInfo, this);
27
+        cc.game.on('on_user_system_info', this._onPublishUserSystemInfo, this);
28 28
         // 更新玩家信息 20101
29
-        cc.game.on('on_h5user_info', this._onPublishUserInfo, this);
29
+        // cc.game.on('on_h5user_info', this._onPublishUserInfo, this);
30 30
     },
31 31
 
32 32
     /**
@@ -207,7 +207,7 @@ let PublicMgr = {
207 207
 
208 208
     // 玩家推送信息处理
209 209
     _onUserInfo (data) {
210
-        G.UserMgr.setUserSystemInfo(data);
210
+        // G.UserMgr.setUserSystemInfo(data);
211 211
 
212 212
         // 发送用户信息更新
213 213
         // 通知UI刷新

+ 7 - 6
assets/script/core/model/user/UserMgr.js

@@ -71,13 +71,14 @@ let UserMgr = {
71 71
             this._baseInfo = responseInfo.baseInfo;
72 72
 
73 73
             // 登录完成判断
74
-            G.PublicMgr.isDoneUserSelfInfo = true;
75
-            if (G.PublicMgr.isDoneSystemInfo) {
76
-                G.PublicMgr.isDoneUserSelfInfo = false;
77
-                G.PublicMgr.isDoneSystemInfo = false;
74
+            // G.PublicMgr.isDoneUserSelfInfo = true;
75
+            // if (G.PublicMgr.isDoneSystemInfo) {
76
+            //     G.PublicMgr.isDoneUserSelfInfo = false;
77
+            //     G.PublicMgr.isDoneSystemInfo = false;
78 78
 
79
-                G.PublicMgr.emit(JMC.PUBLIC_MSG.LOGIN_SUCCESS);
80
-            }
79
+            //     G.PublicMgr.emit(JMC.PUBLIC_MSG.LOGIN_SUCCESS);
80
+            // }
81
+            G.PublicMgr.emit(JMC.PUBLIC_MSG.LOGIN_SUCCESS);
81 82
         } else {
82 83
             // 断开网络并且弹出重连窗口
83 84
             G.NetworkMgr.closeSocket();