feat(player): 优化赛事详情与串关下注交互

- 合并玩法列表、单选投注单与玩法内确认下单
- 波胆底部确认与核对弹窗;串关底栏固定
- 帮助弹窗与投注单逻辑拆分(详情单关/串关页串关)

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-03 10:54:49 +08:00
parent 451cc3984a
commit d432de6fdf
12 changed files with 1089 additions and 540 deletions

View File

@@ -29,7 +29,6 @@ async function placeBet() {
success.value = '';
try {
const requestId = genId();
if (slip.mode === 'parlay' && slip.items.length >= 2) {
if (slip.hasSameMatch) {
error.value = t('bet.parlay_same_match');
@@ -41,7 +40,7 @@ async function placeBet() {
oddsVersion: i.oddsVersion,
})),
stake: slip.stake,
requestId,
requestId: genId(),
});
} else if (slip.items.length === 1) {
const item = slip.items[0];
@@ -49,17 +48,21 @@ async function placeBet() {
selectionId: item.selectionId,
oddsVersion: item.oddsVersion,
stake: slip.stake,
requestId,
requestId: genId(),
});
} else {
error.value = t('bet.parlay_need_more');
return;
}
success.value = '下注成功!';
success.value = t('bet.place_success');
slip.clear();
setTimeout(() => { show.value = false; success.value = ''; }, 1500);
setTimeout(() => {
show.value = false;
success.value = '';
}, 1500);
} catch (e: unknown) {
error.value = (e as { response?: { data?: { error?: string } } })?.response?.data?.error || '下注失败';
error.value =
(e as { response?: { data?: { error?: string } } })?.response?.data?.error ||
t('bet.place_failed');
} finally {
loading.value = false;
}
@@ -71,31 +74,46 @@ async function placeBet() {
<div class="drawer">
<div class="drawer-header">
<h3>{{ t('bet.bet_slip') }} <span class="count">({{ slip.count }})</span></h3>
<button class="close-btn" @click="show = false"></button>
<button type="button" class="close-btn" :aria-label="t('bet.cancel')" @click="show = false">
</button>
</div>
<div v-if="!slip.items.length" class="empty">点击赔率添加投注</div>
<div v-if="!slip.items.length" class="empty">{{ t('bet.slip_empty_hint') }}</div>
<div v-for="item in slip.items" :key="item.selectionId" class="slip-item">
<div class="item-name">{{ item.matchName }}</div>
<div class="item-sel">{{ item.selectionName }} @ <span class="odds">{{ item.odds }}</span></div>
<button class="remove" @click="slip.removeItem(item.selectionId)">移除</button>
<div class="item-sel">
{{ item.selectionName }} @ <span class="odds">{{ item.odds }}</span>
</div>
<button type="button" class="remove" @click="slip.removeItem(item.selectionId)">
{{ t('bet.slip_remove') }}
</button>
</div>
<div v-if="slip.hasSameMatch" class="warn">同场比赛不能串关可作为单关分别投注</div>
<p v-if="slip.isParlay" class="mode-hint mode-hint--parlay">
{{ t('bet.parlay') }} · {{ t('bet.slip_parlay_odds', { odds: slip.totalOdds.toFixed(2) }) }}
</p>
<div v-if="slip.items.length" class="stake-area">
<label>{{ t('bet.stake') }}</label>
<input v-model.number="slip.stake" type="number" min="1" />
<div v-if="slip.isParlay" class="mode-tag">{{ t('bet.parlay') }} · 赔率 {{ slip.totalOdds.toFixed(2) }}</div>
<div class="return">预计返还: <strong>{{ slip.potentialReturn.toFixed(2) }}</strong></div>
<div class="return">
{{ t('bet.slip_est_return') }}:
<strong>{{ slip.potentialReturn.toFixed(2) }}</strong>
</div>
</div>
<p v-if="error" class="error">{{ error }}</p>
<p v-if="success" class="success">{{ success }}</p>
<button class="btn-primary" :disabled="loading || !slip.items.length" @click="placeBet">
{{ t('bet.place_bet') }}
<button
type="button"
class="btn-primary"
:disabled="loading || !slip.items.length"
@click="placeBet"
>
{{ loading ? t('bet.placing') : t('bet.place_bet') }}
</button>
</div>
</div>
@@ -103,48 +121,130 @@ async function placeBet() {
<style scoped>
.overlay {
position: fixed; inset: 0;
position: fixed;
inset: 0;
background: rgba(0, 0, 0, 0.75);
z-index: 200;
display: flex; align-items: flex-end;
display: flex;
align-items: flex-end;
}
.drawer {
background: linear-gradient(180deg, #222 0%, #141414 100%);
width: 100%;
max-height: 80vh;
border-radius: 20px 20px 0 0;
padding: 20px 16px calc(20px + env(safe-area-inset-bottom, 0));
border-radius: 16px 16px 0 0;
padding: 14px 14px calc(14px + env(safe-area-inset-bottom, 0));
overflow-y: auto;
border-top: 1px solid var(--border);
box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.35);
}
.drawer-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.drawer-header h3 { font-size: 18px; font-weight: 800; letter-spacing: 0.04em; }
.count { color: var(--primary-light); font-size: 20px; font-weight: 800; }
.close-btn { background: none; color: var(--text-muted); font-size: 22px; padding: 4px; font-weight: 700; }
.drawer-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 12px;
}
.drawer-header h3 {
font-size: 16px;
font-weight: 800;
}
.count {
color: var(--primary-light);
}
.close-btn {
background: none;
color: var(--text-muted);
font-size: 20px;
padding: 4px;
}
.slip-item {
padding: 14px;
padding: 10px 12px;
background: #111;
border: 1px solid var(--border);
border-radius: var(--radius-sm);
margin-bottom: 10px;
border-radius: 6px;
margin-bottom: 8px;
}
.item-name { font-size: 14px; font-weight: 800; }
.item-sel { font-size: 13px; color: var(--text-muted); margin-top: 6px; font-weight: 500; }
.odds { color: var(--primary-light); font-weight: 800; }
.remove { background: none; color: var(--danger); font-size: 13px; margin-top: 8px; font-weight: 700; }
.stake-area { margin: 18px 0; }
.stake-area label { font-size: 13px; color: var(--primary-light); display: block; margin-bottom: 8px; font-weight: 700; letter-spacing: 0.04em; }
.return { font-size: 15px; color: var(--text-muted); margin-top: 12px; font-weight: 600; }
.item-name {
font-size: 13px;
font-weight: 800;
}
.item-sel {
font-size: 12px;
color: var(--text-muted);
margin-top: 4px;
}
.odds {
color: var(--primary-light);
font-weight: 800;
}
.remove {
background: none;
color: var(--danger);
font-size: 12px;
margin-top: 6px;
font-weight: 700;
}
.mode-hint {
font-size: 12px;
color: var(--text-muted);
margin-bottom: 8px;
}
.mode-hint--parlay {
color: var(--primary-light);
font-weight: 700;
}
.stake-area {
margin: 12px 0;
}
.stake-area label {
font-size: 12px;
color: var(--primary-light);
display: block;
margin-bottom: 6px;
font-weight: 700;
}
.return {
font-size: 13px;
color: var(--text-muted);
margin-top: 8px;
}
.return strong {
color: var(--primary-light);
font-size: 22px;
font-size: 18px;
font-weight: 800;
text-shadow: none;
}
.mode-tag { font-size: 13px; color: var(--primary-light); font-weight: 700; margin-top: 8px; }
.warn { color: var(--primary-light); font-size: 13px; margin-bottom: 10px; font-weight: 600; }
.error { color: var(--danger); font-size: 14px; margin-bottom: 8px; font-weight: 600; }
.success { color: var(--primary-light); font-size: 14px; font-weight: 700; margin-bottom: 8px; }
.empty { text-align: center; color: var(--text-muted); padding: 32px; font-weight: 600; }
.error {
color: var(--danger);
font-size: 13px;
margin-bottom: 8px;
}
.success {
color: var(--primary-light);
font-size: 13px;
margin-bottom: 8px;
}
.empty {
text-align: center;
color: var(--text-muted);
padding: 24px;
font-size: 13px;
}
</style>