From 3773cf905bb1a8595fb0476bc9bcd57915c6240f Mon Sep 17 00:00:00 2001 From: lkddi Date: Sat, 25 Apr 2026 08:10:23 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=81=E7=A7=BB=E5=A9=9A=E5=A7=BB=E5=BC=B9?= =?UTF-8?q?=E7=AA=97=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/marriage-status.js | 100 ++++++++++++++++++ .../chat/partials/layout/toolbar.blade.php | 28 ++--- 3 files changed, 118 insertions(+), 14 deletions(-) create mode 100644 resources/js/chat-room/marriage-status.js diff --git a/resources/js/chat-room.js b/resources/js/chat-room.js index 9205612..0469eaf 100644 --- a/resources/js/chat-room.js +++ b/resources/js/chat-room.js @@ -8,6 +8,7 @@ export { bindChatImageUploadControl } from "./chat-room/image-upload.js"; export { bindFriendPanelControls, closeFriendPanel, friendSearch, loadFriends, openFriendPanel } from "./chat-room/friend-panel.js"; export { closeChatImageLightbox, initChatImageLightboxEvents, openChatImageLightbox } from "./chat-room/lightbox.js"; export { bindMobileDrawerControls } from "./chat-room/mobile-drawer.js"; +export { bindMarriageStatusControls } from "./chat-room/marriage-status.js"; export { bindToolbarControls } from "./chat-room/toolbar.js"; export { bindWelcomeMenuControls } from "./chat-room/welcome-menu.js"; export { bindAdminMenuControls } from "./chat-room/admin-menu.js"; @@ -56,6 +57,7 @@ import { bindChatImageUploadControl } from "./chat-room/image-upload.js"; import { bindFriendPanelControls, closeFriendPanel, friendSearch, loadFriends, openFriendPanel } from "./chat-room/friend-panel.js"; import { closeChatImageLightbox, initChatImageLightboxEvents, openChatImageLightbox } from "./chat-room/lightbox.js"; import { bindMobileDrawerControls } from "./chat-room/mobile-drawer.js"; +import { bindMarriageStatusControls } from "./chat-room/marriage-status.js"; import { bindToolbarControls } from "./chat-room/toolbar.js"; import { bindWelcomeMenuControls } from "./chat-room/welcome-menu.js"; import { bindAdminMenuControls } from "./chat-room/admin-menu.js"; @@ -123,6 +125,7 @@ if (typeof window !== "undefined") { submitBaccaratLossCoverEvent, bindBankControls, bindFishingControls, + bindMarriageStatusControls, bindProfileControls, bindShopControls, bindVipControls, @@ -175,6 +178,7 @@ if (typeof window !== "undefined") { bindBaccaratLossCoverAdminControls(); bindBankControls(); bindFishingControls(); + bindMarriageStatusControls(); bindProfileControls(); bindShopControls(); bindVipControls(); diff --git a/resources/js/chat-room/marriage-status.js b/resources/js/chat-room/marriage-status.js new file mode 100644 index 0000000..dbe321b --- /dev/null +++ b/resources/js/chat-room/marriage-status.js @@ -0,0 +1,100 @@ +// 婚姻状态弹窗基础事件绑定,替代 toolbar 婚姻区域内联 onclick。 + +let marriageStatusEventsBound = false; + +/** + * 调用婚姻系统存量全局函数。 + * + * @param {string} functionName 全局函数名 + * @param {...unknown} args 参数 + * @returns {void} + */ +function callMarriageGlobal(functionName, ...args) { + if (typeof window[functionName] === "function") { + window[functionName](...args); + } +} + +/** + * 从分页文本解析当前页码。 + * + * @returns {number} + */ +function resolveCurrentMarriedPage() { + const pageInfo = document.getElementById("married-page-info")?.textContent || "1 / 1"; + const currentPage = Number.parseInt(pageInfo.split("/")[0]?.trim() || "1", 10); + + return Number.isInteger(currentPage) && currentPage > 0 ? currentPage : 1; +} + +/** + * 绑定婚姻弹窗 tab、分页、用户名片和状态操作按钮事件。 + * + * @returns {void} + */ +export function bindMarriageStatusControls() { + if (marriageStatusEventsBound || typeof document === "undefined") { + return; + } + + marriageStatusEventsBound = true; + document.addEventListener("click", (event) => { + if (!(event.target instanceof Element)) { + return; + } + + const tabButton = event.target.closest("[data-marriage-tab]"); + if (tabButton) { + event.preventDefault(); + callMarriageGlobal("switchMarriageTab", tabButton.getAttribute("data-marriage-tab") || ""); + return; + } + + if (event.target.closest("[data-marriage-modal-close]")) { + event.preventDefault(); + callMarriageGlobal("closeMarriageStatusModal"); + return; + } + + const pageButton = event.target.closest("[data-marriage-page-delta]"); + if (pageButton) { + event.preventDefault(); + + // 分页状态仍由存量脚本维护,这里从页面文本推导目标页。 + const delta = Number.parseInt(pageButton.getAttribute("data-marriage-page-delta") || "0", 10); + callMarriageGlobal("fetchMarriedList", resolveCurrentMarriedPage() + delta); + return; + } + + const userCard = event.target.closest("[data-marriage-user-card]"); + if (userCard) { + event.preventDefault(); + callMarriageGlobal("openUserCard", userCard.getAttribute("data-marriage-user-card") || ""); + return; + } + + const actionButton = event.target.closest("[data-marriage-action]"); + if (actionButton) { + event.preventDefault(); + + // 接受/拒绝沿用原 marriageAction,按钮可声明完成后关闭弹窗。 + const marriageId = actionButton.getAttribute("data-marriage-id") || ""; + const action = actionButton.getAttribute("data-marriage-action") || ""; + callMarriageGlobal("marriageAction", marriageId, action); + + if (actionButton.getAttribute("data-marriage-close-after-action") === "1") { + callMarriageGlobal("closeMarriageStatusModal"); + } + + return; + } + + const divorceButton = event.target.closest("[data-marriage-divorce]"); + if (!divorceButton) { + return; + } + + event.preventDefault(); + callMarriageGlobal("tryDivorce", divorceButton.getAttribute("data-marriage-divorce") || ""); + }); +} diff --git a/resources/views/chat/partials/layout/toolbar.blade.php b/resources/views/chat/partials/layout/toolbar.blade.php index 0ee425f..50c6633 100644 --- a/resources/views/chat/partials/layout/toolbar.blade.php +++ b/resources/views/chat/partials/layout/toolbar.blade.php @@ -2029,11 +2029,11 @@ async function generateWechatBindCode() {
💍 婚姻系统
- - + +
- @@ -2051,9 +2051,9 @@ async function generateWechatBindCode() {
加载中…
- + 1 / 1 - +
@@ -2155,12 +2155,12 @@ async function generateWechatBindCode() { return `
-
+
${user.username}
💖
-
+
${partner.username}
@@ -2205,7 +2205,7 @@ async function generateWechatBindCode() {
`; footer.innerHTML = ` - - `; } else { footer.innerHTML = ` - - `; }