点击余额栏刷新当前余额,下注时余额不足在本地直接拦截不走spin接口
This commit is contained in:
parent
4f83840134
commit
e7d3b71c9d
@ -1,6 +1,6 @@
|
|||||||
import { _decorator, Animation, Button, Component, Label, Node, sp, Sprite, tween, Tween, UIOpacity, Vec3, } from "cc";
|
import { _decorator, Animation, Button, Component, Label, Node, sp, Sprite, tween, Tween, UIOpacity, Vec3, } from "cc";
|
||||||
import { SLOT_BAR_EVENT } from "./Define";
|
import { SLOT_BAR_EVENT } from "./Define";
|
||||||
import { gold2cash } from "../../Main/Scripts/main/comm";
|
import { callGameBalanceApi, getGameId, gold2cash } from "../../Main/Scripts/main/comm";
|
||||||
import { AudioManager } from "../../Main/Scripts/managers/AudioManager";
|
import { AudioManager } from "../../Main/Scripts/managers/AudioManager";
|
||||||
import { GameDataManager } from "../../Main/Scripts/managers/GameDataManager";
|
import { GameDataManager } from "../../Main/Scripts/managers/GameDataManager";
|
||||||
import { I18nManager } from "../../Main/Scripts/managers/I18nManager";
|
import { I18nManager } from "../../Main/Scripts/managers/I18nManager";
|
||||||
@ -537,6 +537,11 @@ export class SlotBar extends Component {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async onClickBalance() {
|
||||||
|
let balacneData = await callGameBalanceApi({ GameId: getGameId() });
|
||||||
|
this.setBalance(balacneData.Balance)
|
||||||
|
}
|
||||||
|
|
||||||
setLeftAutoCount(count: number) {
|
setLeftAutoCount(count: number) {
|
||||||
let num = this.getBtnNode(Btn_Key.StopAutoSpinBtn)
|
let num = this.getBtnNode(Btn_Key.StopAutoSpinBtn)
|
||||||
.getChildByName("num")
|
.getChildByName("num")
|
||||||
|
|||||||
@ -220,6 +220,13 @@ export class SlotScene extends Component {
|
|||||||
this.slotBar.setWin(0);
|
this.slotBar.setWin(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.slotBar.getBalance() < this.slotBar.getBet()) {
|
||||||
|
//余额不足不经过服务器,在客户端拦截
|
||||||
|
this.showErrorTip(2, "");
|
||||||
|
this.handleErrSpin();
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
let msg = !this.isFeatureBuySpin && buyType == 0 ?
|
let msg = !this.isFeatureBuySpin && buyType == 0 ?
|
||||||
{ Bet: this.slotBar.getBet(), IsDouble: this.isDoubleWin, }
|
{ Bet: this.slotBar.getBet(), IsDouble: this.isDoubleWin, }
|
||||||
: { Bet: this.slotBar.getBet(), IsBuy: true, BuyType: buyType, IsDouble: this.isDoubleWin, };
|
: { Bet: this.slotBar.getBet(), IsBuy: true, BuyType: buyType, IsDouble: this.isDoubleWin, };
|
||||||
@ -944,6 +951,8 @@ export class SlotScene extends Component {
|
|||||||
this.spinData.SpinScore = 0;
|
this.spinData.SpinScore = 0;
|
||||||
this.slotGame.stopScroll(this.spinData);
|
this.slotGame.stopScroll(this.spinData);
|
||||||
this.slotBar.setBalance(this.spinInfo.Balance);
|
this.slotBar.setBalance(this.spinInfo.Balance);
|
||||||
|
this.slotBar.closeAutoSpin();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
openFirstChooseDiff() {
|
openFirstChooseDiff() {
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -135,6 +135,29 @@ export async function callGamePendingApi(argsObj: any) {
|
|||||||
return obj
|
return obj
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function callGameBalanceApi(argsObj: any) {
|
||||||
|
const url = apiaddr + path.join("/gameapi/getPlayerBalance")
|
||||||
|
const payload = JSON.stringify(argsObj)
|
||||||
|
|
||||||
|
const res = await fetch(url, {
|
||||||
|
signal: AbortSignal.timeout(10000),
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"X-Rp-Token": token,
|
||||||
|
},
|
||||||
|
method: "POST",
|
||||||
|
body: payload,
|
||||||
|
mode: 'cors',
|
||||||
|
})
|
||||||
|
|
||||||
|
if (res.status != 200) {
|
||||||
|
const errstr = await res.text()
|
||||||
|
throw new Error(errstr || res.statusText)
|
||||||
|
}
|
||||||
|
const obj = await res.json()
|
||||||
|
return obj
|
||||||
|
}
|
||||||
|
|
||||||
export async function callGameApi(action: string, argsObj: any) {
|
export async function callGameApi(action: string, argsObj: any) {
|
||||||
const url = apiaddr + path.join("/gameapi/", GameDataManager.instance.gamePending, action)
|
const url = apiaddr + path.join("/gameapi/", GameDataManager.instance.gamePending, action)
|
||||||
const payload = JSON.stringify(argsObj)
|
const payload = JSON.stringify(argsObj)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user