添加新的抽奖动画

This commit is contained in:
zpc 2025-04-09 03:28:46 +08:00
parent 154b8cfa19
commit de731b9c15

View File

@ -42,6 +42,13 @@ export default {
times: 0, //
targetIndex: 0, //
isFinalWin: false, //
animationType: 1, // 1=2=8
path8Index: 0, // 8
animationTypes: {
SEQUENTIAL: 1, //
FIGURE_EIGHT: 2 // 8
},
pathFigureEight: [0, 1, 2, 5, 4, 3, 6, 7, 8, 5, 4, 3], // 8
};
},
methods: {
@ -59,6 +66,15 @@ export default {
//
this.times = 0;
this.speed = 100;
this.path8Index = 0;
// 1-2
this.animationType = Math.floor(Math.random() * 2) + 1;
let animationName = "顺序遍历";
if (this.animationType === this.animationTypes.FIGURE_EIGHT) {
animationName = "8字形";
}
console.log('抽奖动画类型:', animationName);
// 0-8
this.targetIndex = Math.floor(Math.random() * 9);
@ -71,8 +87,15 @@ export default {
this.timer = setInterval(() => {
this.times++;
//
this.currentIndex = (this.currentIndex + 1) % 9;
//
if (this.animationType === this.animationTypes.SEQUENTIAL) {
//
this.currentIndex = (this.currentIndex + 1) % 9;
} else {
// 8
this.path8Index = (this.path8Index + 1) % this.pathFigureEight.length;
this.currentIndex = this.pathFigureEight[this.path8Index];
}
//
if (this.times > 20) { // 20