feat(player): 优化赛事详情与串关下注交互
- 合并玩法列表、单选投注单与玩法内确认下单 - 波胆底部确认与核对弹窗;串关底栏固定 - 帮助弹窗与投注单逻辑拆分(详情单关/串关页串关) Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -17,37 +17,40 @@ export const useBetSlipStore = defineStore('betSlip', () => {
|
||||
const mode = ref<'single' | 'parlay'>('single');
|
||||
|
||||
const count = computed(() => items.value.length);
|
||||
const isParlay = computed(() => items.value.length >= 2);
|
||||
const isParlay = computed(() => mode.value === 'parlay' && items.value.length >= 2);
|
||||
|
||||
/** 球赛/详情页:仅单关,且投注单同时只能有 1 项 */
|
||||
function addItem(item: SlipItem) {
|
||||
if (mode.value === 'parlay') items.value = [];
|
||||
mode.value = 'single';
|
||||
|
||||
const existing = items.value.findIndex(
|
||||
(i) => i.selectionId === item.selectionId,
|
||||
);
|
||||
if (existing >= 0) {
|
||||
items.value.splice(existing, 1);
|
||||
if (items.value.length < 2) mode.value = 'single';
|
||||
items.value = [];
|
||||
return;
|
||||
}
|
||||
items.value.push(item);
|
||||
if (items.value.length >= 2) mode.value = 'parlay';
|
||||
items.value = [item];
|
||||
}
|
||||
|
||||
/** 串关:同场只保留一个选项;再次点击已选项则取消 */
|
||||
/** 串关页专用:跨场组合,同场只保留一个选项 */
|
||||
function addParlayLeg(item: SlipItem) {
|
||||
if (mode.value === 'single') items.value = [];
|
||||
mode.value = 'parlay';
|
||||
|
||||
const samePick = items.value.findIndex((i) => i.selectionId === item.selectionId);
|
||||
if (samePick >= 0) {
|
||||
items.value.splice(samePick, 1);
|
||||
if (items.value.length < 2) mode.value = 'single';
|
||||
return;
|
||||
}
|
||||
items.value = items.value.filter((i) => i.matchId !== item.matchId);
|
||||
items.value.push(item);
|
||||
mode.value = items.value.length >= 2 ? 'parlay' : 'single';
|
||||
}
|
||||
|
||||
function removeItem(selectionId: string) {
|
||||
items.value = items.value.filter((i) => i.selectionId !== selectionId);
|
||||
if (items.value.length < 2) mode.value = 'single';
|
||||
if (!items.value.length) mode.value = 'single';
|
||||
}
|
||||
|
||||
function clear() {
|
||||
@@ -59,13 +62,13 @@ export const useBetSlipStore = defineStore('betSlip', () => {
|
||||
items.value.reduce((acc, i) => acc * i.odds, 1),
|
||||
);
|
||||
|
||||
const potentialReturn = computed(() =>
|
||||
mode.value === 'parlay'
|
||||
? stake.value * totalOdds.value
|
||||
: items.value.length === 1
|
||||
? stake.value * items.value[0].odds
|
||||
: 0,
|
||||
);
|
||||
const potentialReturn = computed(() => {
|
||||
if (!items.value.length) return 0;
|
||||
if (mode.value === 'parlay' && items.value.length >= 2) {
|
||||
return stake.value * totalOdds.value;
|
||||
}
|
||||
return stake.value * items.value[0].odds;
|
||||
});
|
||||
|
||||
const hasSameMatch = computed(() => {
|
||||
const matchIds = items.value.map((i) => i.matchId);
|
||||
|
||||
Reference in New Issue
Block a user