Ver Fonte

更新登录流程

zouyong há 5 anos atrás
pai
commit
739b4797f1

+ 8 - 5
assets/script/game/data/AppData.ts

@@ -4,6 +4,8 @@
  */
 export class AppData {
 
+    public getDeviceInfoCompelete: boolean = false;
+
     /** 错误日志游戏名标志,尽量短 */
     public appNameBugly: string = '3xiao';
 
@@ -21,15 +23,15 @@ export class AppData {
     public appId: string = 'wxcf31f0e54f7fefda';
 
     /** 友盟渠道 */
-    public umengChannel:string = '';
+    public umengChannel: string = '';
 
     /** 设备型号 */
-    public deviceType:string = '';
+    public deviceType: string = '';
 
     /** 安卓版本号 */
-    public androidVersion:string = '';
+    public androidVersion: string = '';
 
-    public mac: string = 'c9:05:e2:1c:b2:23,f6:60:e4:1a:b7:27';
+    public mac: string = 'c9:24:e2:1c:b2:23,f6:60:e4:1a:b7:27';
 
     /** 设备信息 */
     public machineInfo = {
@@ -48,7 +50,6 @@ export class AppData {
      * @param info  info(Java返回)
      */
     public updateDeviceInfo(info) {
-        mk.console.logSingle("updateDeviceInfo",info)
         let arr = info.split('#')
         this.machineInfo.android_id = arr[0];
         this.machineInfo.idfa = arr[1];
@@ -65,6 +66,8 @@ export class AppData {
         this.deviceType = arr[9];
         /** 安卓版本号 */
         this.androidVersion = arr[10];
+
+        this.getDeviceInfoCompelete = true;
     }
 
     public init() {

+ 9 - 11
assets/script/game/data/GameData.ts

@@ -54,27 +54,25 @@ export class GameData {
         this.initConfigs(response.data);
 
         data = {};
-        response = await mk.http.sendData('user/adShowConfig', data);
-        if (response.errcode != 0) {
-            return;
-        }
-        this.adShowConfig = response.data;
-        mk.console.logSingle("user/adShowConfig", response.data);
-
-        data = {};
         response = await mk.http.sendData('getInfoCrypt', data);
         if (response.errcode != 0) {
             return;
         }
         mk.console.logSingle("getInfoCrypt", response.data);
         this.initPlayerProp(response.data)
-
-
         this.initProps(response.data.gameUserData);
-
         gData.moduleData.forEach(element => {
             element.init();
         });
+
+        data = {};
+        response = await mk.http.sendData('user/adShowConfig', data);
+        if (response.errcode != 0) {
+            return;
+        }
+        this.adShowConfig = response.data;
+        mk.console.logSingle("user/adShowConfig", response.data);
+
         this.dataFinish = true;
     }
 

+ 4 - 3
assets/script/game/data/LoginData.ts

@@ -1,3 +1,4 @@
+import JsbSystem from "../../mk/system/JsbSystem";
 import { StorageKey } from "./StorageData";
 
 /**
@@ -6,7 +7,7 @@ import { StorageKey } from "./StorageData";
  */
 export class LoginData {
 
-    public loadResCompelete: boolean = false;
+    public loadResCompelete: boolean = false;   
 
     /** 是否登录 */
     public isLogin: boolean = false;
@@ -45,13 +46,13 @@ export class LoginData {
             this.privacy_data = result.json.privacy;
             this.loadResCompelete = true;
         }
+        JsbSystem.getDeviceInfo();
     }
 
     /**
      * 登录流程 initApp-->initAd-->connect-->wxLogin-->checkLogin-->getAccountInfo
      */
     public async login() {
-        this.isLogin = true;
         mk.pool.init(gData.gameData.pools);
         gData.appData.init();
         gData.adData.init();
@@ -95,7 +96,7 @@ export class LoginData {
             };
         }
         else {//游客登录
-            encode = mk.encrypt.encrypt(JSON.stringify({ "code": gData.wechatData.code }), ranKey, gData.appData.appId);
+            encode = mk.encrypt.encrypt(JSON.stringify({ "code": '' }), ranKey, gData.appData.appId);
             data = {
                 "uin": this.tempUin,
                 "encrypt": encode

+ 3 - 1
assets/script/game/module/login/Login.ts

@@ -1,3 +1,4 @@
+
 import LoadingBar from "../../component/LoadingBar";
 
 const { ccclass, property } = cc._decorator;
@@ -36,8 +37,9 @@ export default class Login extends cc.Component {
             gData.loginData.loadLocalRes();
             return;
         }
-        if (!gData.loginData.isLogin) {
+        if (gData.appData.getDeviceInfoCompelete) {
             gData.loginData.login();
+            gData.appData.getDeviceInfoCompelete = false;
             return;
         }
         if (gData.gameData.dataFinish) {//登录流程完毕

+ 6 - 1
assets/script/mk/system/JsbSystem.ts

@@ -6,7 +6,7 @@
 export default class JsbSystem {
 
     /**代码桥在AS中的路径 */
-    private static _JSB_ANDROID_PATH: string = "org/cocos2dx/javascript/thridSdk/ThirdSdkMgr";
+    private static _JSB_ANDROID_PATH: string = "org/cocos2dx/javascript/thirdSdk/ThirdSdkMgr";
     /**代码桥在IOS中的路径 */
     private static _JSB_IOS_PATH: string = "ThirdSdkMgr";
 
@@ -58,6 +58,7 @@ export default class JsbSystem {
      * @param info  info(Java返回)
      */
     public static updateDeviceInfo(info) {
+        mk.console.log("updateDeviceInfo" + cc.sys.os, info)
         if (cc.sys.os == cc.sys.OS_ANDROID) {
             gData.appData.updateDeviceInfo(info);
         }
@@ -71,12 +72,16 @@ export default class JsbSystem {
      * @description 自定义功能 CocosToJava
      */
     public static getDeviceInfo() {
+        mk.console.log("getDeviceInfo", cc.sys.os)
         if (cc.sys.os == cc.sys.OS_ANDROID) {
             this.callStaticMethod(this._JSB_ANDROID_PATH, "getDeviceInfo", "()V");
         }
         else if (cc.sys.os == cc.sys.OS_IOS) {
             this.callStaticMethod(this._JSB_IOS_PATH, "getDeviceInfo", "");
         }
+        else {
+            gData.appData.getDeviceInfoCompelete = true;
+        }
     }
 
     /**