From deaaf21e3ce82793d4bc91f11629ee38052c3686 Mon Sep 17 00:00:00 2001 From: TJH Date: Thu, 25 Jun 2026 16:40:41 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=80=E5=A7=8B=E6=BB=9A=E5=8A=A8=E5=89=8D?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E4=BD=99=E9=A2=9D=E6=97=B6=EF=BC=8C=E5=A6=82?= =?UTF-8?q?=E6=9E=9C=E7=BD=91=E7=BB=9C=E9=94=99=E8=AF=AF=EF=BC=8C=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E9=94=99=E8=AF=AF=E5=90=8E=E7=9A=84=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/Game/scripts/SlotBar.ts | 38 ++++++++++++++++++++++++++------ assets/Game/scripts/SlotScene.ts | 9 ++++---- assets/Loading/game.scene | 12 +++++----- assets/Loading/scripts/comm.ts | 2 +- 4 files changed, 42 insertions(+), 19 deletions(-) diff --git a/assets/Game/scripts/SlotBar.ts b/assets/Game/scripts/SlotBar.ts index ed9789b..177ea9a 100644 --- a/assets/Game/scripts/SlotBar.ts +++ b/assets/Game/scripts/SlotBar.ts @@ -427,25 +427,25 @@ export class SlotBar extends Component { if (this.isGetBalance) return this.isGetBalance = true; try { - let balacneData = await callGameBalanceApi({ GameId: getGameId() }); - this.setBalance(balacneData.Balance) - return balacneData.Balance; + let balacneData = await this.refreshBalanceFromServer(); + this.setBalance(balacneData) + return balacneData; } catch (err) { console.log('获取余额失败') return null; } finally { this.scheduleOnce(() => { this.isGetBalance = false; - }, 1) + }, 0.5) } } async onConfirmErr2(): Promise { try { - let balacneData = await callGameBalanceApi({ GameId: getGameId() }); - this.setBalance(balacneData.Balance) - return balacneData.Balance; + let balacneData = await this.refreshBalanceFromServer(); + this.setBalance(balacneData) + return balacneData; } catch (err) { console.log('获取余额失败') return null; @@ -834,4 +834,28 @@ export class SlotBar extends Component { this.setBet(this.betGrade[this.betIndex], true); } } + + // private _refreshingBalance: boolean = false; + async refreshBalanceFromServer(): Promise { + // if (this._refreshingBalance) return this.getBalance(); + // this._refreshingBalance = true; + try { + const res = await callGameBalanceApi({}); + const balance = Number(res.Balance); + if (!Number.isFinite(balance)) { + console.warn("[SlotBar] invalid balance response:", res); + return this.getBalance(); + } + this.setBalance(balance); + return balance; + } catch (err) { + console.error("[SlotBar] refresh balance failed:", err); + return this.getBalance(); + } finally { + // this.scheduleOnce(() => { + // this._refreshingBalance = false; + // }, 1) + + } + } } diff --git a/assets/Game/scripts/SlotScene.ts b/assets/Game/scripts/SlotScene.ts index f633f4f..013e333 100644 --- a/assets/Game/scripts/SlotScene.ts +++ b/assets/Game/scripts/SlotScene.ts @@ -298,12 +298,11 @@ export class SlotScene extends Component { if (!isFreeSpin) { this.slotBar.setWin(0); } - let curBalanceData = await callGameBalanceApi({ GameId: getGameId() }) - let curBalance = curBalanceData.Balance - if (!curBalance) { - curBalance = this.slotBar.getBalance() + let curBalanceData = await this.slotBar.refreshBalanceFromServer() + if (!curBalanceData) { + curBalanceData = this.slotBar.getBalance() } - if (curBalance < (isFeatureBuy ? this.slotBar.getBet() * this.gameInfo.BuyMul : this.slotBar.getBet()) && !isFreeSpin && !GameDataManager.instance.frb.Ongoing) { + if (curBalanceData < (isFeatureBuy ? this.slotBar.getBet() * this.gameInfo.BuyMul : this.slotBar.getBet()) && !isFreeSpin && !GameDataManager.instance.frb.Ongoing) { //余额不足不经过服务器,在客户端拦截 this.showErrorTip(2, () => { this.slotBar.onConfirmErr2() }); this.handleErrSpin(true); diff --git a/assets/Loading/game.scene b/assets/Loading/game.scene index b5b8467..db72553 100644 --- a/assets/Loading/game.scene +++ b/assets/Loading/game.scene @@ -105,7 +105,7 @@ "_lpos": { "__type__": "cc.Vec3", "x": 540, - "y": 959.9999999999999, + "y": 960, "z": 0 }, "_lrot": { @@ -190,7 +190,7 @@ "_priority": 0, "_fov": 45, "_fovAxis": 0, - "_orthoHeight": 959.9999999999999, + "_orthoHeight": 960, "_near": 0, "_far": 2000, "_color": { @@ -2342,7 +2342,7 @@ "_contentSize": { "__type__": "cc.Size", "width": 1080, - "height": 1919.9999999999998 + "height": 1920 }, "_anchorPoint": { "__type__": "cc.Vec2", @@ -2442,7 +2442,7 @@ "_contentSize": { "__type__": "cc.Size", "width": 1080, - "height": 1919.9999999999998 + "height": 1920 }, "_anchorPoint": { "__type__": "cc.Vec2", @@ -2494,7 +2494,7 @@ "_contentSize": { "__type__": "cc.Size", "width": 1080, - "height": 1919.9999999999998 + "height": 1920 }, "_anchorPoint": { "__type__": "cc.Vec2", @@ -3070,7 +3070,7 @@ "_contentSize": { "__type__": "cc.Size", "width": 1080, - "height": 1919.9999999999998 + "height": 1920 }, "_anchorPoint": { "__type__": "cc.Vec2", diff --git a/assets/Loading/scripts/comm.ts b/assets/Loading/scripts/comm.ts index 72e3577..0e06ac1 100644 --- a/assets/Loading/scripts/comm.ts +++ b/assets/Loading/scripts/comm.ts @@ -7,7 +7,7 @@ import { PREVIEW } from "cc/env" const gameId = "rp_11001"; // let apiaddr = "https://rpgames-api.rpfafafahkdev.com"; let apiaddr = ""; -let token = "eyJQIjoxMDA5NDksIkUiOjE3ODExODU1MzgsIlMiOjEwMDIsIkQiOiJycF8xMTAwMSJ9.MEuOw7xQRgnH1-0hQFXTspVZbXMEsvPBF2BbUFq3wBg"; +let token = "eyJQIjoxMDA5NDksIkUiOjE3ODI0MTk0MzcsIlMiOjEwMDEsIkQiOiJycF8xMTAwMSJ9.vtoxQYfRPLeEqzcOqkCE7UIVn6G8xFejT34eR6pixR8"; let language = "en" let currency = "THB"