From de731b9c1595a30ce2f990788b78979a73aeff9f Mon Sep 17 00:00:00 2001 From: zpc Date: Wed, 9 Apr 2025 03:28:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=96=B0=E7=9A=84=E6=8A=BD?= =?UTF-8?q?=E5=A5=96=E5=8A=A8=E7=94=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/other/prize_draw.vue | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/pages/other/prize_draw.vue b/pages/other/prize_draw.vue index dee9a9f..b838a44 100644 --- a/pages/other/prize_draw.vue +++ b/pages/other/prize_draw.vue @@ -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次保持高速