67 lines
2.0 KiB
JavaScript
67 lines
2.0 KiB
JavaScript
// 商店弹窗基础按钮事件绑定,替代 toolbar 商店区域内联 onclick。
|
|
|
|
let shopControlEventsBound = false;
|
|
|
|
/**
|
|
* 调用商店存量全局函数。
|
|
*
|
|
* @param {string} functionName 全局函数名
|
|
* @returns {void}
|
|
*/
|
|
function callShopGlobal(functionName) {
|
|
// 商店主体逻辑仍在 Blade 全局函数内,这里只把 data 事件桥接到旧函数。
|
|
if (typeof window[functionName] === "function") {
|
|
window[functionName]();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 绑定商店关闭、改名和赠礼对话框按钮事件。
|
|
*
|
|
* @returns {void}
|
|
*/
|
|
export function bindShopControls() {
|
|
if (shopControlEventsBound || typeof document === "undefined") {
|
|
return;
|
|
}
|
|
|
|
shopControlEventsBound = true;
|
|
document.addEventListener("click", (event) => {
|
|
if (!(event.target instanceof Element)) {
|
|
return;
|
|
}
|
|
|
|
// 商店弹窗关闭入口与遮罩关闭逻辑保持同一个旧函数。
|
|
if (event.target.closest("[data-shop-modal-close]")) {
|
|
event.preventDefault();
|
|
callShopGlobal("closeShopModal");
|
|
return;
|
|
}
|
|
|
|
// 改名确认/取消只转发按钮意图,接口请求仍由 Blade 内的 submitRename 处理。
|
|
if (event.target.closest("[data-shop-rename-confirm]")) {
|
|
event.preventDefault();
|
|
callShopGlobal("submitRename");
|
|
return;
|
|
}
|
|
|
|
if (event.target.closest("[data-shop-rename-cancel]")) {
|
|
event.preventDefault();
|
|
callShopGlobal("closeRenameModal");
|
|
return;
|
|
}
|
|
|
|
// 赠礼确认/取消对应单次特效卡流程,先保留旧的弹窗状态管理函数。
|
|
if (event.target.closest("[data-shop-gift-confirm]")) {
|
|
event.preventDefault();
|
|
callShopGlobal("confirmGift");
|
|
return;
|
|
}
|
|
|
|
if (event.target.closest("[data-shop-gift-cancel]")) {
|
|
event.preventDefault();
|
|
callShopGlobal("closeGiftDialog");
|
|
}
|
|
});
|
|
}
|