变更:求婚及离婚弹窗在有效期内重新刷新必现,并移除全局提示框的点击背景蒙层关闭功能强制操作
This commit is contained in:
@@ -198,6 +198,43 @@ class ChatController extends Controller
|
|||||||
// 8. 好友上线通知:向此房间内在线的好友推送慧慧话
|
// 8. 好友上线通知:向此房间内在线的好友推送慧慧话
|
||||||
$this->notifyFriendsOnline($id, $user->username);
|
$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', [
|
return view('chat.frame', [
|
||||||
'room' => $room,
|
'room' => $room,
|
||||||
@@ -205,6 +242,8 @@ class ChatController extends Controller
|
|||||||
'weekEffect' => $this->shopService->getActiveWeekEffect($user),
|
'weekEffect' => $this->shopService->getActiveWeekEffect($user),
|
||||||
'newbieEffect' => $newbieEffect,
|
'newbieEffect' => $newbieEffect,
|
||||||
'historyMessages' => $historyMessages,
|
'historyMessages' => $historyMessages,
|
||||||
|
'pendingProposal' => $pendingProposalData,
|
||||||
|
'pendingDivorce' => $pendingDivorceData,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -165,7 +165,6 @@
|
|||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
@endif
|
@endif
|
||||||
{{-- 进房特效自动播放:新人烟花礼包 / 周卡特效 --}}
|
|
||||||
@if (!empty($newbieEffect) || !empty($weekEffect))
|
@if (!empty($newbieEffect) || !empty($weekEffect))
|
||||||
<script>
|
<script>
|
||||||
/**
|
/**
|
||||||
@@ -184,6 +183,28 @@
|
|||||||
</script>
|
</script>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
|
{{-- 页面初始加载时,若存在挂起的求婚 / 离婚请求,则弹窗 --}}
|
||||||
|
@if (!empty($pendingProposal) || !empty($pendingDivorce))
|
||||||
|
<script>
|
||||||
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
|
// 等待短暂延迟以确保 Alpine 和 window.chatDialog 初始化完成
|
||||||
|
setTimeout(() => {
|
||||||
|
@if (!empty($pendingProposal))
|
||||||
|
window.dispatchEvent(new CustomEvent('chat:marriage-proposed', {
|
||||||
|
detail: @json($pendingProposal)
|
||||||
|
}));
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@if (!empty($pendingDivorce))
|
||||||
|
window.dispatchEvent(new CustomEvent('chat:divorce-requested', {
|
||||||
|
detail: @json($pendingDivorce)
|
||||||
|
}));
|
||||||
|
@endif
|
||||||
|
}, 800);
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
@endif
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -180,11 +180,4 @@
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
|
||||||
// 点击遮罩层关闭(等同点取消)
|
|
||||||
document.getElementById('global-dialog-modal').addEventListener('click', function(e) {
|
|
||||||
if (e.target === this) {
|
|
||||||
window.chatDialog._cancel();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user