迁移节日福利领取事件
This commit is contained in:
@@ -34,6 +34,7 @@ export {
|
||||
export { bindBaccaratLossCoverControls } from "./chat-room/baccarat-loss-cover.js";
|
||||
export { bindGameHallControls } from "./chat-room/game-hall.js";
|
||||
export { bindGamePanelControls } from "./chat-room/game-panels.js";
|
||||
export { bindHolidayModalControls, openHolidayRunFromSystemMessage } from "./chat-room/holiday-modal.js";
|
||||
export {
|
||||
bankAction,
|
||||
bankLoadInfo,
|
||||
@@ -108,6 +109,7 @@ import {
|
||||
import { bindBaccaratLossCoverControls } from "./chat-room/baccarat-loss-cover.js";
|
||||
import { bindGameHallControls } from "./chat-room/game-hall.js";
|
||||
import { bindGamePanelControls } from "./chat-room/game-panels.js";
|
||||
import { bindHolidayModalControls, openHolidayRunFromSystemMessage } from "./chat-room/holiday-modal.js";
|
||||
import {
|
||||
bankAction,
|
||||
bankLoadInfo,
|
||||
@@ -185,6 +187,8 @@ if (typeof window !== "undefined") {
|
||||
bindBaccaratLossCoverControls,
|
||||
bindGameHallControls,
|
||||
bindGamePanelControls,
|
||||
bindHolidayModalControls,
|
||||
openHolidayRunFromSystemMessage,
|
||||
loadAdminCurrentLossCoverEvent,
|
||||
openAdminBaccaratLossCoverModal,
|
||||
submitBaccaratLossCoverEvent,
|
||||
@@ -246,6 +250,7 @@ if (typeof window !== "undefined") {
|
||||
window.switchMobileTab = switchMobileTab;
|
||||
window.runFeatureShortcut = runFeatureShortcut;
|
||||
window.runToolbarAction = runToolbarAction;
|
||||
window.openHolidayRunFromSystemMessage = openHolidayRunFromSystemMessage;
|
||||
window.closeAdminBaccaratLossCoverModal = closeAdminBaccaratLossCoverModal;
|
||||
window.closeCurrentBaccaratLossCoverEvent = closeCurrentBaccaratLossCoverEvent;
|
||||
window.openAdminBaccaratLossCoverModal = openAdminBaccaratLossCoverModal;
|
||||
@@ -273,6 +278,7 @@ if (typeof window !== "undefined") {
|
||||
bindBaccaratLossCoverControls();
|
||||
bindGameHallControls();
|
||||
bindGamePanelControls();
|
||||
bindHolidayModalControls();
|
||||
bindBankControls();
|
||||
bindFishingControls();
|
||||
bindMarriageStatusControls();
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
// 节日福利弹窗事件代理,承接从 Blade 内联 onclick 迁移出的公屏领取入口。
|
||||
|
||||
let holidayModalEventsBound = false;
|
||||
|
||||
/**
|
||||
* 从公屏系统消息中打开已缓存的节日福利批次。
|
||||
*
|
||||
* @param {string|number} runId 福利批次 ID
|
||||
* @returns {void}
|
||||
*/
|
||||
export function openHolidayRunFromSystemMessage(runId) {
|
||||
const normalizedRunId = String(runId || "");
|
||||
const detail = window.__holidayRuns?.[normalizedRunId];
|
||||
const modal = document.getElementById("holiday-event-modal");
|
||||
|
||||
if (!normalizedRunId || !modal || typeof window.Alpine?.$data !== "function") {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!detail) {
|
||||
window.chatDialog?.alert("当前福利批次信息未缓存,请等待下一轮广播或刷新页面后重试。", "提示", "#f59e0b");
|
||||
return;
|
||||
}
|
||||
|
||||
window.Alpine.$data(modal)?.open?.(detail);
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定节日福利公屏按钮点击事件。
|
||||
*
|
||||
* @returns {void}
|
||||
*/
|
||||
export function bindHolidayModalControls() {
|
||||
if (holidayModalEventsBound || typeof document === "undefined") {
|
||||
return;
|
||||
}
|
||||
|
||||
holidayModalEventsBound = true;
|
||||
document.addEventListener("click", (event) => {
|
||||
if (!(event.target instanceof Element)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const claimButton = event.target.closest("[data-holiday-run-id]");
|
||||
if (!claimButton) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
openHolidayRunFromSystemMessage(claimButton.getAttribute("data-holiday-run-id") || "");
|
||||
});
|
||||
}
|
||||
@@ -257,26 +257,20 @@
|
||||
window.__holidayRuns = window.__holidayRuns || {};
|
||||
|
||||
/**
|
||||
* 从公屏系统消息中打开指定节日福利批次弹窗。
|
||||
* 转义按钮属性值,避免福利批次 ID 写入 data 属性时破坏 HTML。
|
||||
*
|
||||
* @param {number|string} runId
|
||||
* @param {number|string} value
|
||||
* @returns {string}
|
||||
*/
|
||||
window.openHolidayRunFromSystemMessage = function(runId) {
|
||||
const normalizedRunId = String(runId);
|
||||
const detail = window.__holidayRuns?.[normalizedRunId];
|
||||
const el = document.getElementById('holiday-event-modal');
|
||||
|
||||
if (!el || typeof Alpine === 'undefined') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!detail) {
|
||||
window.chatDialog?.alert('当前福利批次信息未缓存,请等待下一轮广播或刷新页面后重试。', '提示', '#f59e0b');
|
||||
return;
|
||||
}
|
||||
|
||||
Alpine.$data(el).open(detail);
|
||||
};
|
||||
function escapeHolidayAttribute(value) {
|
||||
return String(value).replace(/[&<>"']/g, (char) => ({
|
||||
'&': '&',
|
||||
'<': '<',
|
||||
'>': '>',
|
||||
'"': '"',
|
||||
"'": ''',
|
||||
})[char]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建公屏系统消息里的领取按钮,便于多个消息场景复用一致视觉。
|
||||
@@ -290,8 +284,10 @@
|
||||
return '';
|
||||
}
|
||||
|
||||
const safeRunId = escapeHolidayAttribute(runId);
|
||||
|
||||
return ` <button type="button"
|
||||
onclick="openHolidayRunFromSystemMessage(${JSON.stringify(String(runId))})"
|
||||
data-holiday-run-id="${safeRunId}"
|
||||
style="display:inline-flex; align-items:center; gap:4px; margin-left:8px; padding:3px 10px; border:none; border-radius:999px; background:linear-gradient(135deg,#f59e0b,#d97706); color:#fff; font-size:12px; font-weight:bold; cursor:pointer; box-shadow:0 2px 6px rgba(0,0,0,.22); vertical-align:middle;"
|
||||
title="点击领取本轮节日福利">${label}</button>`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user