56 lines
1.7 KiB
JavaScript
56 lines
1.7 KiB
JavaScript
// 百乐加强买单活动前台弹窗事件代理,替代 Blade 内联 onclick。
|
|
|
|
let baccaratLossCoverEventsBound = false;
|
|
|
|
/**
|
|
* 调用买单活动前台存量全局函数。
|
|
*
|
|
* @param {string} functionName 全局函数名
|
|
* @param {...unknown} args 参数
|
|
* @returns {void}
|
|
*/
|
|
function callLossCoverGlobal(functionName, ...args) {
|
|
// 前台弹窗的数据加载、领取接口和金币同步仍由 Blade 旧脚本维护。
|
|
if (typeof window[functionName] === "function") {
|
|
window[functionName](...args);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 绑定买单活动前台弹窗关闭、Tab 切换与领取按钮事件。
|
|
*
|
|
* @returns {void}
|
|
*/
|
|
export function bindBaccaratLossCoverControls() {
|
|
if (baccaratLossCoverEventsBound || typeof document === "undefined") {
|
|
return;
|
|
}
|
|
|
|
baccaratLossCoverEventsBound = true;
|
|
document.addEventListener("click", (event) => {
|
|
if (!(event.target instanceof Element)) {
|
|
return;
|
|
}
|
|
|
|
if (event.target.closest("[data-blc-close]")) {
|
|
event.preventDefault();
|
|
callLossCoverGlobal("closeBaccaratLossCoverModal");
|
|
return;
|
|
}
|
|
|
|
const tabButton = event.target.closest("[data-blc-tab]");
|
|
if (tabButton) {
|
|
event.preventDefault();
|
|
callLossCoverGlobal("switchBaccaratLossCoverTab", tabButton.getAttribute("data-blc-tab") || "overview");
|
|
return;
|
|
}
|
|
|
|
const claimButton = event.target.closest("[data-blc-claim]");
|
|
if (claimButton) {
|
|
event.preventDefault();
|
|
// 动态活动卡片只传活动 ID,领取流程继续复用旧全局函数。
|
|
callLossCoverGlobal("claimBaccaratLossCover", claimButton.getAttribute("data-blc-claim") || "");
|
|
}
|
|
});
|
|
}
|