开始滚动前获取余额时,如果网络错误,添加错误后的处理
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 1m31s
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 1m31s
This commit is contained in:
parent
e77e909d91
commit
a45298708d
@ -416,25 +416,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<number | null> {
|
||||
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;
|
||||
@ -809,5 +809,27 @@ export class SlotBar extends Component {
|
||||
this.setBet(this.betGrade[this.betIndex], true);
|
||||
}
|
||||
}
|
||||
// private _refreshingBalance: boolean = false;
|
||||
async refreshBalanceFromServer(): Promise<number | null> {
|
||||
// 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)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -239,12 +239,11 @@ export class SlotScene extends Component {
|
||||
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);
|
||||
|
||||
@ -187,7 +187,7 @@
|
||||
"_priority": 0,
|
||||
"_fov": 45,
|
||||
"_fovAxis": 0,
|
||||
"_orthoHeight": 959.9999999999999,
|
||||
"_orthoHeight": 960,
|
||||
"_near": 0,
|
||||
"_far": 2000,
|
||||
"_color": {
|
||||
|
||||
@ -9,7 +9,7 @@ const qs = new URLSearchParams(location.search)
|
||||
|
||||
// let apiaddr = "https://rpgames-api.rpfafafahkdev.com";
|
||||
let apiaddr = "";
|
||||
let token = "eyJQIjoxMDA5NDksIkUiOjE3ODExODc3NjIsIlMiOjEwMDAsIkQiOiJycF8xMDAxMiJ9.5v087Lt--ozENIV6Rdvga9nZVc2bzxf11iJAbG5x8gM";
|
||||
let token = "eyJQIjoxMDA5NDksIkUiOjE3ODI0MjAxNzcsIlMiOjEwMDQsIkQiOiJycF8xMDAxMiJ9.IH1jKIT22-uI8IRPxgiO6ny0MkEn-ktC9FFRLcy1_3A";
|
||||
let language = "en"
|
||||
let currency = "THB"
|
||||
let isfrom = null
|
||||
|
||||
Loading…
Reference in New Issue
Block a user