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(); - } - });