lgh 7 месяцев назад
Родитель
Сommit
d6db75f6ca

+ 28 - 12
assets/scripts/game/HttpHelp.ts

@@ -23,11 +23,16 @@ export class HttpHelp {
         xhr.onreadystatechange = function () {
             if (xhr.readyState === 4 && xhr.status == 200) {
                 let respone = xhr.responseText;
-                if (bind != null) {
-                    callback.call(bind, respone);
-                } else {
-                    callback(respone);
+                try {
+                    if (bind != null) {
+                        callback.call(bind, respone);
+                    } else {
+                        callback(respone);
+                    }
+                } catch (error3) {
+                    
                 }
+              
             } else {
                 //  console.error(xhr.readyState+"httpGet 失败:"+xhr.status);
             }
@@ -59,18 +64,29 @@ export class HttpHelp {
             if (xhr.readyState === 4) {
                 let respone = xhr.responseText;
                 if (xhr.status == 200) {
-                    if (bind != null) {
-                        callback.call(bind, respone);
-                    } else {
-                        callback(respone);
+                    try {
+                        if (bind != null) {
+                            callback.call(bind, respone);
+                        } else {
+                            callback(respone);
+                        }
+                    } catch (error2) {
+                        
                     }
+                   
 
                 } else {
-                    if (bind != null) {
-                        callback.call(bind, "-1");
-                    } else {
-                        callback("-1");
+
+                    try {
+                        if (bind != null) {
+                            callback.call(bind, "-1");
+                        } else {
+                            callback("-1");
+                        }
+                    } catch (error1) {
+                        
                     }
+                  
                 }
             }
         };

+ 2 - 0
assets/scripts/game/gameConstants.ts

@@ -159,5 +159,7 @@ const gameConstants = {
     },
 
     SOUND_PUSH_CHECK_Y:0.7, //落到推动层上播放金币音效的位置
+
+    MaxAwardCount:3,  //最大礼物数量
 }
 export { gameConstants }

+ 7 - 3
assets/scripts/game/gameManager.ts

@@ -138,7 +138,7 @@ export class gameManager extends Component {
         } else {
             console.log("测试环境");
             this.golabMemory.isReplse = false;
-            this.golabMemory.Token = "dttesteyJhbGciOiJIUzUxMiJ9.eyJqdGkiOiI0MjMzMjciLCJpcCI6IjE4My4yNDkuMTEzLjIxNyIsIm9nIjoiMSIsImlhdCI6MTcyNDEzOTE3M30.oZCzn0JH4gfeIXP8nAWe3I91Fn9USK0GKnR0iFLPz6csv4prJMobd9EsHPWz8q9O6pFE9cPQKL73INxm0FLXJQ";
+            this.golabMemory.Token = "dttesteyJhbGciOiJIUzUxMiJ9.eyJqdGkiOiIzNjY2NDIzOCIsImlwIjoiMTgzLjI0OS44OS43MSIsIm9nIjoiMSIsImlhdCI6MTcyNjgxMDY2NX0.HRSb7o2CSlP2p1GJnKlSzF2nXdTiUuP6AfNA_ii1UXJG3OQOJInsMns1xxn1mv8mcc5fZo5iC51KXxTLjLbRdw";
         }
 
         this.GetBatchInfo();
@@ -157,6 +157,9 @@ export class gameManager extends Component {
         console.log("获得场次信息返回对象:", data)
         var obj: ResponseBase = JSON.parse(data);
         if (obj.code != 1) {
+            if (obj.message) {
+                uiManager.instance.showTips(obj.message);
+            }
             console.error("请求成功,返回数据错误", data);
             return;
         }
@@ -617,13 +620,14 @@ export class gameManager extends Component {
         console.log("掉落回调", data);
         let url = "coins/manage/getAward";
         let timenum = this.getTimestampInSeconds();
-        let m: string = `uuid='${data.uuidstr}'&time='${timenum}'fxkj9999`;
+        let m: string = `uuid=${data.uuidstr}&time=${timenum}fxkj9999`;
         const md5: Md5 = new Md5();
         md5.appendStr(m);
+        let str = md5.end()
         let parm = {
             time: timenum.toString(),
             uuid: data.uuidstr,
-            sign: md5.end()
+            sign: str
         };
         console.log("获得奖品发送数据", parm);
         HttpHelp.httpPost(url, JSON.stringify(parm), this.GetGoodsBack, this.golabMemory.Token, this);

+ 12 - 6
assets/scripts/ui/game/GetGoodPanel.ts

@@ -45,13 +45,18 @@ export class GetGoodPanel extends Component {
         this.wupTitle.string = `<color=#2D3461>${data.name}</color><color=#FF5C00>*${data.num}</color>`;
         const remoteUrl=data.icon?data.icon:"";
         var thiss=this;
+        this.wupImg.spriteFrame=null;
         if(remoteUrl.length>10){
-            assetManager.loadRemote<ImageAsset>(remoteUrl, {ext: '.png'}, function (err, imageAsset) {
-                const spriteFrame = new SpriteFrame();
-                const texture = new Texture2D();
-                texture.image = imageAsset;
-                spriteFrame.texture = texture;
-                thiss.wupImg.spriteFrame=spriteFrame;
+            assetManager.loadRemote<ImageAsset>(remoteUrl, function (err, imageAsset) {
+                if(err){
+                    return console.warn("ImageAssert load failed, err:" + err.message,remoteUrl);
+                }
+                thiss.wupImg.spriteFrame = SpriteFrame.createWithImage(imageAsset);
+                // const spriteFrame = new SpriteFrame();
+                // const texture = new Texture2D();
+                // texture.image = imageAsset;
+                // spriteFrame.texture = texture;
+                // thiss.wupImg.spriteFrame=spriteFrame;
             });
         } 
         const type=data.basicType?data.basicType:0;
@@ -60,6 +65,7 @@ export class GetGoodPanel extends Component {
     }
 
     public btnClose(){
+        this.wupImg.spriteFrame=null;
         this.node.active=false;
     }
 

+ 11 - 1
assets/scripts/ui/game/gamePanel.ts

@@ -202,6 +202,8 @@ export class GamePanel extends Component {
     }
 
     HttpSendGoldBack(data: any) {
+        try {
+            if(data==-1)return;
         // console.log('HttpSendGoldBack:  ',data);
         var obj: ResponseBase = JSON.parse(data);
         if (obj.code != 1) {
@@ -216,7 +218,11 @@ export class GamePanel extends Component {
         playerData.instance.setPlayMoney(coin.gameCurrcy);
         clientEvent.dispatchEvent(gameConstants.EVENT_LIST.GOLD_SHOW_UPDATE);
         if (coin.awardList && coin.awardList.length > 0) {
-            for (let i = 0; i < coin.awardList.length; i++) {
+            let len=coin.awardList.length;
+            if(len>gameConstants.MaxAwardCount){
+                len=gameConstants.MaxAwardCount;
+            }
+            for (let i = 0; i < len; i++) {
                 let key = coin.awardList[i].uuid;
                 if (!key) continue;
                 gameManager.Instance._createPresent(coin.awardList[i]); //创建一个礼物
@@ -224,6 +230,10 @@ export class GamePanel extends Component {
             }
         }
         this.btnTuiBi.interactable = true;
+        } catch (errorx) {
+            console.error("投币回包err:",errorx);
+            this.btnTuiBi.interactable = true;
+        }
     }
 
     /**