Commit 9cc50a83 by Lays-lzq

feat: 修复大转盘列表异常洗牌问题

parent 52d2fb63
......@@ -214,7 +214,8 @@ export default {
id: 0, // 中奖等级
name: '谢谢参与' // 中奖等级
}, // 中奖信息
randomType: Math.floor(Math.random() * (2 - 1 + 1)) + 1 // 部分抽奖类型随机进1或2
randomType: Math.floor(Math.random() * (2 - 1 + 1)) + 1, // 部分抽奖类型随机进1或2
formattedPrizeList: []
}
},
computed: {
......@@ -228,13 +229,8 @@ export default {
prizeList() {
return this.lotteryInfo.prizeConfigs
},
formattedPrizeList() {
const prizeLen = this.lotteryInfo?.prizeConfigs?.length || 0
if (prizeLen >= 6 && prizeLen % 2 === 0) {
const freePrizes = new Array(2).fill({ id: 0, name: '谢谢参与' })
return [...this.lotteryInfo.prizeConfigs, ...freePrizes]
}
return this.lotteryInfo.prizeConfigs
prizeLen() {
return this.prizeList.length
},
isNotStart() {
// 抽奖不在活动日期内
......@@ -251,7 +247,25 @@ export default {
return ''
},
},
watch: {
prizeLen(nVal, oVal) {
if (nVal === oVal) {
return
}
if (this.nVal >= 6 && this.nVal % 2 === 0) {
const freePrizes = new Array(2).fill({ id: 0, name: '谢谢参与' })
this.formattedPrizeList = [...this.lotteryInfo.prizeConfigs, ...freePrizes]
}
this.formattedPrizeList = this.lotteryInfo.prizeConfigs
}
},
mounted() {
if (this.prizeLen >= 6 && this.prizeLen % 2 === 0) {
const freePrizes = new Array(2).fill({ id: 0, name: '谢谢参与' })
this.formattedPrizeList = [...this.lotteryInfo.prizeConfigs, ...freePrizes]
}else {
this.formattedPrizeList = this.lotteryInfo.prizeConfigs
}
// this.lotteryInfo.showType = 4
Bus.$on('updateMain', data => {
for (const [key, value] of Object.entries(data)) {
......
......@@ -30,7 +30,7 @@ export const mutations = {
},
SET_ISSHOWBIND: (state, isShow) => {
state.isShowBind = isShow
}
},
}
export const actions = {
......@@ -70,9 +70,9 @@ export const actions = {
}
})
},
updateInfo({ state }, val) {
updateInfo({ commit, state }, val) {
// const lotteryInfo = cloneDeep(state.lotteryInfo)
state.lotteryInfo = { ...state.lotteryInfo, ...val }
commit('SET_LOTTERYINFO', { ...state.lotteryInfo, ...val })
},
}
export const getters = {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment