From 37e4c5d4c5d81e40d21915a5eceffa4945a0476a Mon Sep 17 00:00:00 2001 From: lkddi Date: Sat, 25 Apr 2026 08:07:28 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=81=E7=A7=BB=E4=BC=9A=E5=91=98=E4=B8=AD?= =?UTF-8?q?=E5=BF=83=E5=9F=BA=E7=A1=80=E6=8C=89=E9=92=AE=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=E7=BB=91=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/js/chat-room.js | 4 ++ resources/js/chat-room/vip-controls.js | 66 +++++++++++++++++++ .../chat/partials/layout/toolbar.blade.php | 14 ++-- 3 files changed, 77 insertions(+), 7 deletions(-) create mode 100644 resources/js/chat-room/vip-controls.js diff --git a/resources/js/chat-room.js b/resources/js/chat-room.js index 3af944e..8f48ac2 100644 --- a/resources/js/chat-room.js +++ b/resources/js/chat-room.js @@ -22,6 +22,7 @@ export { export { bindFishingControls } from "./chat-room/fishing.js"; export { bindProfileControls } from "./chat-room/profile-controls.js"; export { bindShopControls } from "./chat-room/shop-controls.js"; +export { bindVipControls } from "./chat-room/vip-controls.js"; export { BLOCKABLE_SYSTEM_SENDERS, BLOCKED_SYSTEM_SENDERS_STORAGE_KEY, @@ -68,6 +69,7 @@ import { import { bindFishingControls } from "./chat-room/fishing.js"; import { bindProfileControls } from "./chat-room/profile-controls.js"; import { bindShopControls } from "./chat-room/shop-controls.js"; +import { bindVipControls } from "./chat-room/vip-controls.js"; import { BLOCKABLE_SYSTEM_SENDERS, BLOCKED_SYSTEM_SENDERS_STORAGE_KEY, @@ -120,6 +122,7 @@ if (typeof window !== "undefined") { bindFishingControls, bindProfileControls, bindShopControls, + bindVipControls, CHAT_FONT_SIZE_STORAGE_KEY, restoreChatFontSize, closeChatImageLightbox, @@ -170,6 +173,7 @@ if (typeof window !== "undefined") { bindFishingControls(); bindProfileControls(); bindShopControls(); + bindVipControls(); bindChatRightPanelControls(); bindMobileDrawerControls(); bindWelcomeMenuControls(); diff --git a/resources/js/chat-room/vip-controls.js b/resources/js/chat-room/vip-controls.js new file mode 100644 index 0000000..cfc104f --- /dev/null +++ b/resources/js/chat-room/vip-controls.js @@ -0,0 +1,66 @@ +// 会员中心基础按钮事件绑定,替代 toolbar VIP 区域内联 onclick。 + +let vipControlEventsBound = false; + +/** + * 调用会员中心存量全局函数。 + * + * @param {string} functionName 全局函数名 + * @param {...unknown} args 参数 + * @returns {void} + */ +function callVipGlobal(functionName, ...args) { + if (typeof window[functionName] === "function") { + window[functionName](...args); + } +} + +/** + * 绑定会员中心 tab、关闭、购买与个性化保存事件。 + * + * @returns {void} + */ +export function bindVipControls() { + if (vipControlEventsBound || typeof document === "undefined") { + return; + } + + vipControlEventsBound = true; + document.addEventListener("click", (event) => { + if (!(event.target instanceof Element)) { + return; + } + + const tabButton = event.target.closest("[data-vip-tab]"); + if (tabButton) { + event.preventDefault(); + callVipGlobal("switchVipTab", tabButton.getAttribute("data-vip-tab") || ""); + return; + } + + if (event.target.closest("[data-vip-modal-close]")) { + event.preventDefault(); + callVipGlobal("closeVipModal"); + return; + } + + const buyButton = event.target.closest("[data-vip-buy-level]"); + if (buyButton) { + event.preventDefault(); + + // 购买按钮由 VIP 数据动态渲染,等级和支付渠道从 data 属性读取。 + const levelId = Number.parseInt(buyButton.getAttribute("data-vip-buy-level") || "", 10); + const provider = buyButton.getAttribute("data-vip-buy-provider") || "alipay"; + if (Number.isInteger(levelId)) { + callVipGlobal("buyVip", levelId, provider); + } + + return; + } + + if (event.target.closest("[data-vip-save-presence]")) { + event.preventDefault(); + callVipGlobal("saveVipPresenceSettings"); + } + }); +} diff --git a/resources/views/chat/partials/layout/toolbar.blade.php b/resources/views/chat/partials/layout/toolbar.blade.php index b943a90..7ac6f40 100644 --- a/resources/views/chat/partials/layout/toolbar.blade.php +++ b/resources/views/chat/partials/layout/toolbar.blade.php @@ -1493,11 +1493,11 @@ async function generateWechatBindCode() {
👑 会员中心
- - - + + +
- × + ×
{{-- 会员中心面板 --}} @@ -1589,7 +1589,7 @@ async function generateWechatBindCode() { - +