From d7c6e0e7a8086d3b3c3c9bcf035414afad6c57c6 Mon Sep 17 00:00:00 2001 From: lkddi Date: Sun, 1 Mar 2026 18:08:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=98=E6=9B=B4=EF=BC=9A=E6=B1=82=E5=A9=9A?= =?UTF-8?q?=E5=8F=8A=E7=A6=BB=E5=A9=9A=E5=BC=B9=E7=AA=97=E5=9C=A8=E6=9C=89?= =?UTF-8?q?=E6=95=88=E6=9C=9F=E5=86=85=E9=87=8D=E6=96=B0=E5=88=B7=E6=96=B0?= =?UTF-8?q?=E5=BF=85=E7=8E=B0=EF=BC=8C=E5=B9=B6=E7=A7=BB=E9=99=A4=E5=85=A8?= =?UTF-8?q?=E5=B1=80=E6=8F=90=E7=A4=BA=E6=A1=86=E7=9A=84=E7=82=B9=E5=87=BB?= =?UTF-8?q?=E8=83=8C=E6=99=AF=E8=92=99=E5=B1=82=E5=85=B3=E9=97=AD=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E5=BC=BA=E5=88=B6=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/ChatController.php | 39 +++++++++++++++++++ resources/views/chat/frame.blade.php | 23 ++++++++++- .../chat/partials/global-dialog.blade.php | 7 ---- 3 files changed, 61 insertions(+), 8 deletions(-) diff --git a/app/Http/Controllers/ChatController.php b/app/Http/Controllers/ChatController.php index 9d3fa8d..54e140d 100644 --- a/app/Http/Controllers/ChatController.php +++ b/app/Http/Controllers/ChatController.php @@ -198,6 +198,43 @@ class ChatController extends Controller // 8. 好友上线通知:向此房间内在线的好友推送慧慧话 $this->notifyFriendsOnline($id, $user->username); + // 9. 检查是否有未处理的求婚 + $pendingProposal = \App\Models\Marriage::with(['user', 'ringItem']) + ->where('partner_id', $user->id) + ->where('status', 'pending') + ->first(); + + $pendingProposalData = null; + if ($pendingProposal) { + $pendingProposalData = [ + 'marriage_id' => $pendingProposal->id, + 'proposer_name' => $pendingProposal->user?->username ?? '', + 'ring_name' => $pendingProposal->ringItem?->name ?? '', + 'ring_icon' => $pendingProposal->ringItem?->icon ?? '', + 'expires_at' => $pendingProposal->expires_at?->diffForHumans() ?? '', + ]; + } + + // 10. 检查是否有未处理的协议离婚请求(对方发起的) + $pendingDivorce = \App\Models\Marriage::with(['user', 'partner']) + ->where('status', 'married') + ->where('divorce_type', 'mutual') + ->whereNotNull('divorcer_id') + ->where('divorcer_id', '!=', $user->id) + ->where(function($q) use ($user) { + $q->where('user_id', $user->id)->orWhere('partner_id', $user->id); + }) + ->first(); + + $pendingDivorceData = null; + if ($pendingDivorce) { + $initiator = $pendingDivorce->user_id === $pendingDivorce->divorcer_id ? $pendingDivorce->user : $pendingDivorce->partner; + $pendingDivorceData = [ + 'marriage_id' => $pendingDivorce->id, + 'initiator_name' => $initiator?->username ?? '', + ]; + } + // 渲染主聊天框架视图 return view('chat.frame', [ 'room' => $room, @@ -205,6 +242,8 @@ class ChatController extends Controller 'weekEffect' => $this->shopService->getActiveWeekEffect($user), 'newbieEffect' => $newbieEffect, 'historyMessages' => $historyMessages, + 'pendingProposal' => $pendingProposalData, + 'pendingDivorce' => $pendingDivorceData, ]); } diff --git a/resources/views/chat/frame.blade.php b/resources/views/chat/frame.blade.php index 3ced5f4..14f0b7d 100644 --- a/resources/views/chat/frame.blade.php +++ b/resources/views/chat/frame.blade.php @@ -165,7 +165,6 @@ }); @endif - {{-- 进房特效自动播放:新人烟花礼包 / 周卡特效 --}} @if (!empty($newbieEffect) || !empty($weekEffect)) @endif + {{-- 页面初始加载时,若存在挂起的求婚 / 离婚请求,则弹窗 --}} + @if (!empty($pendingProposal) || !empty($pendingDivorce)) + + @endif + diff --git a/resources/views/chat/partials/global-dialog.blade.php b/resources/views/chat/partials/global-dialog.blade.php index dd8ee82..0781458 100644 --- a/resources/views/chat/partials/global-dialog.blade.php +++ b/resources/views/chat/partials/global-dialog.blade.php @@ -180,11 +180,4 @@ }, }; })(); - - // 点击遮罩层关闭(等同点取消) - document.getElementById('global-dialog-modal').addEventListener('click', function(e) { - if (e.target === this) { - window.chatDialog._cancel(); - } - });