dzduole 16 horas atrás
pai
commit
fe3752a499

+ 11 - 10
art/fgui/.objs/workspace.json

@@ -7,29 +7,30 @@
     "/"
   ],
   "libview.iconScale": 0,
-  "doc.openedDocs": [
-    "ui://isxx5ak7uel8v58m",
-    "ui://isxx5ak7uqohv4lr",
-    "ui://isxx5ak7g1giv4el"
-  ],
+  "doc.openedDocs": [],
   "test.device": "Huawei Mate20 Pro",
   "canvasColor": 10066329,
   "auxline2": true,
-  "doc.activeDoc": "ui://isxx5ak7uel8v58m",
   "libview.twoColumn": false,
   "libview.expandedNodes": [
     "isxx5ak7",
     "/",
     "isxx5ak7",
+    "/UIMain/",
+    "isxx5ak7",
+    "/UIMain/component/",
+    "isxx5ak7",
     "/UISecretary/",
     "isxx5ak7",
-    "/UISecretary/UIShop/",
+    "/UISecretary/UIFuli/",
+    "isxx5ak7",
+    "/UISecretary/UIFuli/asset/",
     "isxx5ak7",
-    "/UISecretary/UIShop/component/",
+    "/UISecretary/UIFuli/component/",
     "isxx5ak7",
-    "/_exportasset/",
+    "/UISecretary/UIShop/",
     "isxx5ak7",
-    "/_exportasset/daoju/"
+    "/UIUser/"
   ],
   "auxline1": true,
   "snapToGrid": true,

+ 127 - 16
client/laya/bin/js/bundle.js

@@ -879,12 +879,12 @@
             return reqData;
         }
         sendPost2025(reqUrl, data, call) {
-            let isDev = true;
+            let isDev = false;
             let urlTop = "https://api.kessongame.site/";
-            let urlMid = urlTop + "prod-api/api/game/";
+            let urlMid = urlTop + "prod-api/api/";
             if (isDev) {
                 urlTop = "http://192.168.1.13:8090/";
-                urlMid = urlTop + "api/game/";
+                urlMid = urlTop + "api/";
             }
             let url = urlMid + reqUrl;
             if (reqUrl == "registerForApp" || reqUrl == "loginForApp") {
@@ -895,11 +895,28 @@
                     url = urlTop + "prod-api/" + reqUrl;
                 }
             }
+            let headers = ["Content-Type", "application/json; charset=UTF-8"];
+            if (reqUrl.indexOf("/api/game/") >= 0) {
+            }
+            const keyForLoginInfo = "userInfo";
+            const userInfoData = Laya.LocalStorage.getItem(keyForLoginInfo);
+            if (userInfoData != null) {
+                try {
+                    let bb = JSON.parse(userInfoData);
+                    if (bb) {
+                        let token = bb.token;
+                        headers.push("Authorization");
+                        headers.push(`Bearer ${token}`);
+                    }
+                }
+                catch (e) {
+                }
+            }
             let httpObj = new Laya.HttpRequest();
             httpObj.http.timeout = 5000;
             httpObj.once(Laya.Event.COMPLETE, this, completeHandler);
             httpObj.once(Laya.Event.ERROR, this, errorHandler);
-            httpObj.send(url, data, 'post', 'text', ["Content-Type", "application/json; charset=UTF-8"]);
+            httpObj.send(url, data, 'post', 'text', headers);
             function errorHandler(error) {
                 if (call) {
                     call("{'msg':'Network exception','code':500}");
@@ -5924,7 +5941,7 @@
             let pd = JSON.parse(reqData);
             pd.splx = "Consumable";
             reqData = JSON.stringify(pd);
-            xGame.httpMgr.sendPost2025('getProductList', reqData, (res) => {
+            xGame.httpMgr.sendPost2025('game2/getProductList', reqData, (res) => {
                 try {
                     let code = res.code;
                     let msg = res.msg;
@@ -7553,7 +7570,24 @@
                 xGame.uiMgr.Show(UIMsg, "Network not ready. Try again later.");
                 console.log('zh:✅❌  5秒后重新尝试加载网络资源');
                 Laya.timer.once(5000, this, () => {
-                    xGame.cfgMgr.getConfigFromServer();
+                    let retryCount = 0;
+                    const maxRetries = 3;
+                    const tryFetchConfig = () => {
+                        try {
+                            xGame.cfgMgr.getConfigFromServer();
+                        }
+                        catch (error) {
+                            if (retryCount < maxRetries) {
+                                retryCount++;
+                                console.log(`🔄 第${retryCount}次重试获取配置...`);
+                                Laya.timer.once(5000, this, tryFetchConfig);
+                            }
+                            else {
+                                console.error("❌ 达到最大重试次数,配置获取失败");
+                            }
+                        }
+                    };
+                    tryFetchConfig();
                 });
                 return false;
             }
@@ -17649,28 +17683,44 @@
                     this.httpReqOkCount = 0;
                     let reqData = xGame.httpMgr.getReqData();
                     console.log('zh:第1个请求getClassicCfg');
-                    const classicCfg = yield this.sendPostAsync('getClassicCfg', reqData);
+                    const classicCfg = yield this.sendPostAsync('game2/getClassicCfg', reqData);
                     this.classicCfg = classicCfg;
                     this.httpReqOkCount++;
                     console.log('zh:第2个请求getLevelCfg');
-                    const levelCfg = yield this.sendPostAsync('getLevelCfg', reqData);
+                    const levelCfg = yield this.sendPostAsync('game2/getLevelCfg', reqData);
                     this.levelCfg = levelCfg;
                     this.httpReqOkCount++;
                     console.log('zh:第3个请求 getPlaceBallCfg');
-                    const placeBallCfg = yield this.sendPostAsync('getPlaceBallCfg', reqData);
+                    const placeBallCfg = yield this.sendPostAsync('game2/getPlaceBallCfg', reqData);
                     this.placeBallCfg = placeBallCfg;
                     this.httpReqOkCount++;
                     console.log('zh:第4个请求  npc');
-                    const npc = yield this.sendPostAsync('getNpc', reqData);
+                    const npc = yield this.sendPostAsync('game2/getNpc', reqData);
                     this.npcJson = npc.Data;
                     this.httpReqOkCount++;
                     console.log('zh:所有配置加载完成');
                 }
                 catch (error) {
                     console.error('❌请求失败:', error);
-                    Laya.timer.once(500, this, () => {
-                        console.log('zh:✅重新尝试加载网络资源');
-                        xGame.cfgMgr.getConfigFromServer();
+                    Laya.timer.once(5000, this, () => {
+                        let retryCount = 0;
+                        const maxRetries = 3;
+                        const tryFetchConfig = () => {
+                            try {
+                                xGame.cfgMgr.getConfigFromServer();
+                            }
+                            catch (error) {
+                                if (retryCount < maxRetries) {
+                                    retryCount++;
+                                    console.log(`🔄 第${retryCount}次重试获取配置...`);
+                                    Laya.timer.once(5000, this, tryFetchConfig);
+                                }
+                                else {
+                                    console.error("❌ 达到最大重试次数,配置获取失败");
+                                }
+                            }
+                        };
+                        tryFetchConfig();
                     });
                 }
                 finally {
@@ -17723,7 +17773,7 @@
         }
         test() {
             let reqData = xGame.httpMgr.getReqData();
-            xGame.httpMgr.sendPost2025('getClassicCfg', reqData, (res) => {
+            xGame.httpMgr.sendPost2025('game2/getClassicCfg', reqData, (res) => {
                 console.log('zh:1s');
                 try {
                     let code = res.code;
@@ -18225,6 +18275,7 @@
             this.userData.coin += val;
             this.saveUserData();
             xGame.eventMgr.event(COIN_CHANGE);
+            this.updateUserInfo2Server("jb");
         }
         static getCoin() {
             return this.userData.coin;
@@ -18243,6 +18294,7 @@
             this.userData.diamond += val;
             this.saveUserData();
             xGame.eventMgr.event(DIAMOND_CHANGE);
+            this.updateUserInfo2Server("zs");
         }
         static getDiamond() {
             return this.userData.diamond;
@@ -18516,6 +18568,48 @@
             this.diyGameData.challengeMode_overLev = levNum;
             this.saveDiyGameData();
         }
+        static updateUserInfo2Server(type, count = 0) {
+            const keyForLoginInfo = "userInfo";
+            const userInfoData = Laya.LocalStorage.getItem(keyForLoginInfo);
+            if (userInfoData == null) {
+                return;
+            }
+            let reqData = xGame.httpMgr.getReqData();
+            let rd = JSON.parse(reqData);
+            rd.dataType = type;
+            let dataValue = 0;
+            if (type == "zs") {
+                dataValue = this.getDiamond();
+            }
+            if (type == "jb") {
+                dataValue = this.getCoin();
+            }
+            rd.dataValue = dataValue;
+            reqData = JSON.stringify(rd);
+            xGame.httpMgr.sendPost2025('user/update', reqData, (res) => {
+                try {
+                    let code = res.code;
+                    let data = res.data;
+                    if (code == 401) {
+                        Laya.LocalStorage.setItem(keyForLoginInfo, null);
+                        alert('Please log in.');
+                        return;
+                    }
+                    if (code == 200) {
+                        console.log('zh:更新账号资产OK' + JSON.stringify(res));
+                    }
+                    else {
+                        console.log('zh:更新账号资产fa' + JSON.stringify(res));
+                    }
+                }
+                catch (error) {
+                    console.log('error=' + error);
+                    alert("Please check your network connection.");
+                }
+                finally {
+                }
+            });
+        }
     }
     DataMgr.isNewUser = false;
     DataMgr.fristEnter = true;
@@ -22623,7 +22717,7 @@
             let pd = JSON.parse(reqData);
             pd.splx = "Consumable";
             reqData = JSON.stringify(pd);
-            xGame.httpMgr.sendPost2025('getProductList', reqData, (res) => {
+            xGame.httpMgr.sendPost2025('game2/getProductList', reqData, (res) => {
                 try {
                     let code = res.code;
                     let msg = res.msg;
@@ -23946,7 +24040,24 @@
                 xGame.uiMgr.Show(UIMsg$1, "Network not ready. Try again later.");
                 console.log('zh:✅❌  5秒后重新尝试加载网络资源');
                 Laya.timer.once(5000, this, () => {
-                    xGame.cfgMgr.getConfigFromServer();
+                    let retryCount = 0;
+                    const maxRetries = 3;
+                    const tryFetchConfig = () => {
+                        try {
+                            xGame.cfgMgr.getConfigFromServer();
+                        }
+                        catch (error) {
+                            if (retryCount < maxRetries) {
+                                retryCount++;
+                                console.log(`🔄 第${retryCount}次重试获取配置...`);
+                                Laya.timer.once(5000, this, tryFetchConfig);
+                            }
+                            else {
+                                console.error("❌ 达到最大重试次数,配置获取失败");
+                            }
+                        }
+                    };
+                    tryFetchConfig();
                 });
                 return false;
             }

Diferenças do arquivo suprimidas por serem muito extensas
+ 0 - 0
client/laya/bin/js/bundle.js.map


+ 25 - 8
client/laya/src/core/mgrs/ConfigMgr.ts

@@ -40,32 +40,49 @@ export class ConfigMgr {
             this.httpReqOkCount = 0;
             let reqData = xGame.httpMgr.getReqData();
             console.log('zh:第1个请求getClassicCfg');
-            const classicCfg = await this.sendPostAsync('getClassicCfg', reqData);
+            const classicCfg = await this.sendPostAsync('game2/getClassicCfg', reqData);
             this.classicCfg = classicCfg;
             this.httpReqOkCount++;
 
             console.log('zh:第2个请求getLevelCfg');
-            const levelCfg = await this.sendPostAsync('getLevelCfg', reqData);
+            const levelCfg = await this.sendPostAsync('game2/getLevelCfg', reqData);
             this.levelCfg = levelCfg;
             this.httpReqOkCount++;
 
             console.log('zh:第3个请求 getPlaceBallCfg');
-            const placeBallCfg = await this.sendPostAsync('getPlaceBallCfg', reqData);
+            const placeBallCfg = await this.sendPostAsync('game2/getPlaceBallCfg', reqData);
             this.placeBallCfg = placeBallCfg;
             this.httpReqOkCount++;
 
             console.log('zh:第4个请求  npc');
-            const npc = await this.sendPostAsync('getNpc', reqData);
+            const npc = await this.sendPostAsync('game2/getNpc', reqData);
             this.npcJson = npc.Data;
             this.httpReqOkCount++;
 
             console.log('zh:所有配置加载完成');
         } catch (error) {
             console.error('❌请求失败:', error);
-            Laya.timer.once(500, this, () => {
-                console.log('zh:✅重新尝试加载网络资源');
-                xGame.cfgMgr.getConfigFromServer();
+
+            Laya.timer.once(5000, this, () => {
+                let retryCount = 0;
+                const maxRetries = 3;
+                const tryFetchConfig = () => {
+                    try {
+                        xGame.cfgMgr.getConfigFromServer();
+                    } catch (error) {
+                        if (retryCount < maxRetries) {
+                            retryCount++;
+                            console.log(`🔄 第${retryCount}次重试获取配置...`);
+                            Laya.timer.once(5000, this, tryFetchConfig);
+                        } else {
+                            console.error("❌ 达到最大重试次数,配置获取失败");
+                        }
+                    }
+                };
+                tryFetchConfig();
             });
+
+
         } finally {
             if (this.httpReqCount > this.httpReqOkCount) {
                 CustomAlert.show("Prompt", "Failed to load resources. Check your network and restart the game.", [
@@ -89,7 +106,7 @@ export class ConfigMgr {
 
     private test() {
         let reqData = xGame.httpMgr.getReqData();
-        xGame.httpMgr.sendPost2025('getClassicCfg', reqData, (res) => {
+        xGame.httpMgr.sendPost2025('game2/getClassicCfg', reqData, (res) => {
             console.log('zh:1s')
             try {
                 let code = res.code;

+ 41 - 5
client/laya/src/core/mgrs/HttpMgr.ts

@@ -6,6 +6,8 @@
 * 备注:
 ***********************************************************************************
 */
+//import { LocalStorageManager } from "../../utils/LocalStorageManager";
+
 export class HttpMgr {
     // 单例对象
     private static _instance: HttpMgr = null;
@@ -61,14 +63,14 @@ export class HttpMgr {
      * post请求,参数待扩展
      */
     public sendPost2025(reqUrl, data, call) {
-        let isDev = true;//是否是开发环境
+        let isDev = false;//是否是开发环境
         // let urlStr ="https://api.kessongame.site/prod-api/api/game/";
         //////////////https://api.kessongame.site/prod-api/api/game/getClassicCfg
         let urlTop = "https://api.kessongame.site/";
-        let urlMid = urlTop + "prod-api/api/game/";
+        let urlMid = urlTop + "prod-api/api/";
         if (isDev) {
             urlTop = "http://192.168.1.13:8090/";
-            urlMid = urlTop + "api/game/";
+            urlMid = urlTop + "api/";
         }
         let url = urlMid + reqUrl;
         if (reqUrl == "registerForApp" || reqUrl == "loginForApp") {
@@ -78,11 +80,35 @@ export class HttpMgr {
                 url = urlTop + "prod-api/" + reqUrl;
             }
         }
+
+        let headers = ["Content-Type", "application/json; charset=UTF-8"];
+
+        //---------------
+        if(reqUrl.indexOf("/api/game/") >= 0){//这里不需要鉴权
+
+        }
+        const keyForLoginInfo = "userInfo";
+        const userInfoData = Laya.LocalStorage.getItem(keyForLoginInfo);
+        if (userInfoData != null) {
+            try {
+                let bb = JSON.parse(userInfoData);
+                if (bb) {
+                    let token = bb.token;
+                    headers.push("Authorization");
+                    headers.push(`Bearer ${token}`);
+                }
+                //  const token = LocalStorageManager.getItem<{ username: string, token: string }>(keyForLoginInfo)?.token;
+            } catch (e) {
+
+            }
+        }
+        //---------------
         let httpObj = new Laya.HttpRequest();
-        httpObj.http.timeout = 5000;//设置超时时间;
+        httpObj.http.timeout = 5000;
         httpObj.once(Laya.Event.COMPLETE, this, completeHandler);
         httpObj.once(Laya.Event.ERROR, this, errorHandler);
-        httpObj.send(url, data, 'post', 'text', ["Content-Type", "application/json; charset=UTF-8"]);
+        // httpObj.send(url, data, 'post', 'text', ["Content-Type", "application/json; charset=UTF-8"]);
+        httpObj.send(url, data, 'post', 'text', headers);
         function errorHandler(error): void {
             if (call) {
                 call("{'msg':'Network exception','code':500}");//固定
@@ -99,6 +125,16 @@ export class HttpMgr {
         }
     }
 
+    // getHeadInfo() {
+    //     let headers = ["Content-Type", "application/json; charset=UTF-8"];
+    //     const keyForLoginInfo = "loginInfo"; 
+    //     const token = LocalStorageManager.getItem<{ username: string, token: string }>(keyForLoginInfo)?.token;
+    //     if (token) {
+    //         headers.push("Authorization");
+    //         headers.push(`Bearer ${token}`);
+    //     }
+    //     return headers;
+    // }
 
 
     public sendGet(url, call) {

+ 56 - 0
client/laya/src/data/DataMgr.ts

@@ -298,6 +298,7 @@ export default class DataMgr {
         this.userData.coin += val;
         this.saveUserData();
         xGame.eventMgr.event(COIN_CHANGE);
+        this.updateUserInfo2Server("jb");
     }
     public static getCoin() {
         return this.userData.coin;
@@ -318,6 +319,7 @@ export default class DataMgr {
         this.userData.diamond += val;
         this.saveUserData();
         xGame.eventMgr.event(DIAMOND_CHANGE);
+        this.updateUserInfo2Server("zs");
     }
     //钻石
     public static getDiamond() {
@@ -627,4 +629,58 @@ export default class DataMgr {
     }
 
 
+
+
+
+
+    /**
+     * 保存用户信息到服务器
+     * @param type 更新数据的类型  zs ,jb   
+     * @param count 数量
+     */
+    public static updateUserInfo2Server(type: string, count: number = 0) {
+
+        const keyForLoginInfo = "userInfo";
+        const userInfoData = Laya.LocalStorage.getItem(keyForLoginInfo);
+        if (userInfoData == null) {
+            //alert('Please log in.');
+            return;
+        }
+
+        let reqData = xGame.httpMgr.getReqData();
+        let rd: any = JSON.parse(reqData);
+        rd.dataType = type;
+        let dataValue = 0;
+        if (type == "zs") {//钻石
+            dataValue = this.getDiamond();
+        }
+        if (type == "jb") {//金币
+            dataValue = this.getCoin();
+        }
+        rd.dataValue = dataValue;
+        reqData = JSON.stringify(rd);
+        xGame.httpMgr.sendPost2025('user/update', reqData, (res) => {
+            try {
+                let code = res.code;
+                let data = res.data;
+                if (code == 401) {
+                    Laya.LocalStorage.setItem(keyForLoginInfo, null);
+                    alert('Please log in.');
+                    //import UIMsg from "./UIMsg";
+                    //xGame.uiMgr.Show(UIMsg, msg)
+                    return;
+                }
+                if (code == 200) {
+                    console.log('zh:更新账号资产OK' + JSON.stringify(res));
+                } else {
+                    console.log('zh:更新账号资产fa' + JSON.stringify(res));
+                }
+            } catch (error) {
+                console.log('error=' + error);
+                alert("Please check your network connection.");
+            } finally {
+            }
+        });
+
+    }
 }

+ 0 - 1
client/laya/src/ui/UIAddProp.ts

@@ -183,7 +183,6 @@ export default class UIAddProp extends UIBase {
             }
         }
 
-
         if (JSBridgeUtils.instance.showRewardAd('qjff_AD_for_uiAddProp_videoGetCoin')) {
 
         } else {

+ 19 - 2
client/laya/src/ui/UIMain.ts

@@ -207,7 +207,7 @@ export default class UIMain extends UIBase {
         console.log('zh:福利2');
         xGame.uiMgr.Show(UIFuli1);
         xGame.uiMgr.Show(UIFuli2);
-           console.log('zh:福利2222');
+        console.log('zh:福利2222');
     }
 
     /**
@@ -520,7 +520,24 @@ export default class UIMain extends UIBase {
             xGame.uiMgr.Show(UIMsg, "Network not ready. Try again later.")
             console.log('zh:✅❌  5秒后重新尝试加载网络资源');
             Laya.timer.once(5000, this, () => {
-                xGame.cfgMgr.getConfigFromServer();
+                let retryCount = 0;
+                const maxRetries = 3;
+
+                const tryFetchConfig = () => {
+                    try {
+                        xGame.cfgMgr.getConfigFromServer();
+                    } catch (error) {
+                        if (retryCount < maxRetries) {
+                            retryCount++;
+                            console.log(`🔄 第${retryCount}次重试获取配置...`);
+                            Laya.timer.once(5000, this, tryFetchConfig);
+                        } else {
+                            console.error("❌ 达到最大重试次数,配置获取失败");
+                        }
+                    }
+                };
+
+                tryFetchConfig();
             });
             return false;
         }

+ 1 - 1
client/laya/src/ui/UIShop.ts

@@ -62,7 +62,7 @@ export default class UIShop extends UIBase {
         let pd: any = JSON.parse(reqData);
         pd.splx = "Consumable";//商城商品类型
         reqData = JSON.stringify(pd);
-        xGame.httpMgr.sendPost2025('getProductList', reqData, (res) => {
+        xGame.httpMgr.sendPost2025('game2/getProductList', reqData, (res) => {
             try {
               //  console.log('zh:res = ' + JSON.stringify(res))
                 let code = res.code;

+ 1 - 0
client/laya/src/utils/Common.ts

@@ -701,6 +701,7 @@ export default class Common {
             //完成后的回调用
             switch (type) {
                 case Prop.diamond:
+                    
                     DataMgr.setDiamond(num);
                     break;
                 case Prop.coin:

Alguns arquivos não foram mostrados porque muitos arquivos mudaram nesse diff