fix: 连续点击按钮数据报错

This commit is contained in:
ex_zhangwenlei@exiot.cmcc
2024-01-19 22:02:05 +08:00
parent 44a35a504f
commit 9a44f2819e
3 changed files with 79 additions and 82 deletions

View File

@@ -83,15 +83,9 @@ return state.prizeConfig.prizeList;
},
// 更新奖项数据
updatePrizeConfig(prizeConfigItem: IPrizeConfig) {
// const index = this.prizeConfig.prizeList.findIndex(item => item.id === prizeConfigItem.id);
// this.prizeConfig.prizeList[index] = prizeConfigItem;
// if(prizeConfigItem.isUsed&&index+1<this.prizeConfig.prizeList.length){
// // 设置下一个为currentPrize
// this.setCurrentPrize(this.prizeConfig.prizeList[index+1]);
// }
if(prizeConfigItem.isUsed&&this.prizeConfig.prizeList.length){
// 设置下一个为currentPrize
for(let i=0;i<this.prizeConfig.prizeList.length;i++){
const prizeListLength=this.prizeConfig.prizeList.length;
if(prizeConfigItem.isUsed&&prizeListLength){
for(let i=0;i<prizeListLength;i++){
if(!this.prizeConfig.prizeList[i].isUsed){
this.setCurrentPrize(this.prizeConfig.prizeList[i]);
break;

View File

@@ -44,7 +44,6 @@ const submitTemporaryPrize = () => {
temporaryPrize.value.isShow = true
temporaryPrize.value.id=new Date().getTime().toString()
prizeConfig.setCurrentPrize(temporaryPrize.value)
prizeConfig.setCurrentPrize(temporaryPrize.value)
}
onMounted(() => {
prizeListContainerRef.value.style.height = getPrizeListHeight() + 'px'

View File

@@ -255,8 +255,6 @@ return new Promise((resolve) => {
resolve('')
});
})
// 整体自动旋转
}
function onWindowResize() {
camera.value.aspect = window.innerWidth / window.innerHeight
@@ -303,7 +301,6 @@ function rollBall(rotateY: number, duration: number) {
})
.onComplete(() => {
resolve('')
canOperate.value = true
})
})
}
@@ -333,7 +330,7 @@ function resetCamera() {
.onUpdate(render)
.start()
.onComplete(() => {
canOperate.value = true // 相机恢复原位
canOperate.value = true
// camera.value.lookAt(scene.value.position)
camera.value.position.y = 0
camera.value.position.x = 0
@@ -372,7 +369,7 @@ const startLottery = () => {
return
}
// 验证是否已抽完全部奖项
if (currentPrize.value.isUsed) {
if (currentPrize.value.isUsed||!currentPrize.value) {
toast.open({
message: '抽奖抽完了',
type: 'warning',
@@ -405,11 +402,10 @@ const stopLottery = async () => {
clearInterval(intervalTimer.value)
intervalTimer.value = null
canOperate.value = false
// TWEEN.removeAll();
rollBall(0, 1)
// 抽奖池是否为全体人员
// personPool=currentPrize.value.isAll ? notThisPrizePersonList.value : notPersonList.value
// 每次最多抽十个
luckyCount.value = 10
const leftover = currentPrize.value.count - currentPrize.value.isUsedCount
leftover < luckyCount.value ? luckyCount.value = leftover : luckyCount
if (personPool.value.length < leftover) {
@@ -446,6 +442,10 @@ const stopLottery = async () => {
item.element = useElementStyle(item.element, person, cardIndex, patternList.value, patternColor.value, luckyColor.value, { width: cardSize.value.width * 2, height: cardSize.value.height * 2 }, textSize.value * 2, 'lucky')
})
.start()
.onComplete(() => {
canOperate.value = true
currentStatus.value = 3
})
new TWEEN.Tween(item.rotation)
.to({
x: 0,
@@ -459,23 +459,21 @@ const stopLottery = async () => {
resetCamera()
})
})
currentStatus.value = 3
}
// 继续
const continueLottery = async () => {
if (!canOperate.value) {
return
}
currentPrize.value.isUsedCount += luckyCount.value
luckyCount.value = 0
if (currentPrize.value.isUsedCount >= currentPrize.value.count) {
currentPrize.value.isUsed = true
currentPrize.value.isUsedCount = currentPrize.value.count
}
personConfig.addAlreadyPersonList(luckyTargets.value, currentPrize.value)
prizeConfig.updatePrizeConfig(currentPrize.value)
prizeConfig.setCurrentPrize(currentPrize.value)
luckyCount.value = 10
await enterLottery()
// startLottery()
currentStatus.value = 1
}
const quitLottery = () => {
enterLottery()
@@ -659,10 +657,12 @@ onUnmounted(() => {
margin: 0 auto;
font-size: 32px;
}
.header-title {
-webkit-animation: tracking-in-expand-fwd 0.8s cubic-bezier(0.215, 0.610, 0.355, 1.000) both;
animation: tracking-in-expand-fwd 0.8s cubic-bezier(0.215, 0.610, 0.355, 1.000) both;
}
.start {
// 居中
display: flex;
@@ -951,6 +951,7 @@ strong {
transform: scale(1);
}
}
@-webkit-keyframes tracking-in-expand-fwd {
0% {
letter-spacing: -0.5em;
@@ -958,15 +959,18 @@ strong {
transform: translateZ(-700px);
opacity: 0;
}
40% {
opacity: 0.6;
}
100% {
-webkit-transform: translateZ(0);
transform: translateZ(0);
opacity: 1;
}
}
@keyframes tracking-in-expand-fwd {
0% {
letter-spacing: -0.5em;
@@ -974,15 +978,15 @@ strong {
transform: translateZ(-700px);
opacity: 0;
}
40% {
opacity: 0.6;
}
100% {
-webkit-transform: translateZ(0);
transform: translateZ(0);
opacity: 1;
}
}
</style>