迁移节日福利领取事件
This commit is contained in:
@@ -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") || "");
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user