迁移商店弹窗基础按钮事件绑定
This commit is contained in:
@@ -21,6 +21,7 @@ export {
|
|||||||
} from "./chat-room/baccarat-loss-cover-admin.js";
|
} from "./chat-room/baccarat-loss-cover-admin.js";
|
||||||
export { bindFishingControls } from "./chat-room/fishing.js";
|
export { bindFishingControls } from "./chat-room/fishing.js";
|
||||||
export { bindProfileControls } from "./chat-room/profile-controls.js";
|
export { bindProfileControls } from "./chat-room/profile-controls.js";
|
||||||
|
export { bindShopControls } from "./chat-room/shop-controls.js";
|
||||||
export {
|
export {
|
||||||
BLOCKABLE_SYSTEM_SENDERS,
|
BLOCKABLE_SYSTEM_SENDERS,
|
||||||
BLOCKED_SYSTEM_SENDERS_STORAGE_KEY,
|
BLOCKED_SYSTEM_SENDERS_STORAGE_KEY,
|
||||||
@@ -66,6 +67,7 @@ import {
|
|||||||
} from "./chat-room/baccarat-loss-cover-admin.js";
|
} from "./chat-room/baccarat-loss-cover-admin.js";
|
||||||
import { bindFishingControls } from "./chat-room/fishing.js";
|
import { bindFishingControls } from "./chat-room/fishing.js";
|
||||||
import { bindProfileControls } from "./chat-room/profile-controls.js";
|
import { bindProfileControls } from "./chat-room/profile-controls.js";
|
||||||
|
import { bindShopControls } from "./chat-room/shop-controls.js";
|
||||||
import {
|
import {
|
||||||
BLOCKABLE_SYSTEM_SENDERS,
|
BLOCKABLE_SYSTEM_SENDERS,
|
||||||
BLOCKED_SYSTEM_SENDERS_STORAGE_KEY,
|
BLOCKED_SYSTEM_SENDERS_STORAGE_KEY,
|
||||||
@@ -117,6 +119,7 @@ if (typeof window !== "undefined") {
|
|||||||
submitBaccaratLossCoverEvent,
|
submitBaccaratLossCoverEvent,
|
||||||
bindFishingControls,
|
bindFishingControls,
|
||||||
bindProfileControls,
|
bindProfileControls,
|
||||||
|
bindShopControls,
|
||||||
CHAT_FONT_SIZE_STORAGE_KEY,
|
CHAT_FONT_SIZE_STORAGE_KEY,
|
||||||
restoreChatFontSize,
|
restoreChatFontSize,
|
||||||
closeChatImageLightbox,
|
closeChatImageLightbox,
|
||||||
@@ -166,6 +169,7 @@ if (typeof window !== "undefined") {
|
|||||||
bindBaccaratLossCoverAdminControls();
|
bindBaccaratLossCoverAdminControls();
|
||||||
bindFishingControls();
|
bindFishingControls();
|
||||||
bindProfileControls();
|
bindProfileControls();
|
||||||
|
bindShopControls();
|
||||||
bindChatRightPanelControls();
|
bindChatRightPanelControls();
|
||||||
bindMobileDrawerControls();
|
bindMobileDrawerControls();
|
||||||
bindWelcomeMenuControls();
|
bindWelcomeMenuControls();
|
||||||
|
|||||||
@@ -0,0 +1,62 @@
|
|||||||
|
// 商店弹窗基础按钮事件绑定,替代 toolbar 商店区域内联 onclick。
|
||||||
|
|
||||||
|
let shopControlEventsBound = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 调用商店存量全局函数。
|
||||||
|
*
|
||||||
|
* @param {string} functionName 全局函数名
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
function callShopGlobal(functionName) {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -1066,7 +1066,7 @@ async function generateWechatBindCode() {
|
|||||||
<div id="shop-modal-title">🛍 道具商店</div>
|
<div id="shop-modal-title">🛍 道具商店</div>
|
||||||
<div id="shop-modal-jjb">💰 <strong id="shop-jjb">--</strong> 金币</div>
|
<div id="shop-modal-jjb">💰 <strong id="shop-jjb">--</strong> 金币</div>
|
||||||
<span id="shop-week-badge"></span>
|
<span id="shop-week-badge"></span>
|
||||||
<span id="shop-modal-close" onclick="closeShopModal()">✕</span>
|
<span id="shop-modal-close" data-shop-modal-close>✕</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{-- Toast --}}
|
{{-- Toast --}}
|
||||||
@@ -1083,8 +1083,8 @@ async function generateWechatBindCode() {
|
|||||||
<h4>🎭 使用改名卡</h4>
|
<h4>🎭 使用改名卡</h4>
|
||||||
<input id="rename-input" type="text" maxlength="10" placeholder="输入新昵称(1-10字)">
|
<input id="rename-input" type="text" maxlength="10" placeholder="输入新昵称(1-10字)">
|
||||||
<div class="rename-btn-row">
|
<div class="rename-btn-row">
|
||||||
<button id="rename-confirm" onclick="submitRename()">确认改名</button>
|
<button id="rename-confirm" data-shop-rename-confirm>确认改名</button>
|
||||||
<button id="rename-cancel" onclick="closeRenameModal()">取消</button>
|
<button id="rename-cancel" data-shop-rename-cancel>取消</button>
|
||||||
</div>
|
</div>
|
||||||
<div id="rename-err"></div>
|
<div id="rename-err"></div>
|
||||||
</div>
|
</div>
|
||||||
@@ -1103,9 +1103,9 @@ async function generateWechatBindCode() {
|
|||||||
<input id="gift-message" class="gift-input" type="text" maxlength="50" placeholder="可不填,百字以内">
|
<input id="gift-message" class="gift-input" type="text" maxlength="50" placeholder="可不填,百字以内">
|
||||||
<div id="gift-err"></div>
|
<div id="gift-err"></div>
|
||||||
<div class="rename-btn-row" style="margin-top:8px;">
|
<div class="rename-btn-row" style="margin-top:8px;">
|
||||||
<button onclick="confirmGift()"
|
<button data-shop-gift-confirm
|
||||||
style="flex:1;background:#336699;color:#fff;border:none;border-radius:4px;padding:7px;cursor:pointer;font-size:12px;font-weight:bold;">确认赠出</button>
|
style="flex:1;background:#336699;color:#fff;border:none;border-radius:4px;padding:7px;cursor:pointer;font-size:12px;font-weight:bold;">确认赠出</button>
|
||||||
<button onclick="closeGiftDialog()"
|
<button data-shop-gift-cancel
|
||||||
style="flex:1;background:#eee;color:#555;border:1px solid #ccc;border-radius:4px;padding:7px;cursor:pointer;font-size:12px;">取消</button>
|
style="flex:1;background:#eee;color:#555;border:1px solid #ccc;border-radius:4px;padding:7px;cursor:pointer;font-size:12px;">取消</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user