变更:修复求婚同意消息未收到问题,重构求婚流程支持直接选婚礼档位
This commit is contained in:
@@ -77,19 +77,19 @@ export function initChat(roomId) {
|
||||
);
|
||||
})
|
||||
// ─── 婚姻系统:全局事件(广播给整个房间) ────────────────
|
||||
.listen("MarriageAccepted", (e) => {
|
||||
.listen(".marriage.accepted", (e) => {
|
||||
console.log("结婚公告:", e);
|
||||
window.dispatchEvent(
|
||||
new CustomEvent("chat:marriage-accepted", { detail: e }),
|
||||
);
|
||||
})
|
||||
.listen("MarriageDivorced", (e) => {
|
||||
.listen(".marriage.divorced", (e) => {
|
||||
console.log("离婚公告:", e);
|
||||
window.dispatchEvent(
|
||||
new CustomEvent("chat:marriage-divorced", { detail: e }),
|
||||
);
|
||||
})
|
||||
.listen("WeddingCelebration", (e) => {
|
||||
.listen(".wedding.celebration", (e) => {
|
||||
console.log("婚礼庆典:", e);
|
||||
window.dispatchEvent(
|
||||
new CustomEvent("chat:wedding-celebration", { detail: e }),
|
||||
|
||||
@@ -114,36 +114,46 @@
|
||||
</template>
|
||||
</div>
|
||||
|
||||
{{-- ── 婚礼费用提示面板 ── --}}
|
||||
{{-- ── 婚礼档位选择与费用提示面板 ── --}}
|
||||
@php
|
||||
$minWedding = (int) \App\Models\WeddingTier::where('is_active', true)
|
||||
->orderBy('amount')
|
||||
->value('amount');
|
||||
$activeTiers = \App\Models\WeddingTier::where('is_active', true)->orderBy('amount')->get();
|
||||
@endphp
|
||||
@if ($minWedding > 0)
|
||||
<div style="margin-bottom:14px;">
|
||||
@php $canAfford = ($user->jjb >= $minWedding); @endphp
|
||||
<div style="margin-bottom:14px; text-align:left;">
|
||||
<div style="display:flex; align-items:center; gap:8px; margin-bottom:8px;">
|
||||
<div
|
||||
style="border-radius:12px; padding:12px 14px; font-size:12px; line-height:1.7;
|
||||
background:{{ $canAfford ? '#f0fdf4' : '#fef2f2' }};
|
||||
border:1.5px solid {{ $canAfford ? '#bbf7d0' : '#fecaca' }};">
|
||||
<div
|
||||
style="font-weight:700; color:{{ $canAfford ? '#15803d' : '#dc2626' }}; margin-bottom:4px;">
|
||||
{{ $canAfford ? '✅ 您的金币可以举办婚礼' : '⚠️ 金币可能不足以举办婚礼' }}
|
||||
</div>
|
||||
<div style="color:#6b7280;">
|
||||
结婚最低花费:<strong style="color:#f43f5e;">🪙 {{ number_format($minWedding) }}</strong>
|
||||
金币
|
||||
</div>
|
||||
<div style="color:#{{ $canAfford ? '15803d' : 'dc2626' }};">
|
||||
当前余额:<strong>🪙 {{ number_format($user->jjb) }}</strong> 金币
|
||||
</div>
|
||||
@if (!$canAfford)
|
||||
<div style="color:#9ca3af; font-size:11px; margin-top:4px;">可先求婚,婚礼设置时再准备金币</div>
|
||||
@endif
|
||||
style="width:3px; height:14px; background:linear-gradient(#f59e0b,#d97706); border-radius:2px;">
|
||||
</div>
|
||||
<span style="font-size:12px; font-weight:700; color:#4b5563;">预设婚礼档位</span>
|
||||
</div>
|
||||
<select x-model="selectedTierId"
|
||||
style="width:100%; padding:8px 10px; border-radius:8px; border:1px solid #d1d5db; background:#fff; font-size:13px; color:#1f2937; margin-bottom:10px;">
|
||||
<option value="">(不举办撒红包婚礼)</option>
|
||||
<template x-for="tier in tiers" :key="tier.id">
|
||||
<option :value="tier.id" x-text="`${tier.icon} ${tier.name} (🪙 ${tier.amount})`">
|
||||
</option>
|
||||
</template>
|
||||
</select>
|
||||
|
||||
<div x-show="selectedTier" x-transition
|
||||
style="border-radius:12px; padding:12px 14px; font-size:12px; line-height:1.7; transition:all .2s;"
|
||||
:style="canAfford ? 'background:#f0fdf4; border:1.5px solid #bbf7d0;' :
|
||||
'background:#fef2f2; border:1.5px solid #fecaca;'">
|
||||
<div style="font-weight:700; margin-bottom:4px;"
|
||||
:style="canAfford ? 'color:#15803d' : 'color:#dc2626'"
|
||||
x-text="canAfford ? '✅ 您的金币足以预定该婚礼' : '⚠️ 金币不足,请降低档位或准备金币'">
|
||||
</div>
|
||||
<div style="color:#6b7280;">
|
||||
婚礼预冻结:<strong style="color:#f43f5e;"
|
||||
x-text="'🪙 ' + (selectedTier ? Number(selectedTier.amount).toLocaleString() : 0)"></strong>
|
||||
金币
|
||||
</div>
|
||||
<div :style="canAfford ? 'color:#15803d' : 'color:#dc2626'">
|
||||
当前余额:<strong>🪙 {{ number_format($user->jjb) }}</strong> 金币
|
||||
</div>
|
||||
<div style="color:#9ca3af; font-size:11px; margin-top:4px;">需男方独自承担预冻结金币,对方同意后即刻举行。被拒则全额退回!
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
{{-- 底部按钮:样式修复并参照大卡片弹窗 --}}
|
||||
<div style="display:flex; gap:12px;">
|
||||
@@ -154,9 +164,10 @@
|
||||
onmouseover="this.style.background='#e2e8f0'" onmouseout="this.style.background='#f1f5f9'">
|
||||
✕ 取消
|
||||
</button>
|
||||
<button x-on:click="doPropose()" :disabled="sending || !selectedRing || rings.length === 0"
|
||||
<button x-on:click="doPropose()"
|
||||
:disabled="sending || !selectedRing || rings.length === 0 || !canAfford"
|
||||
style="flex:1; padding:10px 0; border-radius:8px; font-size:13px; font-weight:bold; border:none; transition:all .2s;"
|
||||
:style="(sending || !selectedRing || rings.length === 0) ?
|
||||
:style="(sending || !selectedRing || rings.length === 0 || !canAfford) ?
|
||||
{ background: '#f1f5f9', color: '#94a3b8', cursor: 'not-allowed', boxShadow: 'none' } :
|
||||
{ background: 'linear-gradient(135deg,#be185d,#f43f5e,#ec4899)', color: '#fff',
|
||||
cursor: 'pointer', boxShadow: '0 4px 12px rgba(244,63,94,0.3)' }">
|
||||
@@ -457,10 +468,22 @@
|
||||
marriageId: null, // 当前对方婚姻/求婚记录 ID(accept/reject 用)
|
||||
rings: [],
|
||||
selectedRing: null,
|
||||
tiers: @json(\App\Models\WeddingTier::where('is_active', true)->orderBy('amount')->get()),
|
||||
selectedTierId: '',
|
||||
loading: false,
|
||||
sending: false,
|
||||
error: '',
|
||||
|
||||
get selectedTier() {
|
||||
if (!this.selectedTierId) return null;
|
||||
return this.tiers.find(t => t.id == this.selectedTierId);
|
||||
},
|
||||
|
||||
get canAfford() {
|
||||
const amount = this.selectedTier ? Number(this.selectedTier.amount) : 0;
|
||||
return window.chatContext.userJjb >= amount;
|
||||
},
|
||||
|
||||
async open(username) {
|
||||
this.targetUsername = username;
|
||||
this.selectedRing = null;
|
||||
@@ -520,6 +543,7 @@
|
||||
body: JSON.stringify({
|
||||
target_username: this.targetUsername,
|
||||
ring_purchase_id: this.selectedRing,
|
||||
wedding_tier_id: this.selectedTierId || null,
|
||||
room_id: window.chatContext.roomId
|
||||
})
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user