张延森 3 年之前
父節點
當前提交
22e47083a8

二進制
src/assets/indexImg/loading.png 查看文件


二進制
src/assets/indexImg/loadingBgc.jpg 查看文件


二進制
src/assets/indexImg/loading_bar.png 查看文件


public/images/paused.png → src/assets/indexImg/paused.png 查看文件


public/images/play.png → src/assets/indexImg/play.png 查看文件


+ 50
- 4
src/components/BgMusic.vue 查看文件

1
 <template>
1
 <template>
2
-  <div class="bg-music">
3
-
2
+  <div class="bg-music" :class="{ ['icon-playing']: playing }" @click="handleClick" v-show="show">
3
+    <audio :src="url" ref="audioRef" loop @canplay="show = true" @play="handlePlay"></audio>
4
   </div>
4
   </div>
5
 </template>
5
 </template>
6
 
6
 
11
     const { origin, pathname } = window.location
11
     const { origin, pathname } = window.location
12
 
12
 
13
     return {
13
     return {
14
+      show: false,
15
+      playing: false,
14
       url: `${origin}${pathname}/bg.mp3`
16
       url: `${origin}${pathname}/bg.mp3`
15
     }
17
     }
18
+  },
19
+  mounted() {
20
+    document.body.addEventListener("click", this.handleClick);
21
+  },
22
+  methods: {
23
+    handleClick() {
24
+      if (!this.show || !this.$refs.audioRef) return;
25
+
26
+      if (this.playing) {
27
+        this.$refs.audioRef.pause();
28
+      } else {
29
+        this.$refs.audioRef.play();
30
+      }
31
+
32
+      this.playing = !this.playing
33
+    },
34
+
35
+    handlePlay() {
36
+      document.body.removeEventListener("click", this.handleClick);
37
+    }
16
   }
38
   }
17
 }
39
 }
18
 </script>
40
 </script>
19
 
41
 
20
 <style lang="less" scoped>
42
 <style lang="less" scoped>
21
 .bg-music {
43
 .bg-music {
22
-  width: 64px;
23
-  height: 64px;
44
+  position: fixed;
45
+  top: 1em;
46
+  right: 1em;
47
+  z-index: 10;
48
+
49
+  width: 2em;
50
+  height: 2em;
51
+  background-image: url('~@/assets/indexImg/play.png');
52
+  background-repeat: no-repeat;
53
+  background-size: 100% 100%;
54
+
55
+  &.icon-playing {
56
+    background-image: url('~@/assets/indexImg/paused.png');
57
+    animation: musicrotate 3s linear infinite;
58
+  }
59
+
60
+  & > audio {
61
+    max-width: 1px;
62
+    max-height: 1px;
63
+  }
64
+}
65
+
66
+@keyframes musicrotate {
67
+  100% {
68
+    transform: rotate(360deg);
69
+  }
24
 }
70
 }
25
 </style>
71
 </style>

+ 3
- 1
src/pages/Honghe.vue 查看文件

1
 <template>
1
 <template>
2
   <div class="index-box">
2
   <div class="index-box">
3
+    <bg-music />
3
     <popup :show="showPopup" @cancel="cancelFrom" :current-month="currentMonth" />
4
     <popup :show="showPopup" @cancel="cancelFrom" :current-month="currentMonth" />
4
     <MyWinning :show="showMyWinning" :current-month="currentMonth" />
5
     <MyWinning :show="showMyWinning" :current-month="currentMonth" />
5
     <img class="topImage" src="../assets/indexImg/indexBgctop.jpg" alt />
6
     <img class="topImage" src="../assets/indexImg/indexBgctop.jpg" alt />
143
   components: {
144
   components: {
144
     Popup: () => import('@/components/Popup.vue'),
145
     Popup: () => import('@/components/Popup.vue'),
145
     WinningPopup: () => import('@/components/WinningPopup.vue'),
146
     WinningPopup: () => import('@/components/WinningPopup.vue'),
146
-    ImgBox: () => import('@/components/imgbox.vue')
147
+    ImgBox: () => import('@/components/imgbox.vue'),
148
+    BgMusic: () => import('@/components/BgMusic.vue'),
147
   },
149
   },
148
   data() {
150
   data() {
149
     return {
151
     return {