优化 游戏金币余额显示
This commit is contained in:
@@ -483,6 +483,16 @@
|
||||
autoCloseTimer: null,
|
||||
autoCloseCountdown: 0,
|
||||
|
||||
/**
|
||||
* 同步全局聊天上下文中的金币余额,供弹窗右上角与其他面板共用。
|
||||
*/
|
||||
syncUserGold(jjb) {
|
||||
if (jjb === undefined || jjb === null) return;
|
||||
if (!window.chatContext) return;
|
||||
window.chatContext.userJjb = Number(jjb);
|
||||
window.chatContext.myGold = Number(jjb);
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取快捷下注金额数组
|
||||
*/
|
||||
@@ -594,6 +604,8 @@
|
||||
try {
|
||||
const res = await fetch('/baccarat/current');
|
||||
const data = await res.json();
|
||||
// 每次打开或刷新局次信息时,都用服务端最新金币覆盖右上角余额。
|
||||
this.syncUserGold(data.jjb);
|
||||
if (data.round && (data.round.seconds_left || 0) > 0) {
|
||||
this.phase = 'betting';
|
||||
this.roundId = data.round.id;
|
||||
@@ -807,6 +819,9 @@
|
||||
// 再检查是否有正在进行的局
|
||||
const curRes = await fetch('/baccarat/current');
|
||||
const curData = await curRes.json();
|
||||
if (panel) {
|
||||
Alpine.$data(panel).syncUserGold(curData.jjb);
|
||||
}
|
||||
|
||||
if (curData.round && panel) {
|
||||
const round = curData.round;
|
||||
|
||||
Reference in New Issue
Block a user