Forráskód Böngészése

【优化】红包提现页优化

mojunshou 7 hónapja
szülő
commit
ea8df9c2bd

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 0 - 10610
assets/bundle/gui/eliminate/gameView.prefab


+ 0 - 13
assets/bundle/gui/eliminate/gameView.prefab.meta

@@ -1,13 +0,0 @@
-{
-  "ver": "1.1.50",
-  "importer": "prefab",
-  "imported": true,
-  "uuid": "002e5316-d9a3-40a3-9547-125f0527ac70",
-  "files": [
-    ".json"
-  ],
-  "subMetas": {},
-  "userData": {
-    "syncNodeName": "gameView"
-  }
-}

+ 2 - 2
assets/bundle/gui/eliminate/texture/load_4.png.meta

@@ -51,8 +51,8 @@
         "rawHeight": 28,
         "borderTop": 0,
         "borderBottom": 0,
-        "borderLeft": 30,
-        "borderRight": 43,
+        "borderLeft": 0,
+        "borderRight": 0,
         "packable": true,
         "pixelsToUnit": 100,
         "pivotX": 0.5,

+ 4 - 4
assets/bundle/gui/loading/loading.prefab

@@ -549,7 +549,7 @@
     },
     "_lpos": {
       "__type__": "cc.Vec3",
-      "x": 0,
+      "x": -281,
       "y": 0,
       "z": 0
     },
@@ -595,7 +595,7 @@
     },
     "_anchorPoint": {
       "__type__": "cc.Vec2",
-      "x": 0.5,
+      "x": 0,
       "y": 0.5
     },
     "_id": ""
@@ -937,8 +937,8 @@
       "__id__": 24
     },
     "_mode": 2,
-    "_totalLength": 1,
-    "_progress": 0,
+    "_totalLength": 0,
+    "_progress": 1,
     "_reverse": false,
     "_id": ""
   },

+ 37 - 19
assets/script/game/common/manager/ServerHandler.ts

@@ -2,7 +2,7 @@
  * @Author: mojunshou 1637302775@qq.com
  * @Date: 2025-04-11 10:16:41
  * @LastEditors: mojunshou 1637302775@qq.com
- * @LastEditTime: 2025-04-16 11:59:51
+ * @LastEditTime: 2025-04-16 15:01:15
  * @Description: 
  */
 // ServerHandler.ts
@@ -81,6 +81,8 @@ export class ServerHandler {
         game.curLevelConfig = data.currentLevelConf;
         game.costInfo = data.handlingChargeConf;
         game.eventType = data.currentLevelConf.eventType;
+        account.wxCoin = this.formatNumber(data.props['1005'], 1000);
+        account.hbCoin = this.formatNumber(data.props['1004'], 100);
         oops.message.dispatchEvent(GameEvent.UserLogin);
     }
 
@@ -98,7 +100,7 @@ export class ServerHandler {
     onDailyReward(str: string) {
         console.log('[服务器] 每日奖励返回', str);
         let result = JSON.parse(str);
-        smc.account.AccountModel.hbCoin = result.props["1004"] / 100;
+        smc.account.AccountModel.hbCoin = this.formatNumber(result.props["1004"], 100);
         smc.account.AccountModel.xcCount = result.props["1007"];  //消除次数
         smc.account.AccountModel.goldCoin = result.props["1006"] //金砖数量
         smc.game.GameModel.wxCash = result.money;
@@ -122,7 +124,7 @@ export class ServerHandler {
     onHbTxInfo(str: string) {
         console.log('[服务器] 获取红包页面信息返回', str);
         let result = JSON.parse(str);
-        smc.account.AccountModel.hbCoin = result.props["1004"] / 100;
+        smc.account.AccountModel.hbCoin = this.formatNumber(result.props["1004"], 100);
         smc.account.AccountModel.xcCount = result.props["1007"];  //消除次数
         smc.account.AccountModel.goldCoin = result.props["1006"] //金砖数量
         //要根据taskList的status排序,可领取再在前边,领取完在最后0 进行中 1 可领取 2已经领取
@@ -130,6 +132,7 @@ export class ServerHandler {
             if (a.status === 1 && b.status !== 1) return -1; // a 在前
         })
         smc.game.GameModel.taskList = taskList;
+        smc.game.GameModel.wxCash = result.money;
         oops.message.dispatchEvent(GameEvent.openView, "openRedBagView");
     }
 
@@ -147,10 +150,11 @@ export class ServerHandler {
         const props = result.data.props;
         const account = smc.account.AccountModel;
         const game = smc.game.GameModel;
-        account.wxCoin = props['1005'];
-        account.hbCoin = props['1004'];
+        account.wxCoin = this.formatNumber(props['1005'], 1000);
+        account.hbCoin = this.formatNumber(props['1004'], 100);
         account.goldCoin = props['1006'];
-        game.handlingCharge = props['1009'];
+        game.handlingCharge = this.formatNumber(props['1009'], 1000);
+        //返回成功才登录
     }
 
     //获取提现记录
@@ -202,7 +206,9 @@ export class ServerHandler {
     onRebates(str: string) {
         console.log('[服务器] 提现返利信息', str);
         let result = JSON.parse(str);
-        smc.game.GameModel.cashNum = result.props["1004"] / 100;
+        smc.game.GameModel.cashNum = this.formatNumber(result.props["1004"], 100);
+        smc.account.AccountModel.hbCoin = this.formatNumber(result.props["1004"], 100);
+        smc.game.GameModel.changeHbCoin = this.formatNumber(result.changes["1004"], 100);
         oops.message.dispatchEvent(GameEvent.openView, "openRebateView")
     }
 
@@ -244,10 +250,11 @@ export class ServerHandler {
             const changes = result.changes;
             const account = smc.account.AccountModel;
             const game = smc.game.GameModel;
-            account.wxCoin = props['1005'];
-            account.hbCoin = props['1004'];
-            game.changeHbCoin = changes['1004'] / 100;
-            game.changeWxCoin = changes['1005'] / 1000;
+            //全部取小数点后两位
+            account.hbCoin = this.formatNumber(props['1004'], 100);
+            account.wxCoin = this.formatNumber(props['1005'], 1000);
+            game.changeHbCoin = this.formatNumber(changes['1004'], 100);
+            game.changeWxCoin = this.formatNumber(changes['1005'], 1000);
             oops.message.dispatchEvent(GameEvent.showCoinAnimation);
             //还要知道是不是二倍速的
         }
@@ -285,10 +292,10 @@ export class ServerHandler {
         console.log('[服务器] 直接领取通关奖励成功返回', str);
         let result = JSON.parse(str);
         //全部取小数点后两位
-        smc.game.GameModel.changeHbCoin = result.changes["1004"] / 100;
-        smc.game.GameModel.changeHbCoin = result.changes["1005"] / 1000;
-        smc.account.AccountModel.hbCoin = result.props["1004"] / 100;
-        smc.account.AccountModel.wxCoin = result.props["1005"] / 1000;
+        smc.game.GameModel.changeHbCoin = this.formatNumber(result.changes['1004'], 100);
+        smc.game.GameModel.changeWxCoin = this.formatNumber(result.changes['1005'], 1000);
+        smc.account.AccountModel.hbCoin = this.formatNumber(result.props["1004"], 100);
+        smc.account.AccountModel.wxCoin = this.formatNumber(result.props["1005"], 1000);
         oops.message.dispatchEvent(GameEvent.showCoinAnimation);
         //请求下一局
         this.getNextLevel();
@@ -350,10 +357,10 @@ export class ServerHandler {
             const changes = result.changes;
             const account = smc.account.AccountModel;
             const game = smc.game.GameModel;
-            account.wxCoin = props['1005'];
-            account.hbCoin = props['1004'];
-            game.changeHbCoin = changes['1004'] / 100;
-            game.changeWxCoin = changes['1005'] / 1000;
+            account.wxCoin = this.formatNumber(props['1005'], 1000);
+            account.hbCoin = this.formatNumber(props['1004'], 100);
+            game.changeHbCoin = this.formatNumber(changes['1004'], 100);
+            game.changeWxCoin = this.formatNumber(changes['1005'], 1000);
             oops.message.dispatchEvent(GameEvent.showCoinAnimation);
             //还要知道是不是二倍速的
         }
@@ -489,6 +496,17 @@ export class ServerHandler {
     onRequestFail(code: number, str: string) {
         console.log('[服务器] 请求失败', code, str);
     }
+
+
+
+    //小数点保留两位小数,返回的还是数字,不是字符串
+    formatNumber(num: number, type: number) {
+        num = num / type;
+        const str = num.toFixed(2);
+        return parseFloat(str);
+    }
+
+
 }
 
 window["ServerHandler"] = ServerHandler;

+ 5 - 2
assets/script/game/view/CashRebateView.ts

@@ -2,7 +2,7 @@
  * @Author: mojunshou 1637302775@qq.com
  * @Date: 2025-03-21 11:45:43
  * @LastEditors: mojunshou 1637302775@qq.com
- * @LastEditTime: 2025-04-11 17:51:54
+ * @LastEditTime: 2025-04-16 14:44:54
  * @Description: 提现必返
  */
 import { _decorator, Label } from 'cc';
@@ -14,6 +14,7 @@ import { CocosHandler } from '../common/manager/CocosHandler';
 import { ADHandler } from '../common/manager/ADHandler';
 import { smc } from '../common/SingletonModuleComp';
 import { GameEvent } from '../common/config/GameEvent';
+import { ServerHandler } from '../common/manager/ServerHandler';
 
 
 const { ccclass, property } = _decorator;
@@ -37,7 +38,9 @@ export class CashRebateView extends GameComponent {
         if (DeviceUtil.isNative && DeviceUtil.isAndroid) {
             oops.gui.remove(UIID.CashRebate);
             ADHandler.inst.showAd("105");
-            oops.message.dispatchEvent(GameEvent.showCoinAnimation);
+            oops.message.dispatchEvent(GameEvent.showCoinAnimation, "showCoin");
+            //下一关
+            ServerHandler.inst.getNextLevel();
 
         } else {
             oops.gui.remove(UIID.CashRebate);

+ 49 - 46
assets/script/game/view/EliminateViewComp.ts

@@ -2,7 +2,7 @@
  * @Author: mojunshou 1637302775@qq.com
  * @Date: 2025-03-20 15:01:09
  * @LastEditors: mojunshou 1637302775@qq.com
- * @LastEditTime: 2025-04-16 12:53:14
+ * @LastEditTime: 2025-04-16 14:58:52
  * @Description: 消除游戏主场景
  */
 import { _decorator, Button, Color, EventTouch, instantiate, JsonAsset, Label, Node, Prefab, randomRangeInt, Sprite, tween, UITransform, Vec2, Vec3, Widget } from "cc";
@@ -309,12 +309,25 @@ export class EliminateViewComp extends CCComp {
         console.log("复活游戏,分数不清零");
     }
 
-    //显示金币动画
+    //显示金币动画 --是否只计算红包
     showCoinAnimation(event: string, args: string) {
         //计算中间的坐标就好
         const lastPos = this.moveNode.getWorldPosition();
         const score = this.score;
-
+        if (args) {
+            // 添加回调函数,在红包动画完成后显示红包分数增加
+            this.createCoinFlyAnimation(
+                this.redPacketPrefab,
+                lastPos,
+                this.awardLb.node.getWorldPosition(),
+                5,
+                () => {
+                    // 显示红包分数增加动画
+                    this.showRedPacketScoreAnimation();
+                }
+            );
+            return;
+        }
         // 添加回调函数,在金币动画完成后显示微信分数增加
         this.createCoinFlyAnimation(
             this.coinPrefab,
@@ -327,17 +340,6 @@ export class EliminateViewComp extends CCComp {
             }
         );
 
-        // 添加回调函数,在红包动画完成后显示红包分数增加
-        this.createCoinFlyAnimation(
-            this.redPacketPrefab,
-            lastPos,
-            this.awardLb.node.getWorldPosition(),
-            5,
-            () => {
-                // 显示红包分数增加动画
-                this.showRedPacketScoreAnimation();
-            }
-        );
     }
 
 
@@ -1079,7 +1081,6 @@ export class EliminateViewComp extends CCComp {
             this.scheduleOnce(() => {
                 // 计算分数:每行/列的基础分 + 每个额外格子的分数
                 let score = 0;
-
                 // 行消除基础分
                 for (let i = 1; i <= eliminateRowNum; i++) {
                     score += this.eliminateBaseScore; // 每行基础分
@@ -1097,41 +1098,42 @@ export class EliminateViewComp extends CCComp {
                 this.lab_score.string = this.score.toString();
                 if (DeviceUtil.isNative && DeviceUtil.isAndroid) {
                     ServerHandler.inst.updateEliminationReward({
-                        count: 1,
+                        count: this.totalEliminationCount,
                         score: this.score,
-                        level: 1
+                        level: smc.account.AccountModel.curLevel,
                     })
-                }
-
-                //要服务器请求完了出了数据才展示动画
-                const lastGrid = gridEliminateList[gridEliminateList.length - 1];
-                if (lastGrid?.gridNode && this.coinPrefab && this.amountLb?.node) {
-                    const lastPos = lastGrid.gridNode.getWorldPosition();
+                } else {
+                    //要服务器请求完了出了数据才展示动画
+                    const lastGrid = gridEliminateList[gridEliminateList.length - 1];
+                    if (lastGrid?.gridNode && this.coinPrefab && this.amountLb?.node) {
+                        const lastPos = lastGrid.gridNode.getWorldPosition();
 
-                    // 添加回调函数,在金币动画完成后显示微信分数增加
-                    this.createCoinFlyAnimation(
-                        this.coinPrefab,
-                        lastPos,
-                        this.amountLb.node.getWorldPosition(),
-                        score,
-                        () => {
-                            // 显示微信分数增加动画
-                            this.showWechatScoreAnimation();
-                        }
-                    );
+                        // 添加回调函数,在金币动画完成后显示微信分数增加
+                        this.createCoinFlyAnimation(
+                            this.coinPrefab,
+                            lastPos,
+                            this.amountLb.node.getWorldPosition(),
+                            score,
+                            () => {
+                                // 显示微信分数增加动画
+                                this.showWechatScoreAnimation();
+                            }
+                        );
 
-                    // 添加回调函数,在红包动画完成后显示红包分数增加
-                    this.createCoinFlyAnimation(
-                        this.redPacketPrefab,
-                        lastPos,
-                        this.awardLb.node.getWorldPosition(),
-                        5,
-                        () => {
-                            // 显示红包分数增加动画
-                            this.showRedPacketScoreAnimation();
-                        }
-                    );
+                        // 添加回调函数,在红包动画完成后显示红包分数增加
+                        this.createCoinFlyAnimation(
+                            this.redPacketPrefab,
+                            lastPos,
+                            this.awardLb.node.getWorldPosition(),
+                            5,
+                            () => {
+                                // 显示红包分数增加动画
+                                this.showRedPacketScoreAnimation();
+                            }
+                        );
+                    }
                 }
+
                 // 告诉调用者有消除发生
                 resolve(true)
                 // 检查是否需要继续消除
@@ -1281,8 +1283,9 @@ export class EliminateViewComp extends CCComp {
     private showRedPacketScoreAnimation() {
         if (!this.tweenRedNode) return;
         //如果有值就是要那个,没有就是取随机
-
         const changeNum = smc.game.GameModel.changeHbCoin;
+        console.log("红包分数增加动画", changeNum)
+        this.cash = smc.account.AccountModel.hbCoin;
         if (!changeNum) return;
         const formattedValue = changeNum;
 

+ 2 - 2
assets/script/game/view/RedPackeItemView.ts

@@ -66,8 +66,8 @@ export class RedPackeItemView extends GameComponent {
         this.receivedNode.active = this.data.status == 2;
         this.lab_title.string = this.data.title_num + "次";
         this.lab_num.string = this.data.reward[0].propNum + "元";
-        this.lab_progress.string = `${smc.account.AccountModel.xcCount}/${this.data.total_num}`;
-        const loadNum = smc.account.AccountModel.xcCount / this.data.target > 1 ? 1 : smc.account.AccountModel.xcCount / this.data.target;
+        this.lab_progress.string = `${this.data.cur_num}/${this.data.total_num}`;
+        const loadNum = this.data.cur_num / this.data.total_num > 1 ? 1 : this.data.cur_num / this.data.total_num;
         this.pro_progress.progress = loadNum;
     }