余额不足时在客户端拦截,不经过spin接口

This commit is contained in:
TJH 2026-06-08 15:23:28 +08:00
parent d6d9db5f65
commit 27c066d339
4 changed files with 932 additions and 820 deletions

File diff suppressed because it is too large Load Diff

View File

@ -29,7 +29,9 @@ import { AutoSpinPanel } from "./game/AutoSpinPanel";
import { NodePoolManager } from "../../Loading/scripts/manager/NodePoolManager";
import { webView } from "./game/WebView";
import {
callGameBalanceApi,
cash2gold,
getGameId,
getHistoryUrl,
getOddsUrl,
getSupportUrl,
@ -420,6 +422,12 @@ export class SlotBar extends Component {
this.setBet(this.betGrade[this.betIndex]);
}
async onClickBalance() {
let balacneData = await callGameBalanceApi({ GameId: getGameId() });
this.setBalance(balacneData.Balance)
}
private currentTipTween: Tween<Node> = null;
private hideTimer: number = null;
showTipSmall(str: string, openTurbo?: boolean) {

View File

@ -283,18 +283,25 @@ export class SlotScene extends Component {
isFreeSpin: boolean = false,
isFeatureBuy: boolean = false
) {
try {
this.gameState.isOnReconnect = false;
this.isReceiveMsg = false;
this.isErr = false;
this.slotGame.spin(this.gameState.isInFreeSpin);
this.gameState.isOneRoundEnd = false;
this.slotGame.changeBg(this.gameState.isInFreeSpin);
this.slotGame.hideIconMsg();
if (!isFreeSpin) {
this.slotBar.setWin(0);
}
this.gameState.isOnReconnect = false;
this.isReceiveMsg = false;
this.isErr = false;
this.slotGame.spin(this.gameState.isInFreeSpin);
this.gameState.isOneRoundEnd = false;
this.slotGame.changeBg(this.gameState.isInFreeSpin);
this.slotGame.hideIconMsg();
if (!isFreeSpin) {
this.slotBar.setWin(0);
}
if (this.slotBar.getBalance() < (isFeatureBuy ? this.slotBar.getBet() * this.gameInfo.BuyMul : this.slotBar.getBet()) && !isFreeSpin && !GameDataManager.instance.frb.Ongoing) {
//余额不足不经过服务器,在客户端拦截
this.showErrorTip(2, "");
this.handleErrSpin();
return
}
try {
// 如果有frb就不会扣除金额
let frb = GameDataManager.instance.frb;
if (frb && frb.Ongoing != null) {
@ -412,6 +419,7 @@ export class SlotScene extends Component {
this.slotGame.stopScroll(this.spinData, false, null);
this.slotGame.manualStop();
this.slotBar.setBalance(this.spinInfo.Balance);
this.slotBar.closeAutoSpin();
}
private async handleSpinResult() {

View File

@ -7,7 +7,7 @@ import { PREVIEW } from "cc/env"
const gameId = "rp_11001";
// let apiaddr = "https://rpgames-api.rpfafafahkdev.com";
let apiaddr = "";
let token = "eyJQIjoxMDA5NDksIkUiOjE3Nzk5Nzk1NzUsIlMiOjEwMDEsIkQiOiJycF8xMTAwMSJ9.zFNHlm0quBGtYIxM735w8tij2YjXvkTldJ1_rCP-oqk";
let token = "eyJQIjoxMDA5NDksIkUiOjE3ODA5NDMxOTgsIlMiOjEwMDUsIkQiOiJycF8xMTAwMSJ9.w5qJQBglbAHpEedbpdt-XRMZjG4mxAz79ov8CuOU-GQ";
let language = "en"
let currency = "THB"
@ -100,6 +100,29 @@ AbortSignal.timeout ??= function timeout(ms) {
return ctrl.signal
}
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) {
const url = apiaddr + path.join("/gameapi/", gameId, action)
const payload = JSON.stringify(argsObj)