|
@@ -1,6 +1,9 @@
|
1
|
1
|
<template>
|
2
|
|
- <div ref="el"></div>
|
3
|
|
- <FireWorkListVue :center="center" :raduis="raduis" ref="firesRef" />
|
|
2
|
+ <div ref="el" />
|
|
3
|
+ <FireWorkListVue ref="firesRef" :center="center" :raduis="raduis" />
|
|
4
|
+ <MusicOnce ref="bingoRef" :src="bingoMusic" />
|
|
5
|
+ <MusicOnce ref="failRef" :src="failMusic" />
|
|
6
|
+ <MusicOnce ref="successRef" :src="successMusic" />
|
4
|
7
|
</template>
|
5
|
8
|
|
6
|
9
|
<script setup>
|
|
@@ -23,6 +26,22 @@ const destroyRef = ref()
|
23
|
26
|
const firesRef = ref()
|
24
|
27
|
const router = useRouter()
|
25
|
28
|
const raduis = ref(150)
|
|
29
|
+const path = window.location.origin + window.location.pathname
|
|
30
|
+const bingoMusic = `${path}/music/bingo.mp3`
|
|
31
|
+const failMusic = `${path}/music/fail.mp3`
|
|
32
|
+const successMusic = `${path}/music/bingo.mp3`
|
|
33
|
+
|
|
34
|
+// // 修复一个 two-js bug ,当页面返回的时候, 不能正常渲染
|
|
35
|
+// // 所以这边判断如果第二次进入页面就强制刷新
|
|
36
|
+// const loadSign = localStorage.getItem('loadSign');
|
|
37
|
+// if (loadSign) {
|
|
38
|
+// localStorage.removeItem('loadSign');
|
|
39
|
+// window.location.href = window.location.href;
|
|
40
|
+// }
|
|
41
|
+
|
|
42
|
+const bingoRef = ref()
|
|
43
|
+const failRef = ref()
|
|
44
|
+const successRef = ref()
|
26
|
45
|
|
27
|
46
|
const center = {
|
28
|
47
|
x: document.body.offsetWidth / 2,
|
|
@@ -34,7 +53,7 @@ const gameInit = () => {
|
34
|
53
|
el: el.value,
|
35
|
54
|
center,
|
36
|
55
|
onError: () => {
|
37
|
|
- alert('oo ~')
|
|
56
|
+ failRef.value.play()
|
38
|
57
|
const t = setTimeout(() => {
|
39
|
58
|
localStorage.setItem('loadSign', '1')
|
40
|
59
|
router.push('/OverPage?type=lose')
|
|
@@ -42,22 +61,29 @@ const gameInit = () => {
|
42
|
61
|
}, 1000)
|
43
|
62
|
},
|
44
|
63
|
onSuccess: () => {
|
45
|
|
- gameOver().then((e) => {
|
46
|
|
- firesRef.value.toggle()
|
47
|
|
- // alert('你真牛逼')
|
48
|
|
- const t = setTimeout(() => {
|
49
|
|
- localStorage.setItem('loadSign', '1')
|
50
|
|
- router.push('/OverPage?type=win')
|
51
|
|
- clearTimeout(t)
|
52
|
|
- }, 2000)
|
53
|
|
- })
|
|
64
|
+ successRef.value.play()
|
|
65
|
+ firesRef.value.toggle()
|
|
66
|
+ // alert('你真牛逼')
|
|
67
|
+ const t = setTimeout(() => {
|
|
68
|
+ localStorage.setItem('loadSign', '1')
|
|
69
|
+ router.push('/OverPage?type=win')
|
|
70
|
+ clearTimeout(t)
|
|
71
|
+ }, 2000)
|
54
|
72
|
},
|
55
|
|
- onBingo: () => {}
|
|
73
|
+ onBingo: () => {
|
|
74
|
+ bingoRef.value.play()
|
|
75
|
+ }
|
56
|
76
|
})
|
57
|
77
|
|
58
|
78
|
raduis.value = destroyRef.value.raduis
|
59
|
79
|
}
|
60
|
80
|
|
|
81
|
+onMounted(() => {
|
|
82
|
+ gameInit()
|
|
83
|
+})
|
|
84
|
+
|
|
85
|
+raduis.value = destroyRef.value.raduis
|
|
86
|
+
|
61
|
87
|
onMounted(() => {
|
62
|
88
|
gameStart()
|
63
|
89
|
gameInit()
|