feat(抽奖活动页): 修复抽奖问题

This commit is contained in:
hzj 2025-10-22 19:58:39 +08:00
parent caef58fa15
commit 44658c262b

View File

@ -868,9 +868,6 @@ const barrageList = ref([
//
const activity = ref({})
// (8)
const prizes = ref([])
const userInfo = ref({}) //
const userIdentity = ref({}) //
@ -1060,6 +1057,8 @@ const getGridPosition = (index) => {
//
const startLottery = (resultIndex) => {
console.log('开始抽奖动画')
return new Promise((resolve) => {
activeIndex.value = -1
@ -1069,14 +1068,15 @@ const startLottery = (resultIndex) => {
let totalCycles = 1 // 2
const roll = () => {
activeIndex.value = (activeIndex.value + 1) % prizes.value.length
activeIndex.value = (activeIndex.value + 1) % activity.value.prizeList.length
console.log('当前索引:', activeIndex.value)
if (activeIndex.value === resultIndex && speed > 200) {
setTimeout(() => {
resolve() //
}, 500)
} else {
if (activeIndex.value === prizes.value.length - 1) {
if (activeIndex.value === activity.value.prizeList.length - 1) {
currentCycle++
}
//
@ -1084,7 +1084,7 @@ const startLottery = (resultIndex) => {
speed -= 20
} else {
//
if (activeIndex.value === prizes.value.length - 1) {
if (activeIndex.value === activity.value.prizeList.length - 1) {
constantSpeedCycle++
}
if (constantSpeedCycle > 2) {
@ -1110,26 +1110,12 @@ const sweepstakes = async (consecutive) => {
activityId: activity.value.activity.id,
drawCount: consecutive,
}
//
if (consecutive == 1) {
const resOnceDraw = await onceDraw(data)
if (resOnceDraw.status && resOnceDraw.body) {
const resItem = resOnceDraw.body //
const index = activity.value.prizeList.findIndex(
(prize) => prize.prizeName == resItem?.prize.prizeName
) //
console.log('index:', index)
await startLottery(index)
result.value.push(resItem)
}
}
//
else {
const resMultiDraw = await multiDraw(data)
if (resMultiDraw.status && resMultiDraw.body) {
const resDrawList = resMultiDraw.body //
for (let i = 0; i < resDrawList.results.length; i++) {
const resItem = resDrawList.results[i]
try {
//
if (consecutive == 1) {
const resOnceDraw = await onceDraw(data)
if (resOnceDraw.status && resOnceDraw.body) {
const resItem = resOnceDraw.body //
const index = activity.value.prizeList.findIndex(
(prize) => prize.prizeName == resItem?.prize.prizeName
) //
@ -1138,10 +1124,28 @@ const sweepstakes = async (consecutive) => {
result.value.push(resItem)
}
}
//
else {
const resMultiDraw = await multiDraw(data)
if (resMultiDraw.status && resMultiDraw.body) {
const resDrawList = resMultiDraw.body //
for (let i = 0; i < resDrawList.results.length; i++) {
const resItem = resDrawList.results[i]
const index = activity.value.prizeList.findIndex(
(prize) => prize.prizeName == resItem?.prize.prizeName
) //
console.log('index:', index)
await startLottery(index)
result.value.push(resItem)
}
}
}
getTickets() //
resultShow.value = true
isRolling.value = false
} catch (error) {
isRolling.value = false
}
getTickets() //
resultShow.value = true
isRolling.value = false
}
}