This commit is contained in:
zzc
2026-01-16 15:09:19 +08:00
parent 67684572da
commit 9d5b9b6812
6 changed files with 148 additions and 109 deletions

View File

@@ -100,12 +100,28 @@
</template>
<script setup>
import { ref } from "vue";
import { ref, onUnmounted } from "vue";
import { getBavBarHeight } from "@/utils/system";
const status = ref("initial"); // initial, shaking, result
const remainingCount = ref(1);
// 音效控制
const audioContext = uni.createInnerAudioContext();
audioContext.src = "/static/music/shake.mp3";
let playCount = 0;
audioContext.onEnded(() => {
playCount++;
if (playCount < 3) {
audioContext.play();
}
});
onUnmounted(() => {
audioContext.destroy();
});
const fortunes = [
{ title: "好运连连", desc: "2026年你将万事如意惊喜不断。", icon: "☀" },
{ title: "财源滚滚", desc: "正财偏财滚滚来,荷包满满乐开怀。", icon: "💰" },
@@ -132,6 +148,10 @@ const startShake = () => {
status.value = "shaking";
// 播放音效
playCount = 0;
audioContext.play();
// 模拟摇晃动画和数据请求
setTimeout(() => {
const idx = Math.floor(Math.random() * fortunes.length);