Explorar el Código

Merge branch 'master' of http://git.ycjcjy.com/honghe/h5-draw-lots

李志伟 hace 3 años
padre
commit
347a2a68da

BIN
src/assets/indexImg/loading.png Ver fichero


BIN
src/assets/indexImg/loadingBgc.jpg Ver fichero


BIN
src/assets/indexImg/loading_bar.png Ver fichero


public/images/paused.png → src/assets/indexImg/paused.png Ver fichero


public/images/play.png → src/assets/indexImg/play.png Ver fichero


+ 50
- 4
src/components/BgMusic.vue Ver fichero

@@ -1,6 +1,6 @@
1 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 4
   </div>
5 5
 </template>
6 6
 
@@ -11,15 +11,61 @@ export default {
11 11
     const { origin, pathname } = window.location
12 12
 
13 13
     return {
14
+      show: false,
15
+      playing: false,
14 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 40
 </script>
19 41
 
20 42
 <style lang="less" scoped>
21 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 71
 </style>

+ 10
- 1
src/pages/Honghe.vue Ver fichero

@@ -1,5 +1,6 @@
1 1
 <template>
2 2
   <div class="index-box">
3
+    <bg-music />
3 4
     <popup
4 5
       :show="showPopup"
5 6
       @cancel="cancelFrom"
@@ -151,7 +152,8 @@ export default {
151 152
   components: {
152 153
     Popup: () => import('@/components/Popup.vue'),
153 154
     WinningPopup: () => import('@/components/WinningPopup.vue'),
154
-    ImgBox: () => import('@/components/imgbox.vue')
155
+    ImgBox: () => import('@/components/imgbox.vue'),
156
+    BgMusic: () => import('@/components/BgMusic.vue'),
155 157
   },
156 158
   data() {
157 159
     return {
@@ -236,6 +238,13 @@ export default {
236 238
         this.showMyWinning = true
237 239
 
238 240
         // 其他动作
241
+      }).catch(err => {
242
+        if (err && err.code === 9999) {
243
+          // 奖品没了
244
+        } else {
245
+          // 其他错误
246
+          const errMsg = err.message || err;
247
+        }
239 248
       })
240 249
     },
241 250
     // 获取奖品列表

+ 1
- 1
src/utils/request.js Ver fichero

@@ -12,7 +12,7 @@ export default function request (url, options = {}) {
12 12
     .then(response => response.json())
13 13
     .then(data => {
14 14
       if (data.code === 1000) return data.data
15
-      return Promise.reject(data.message)
15
+      return Promise.reject(data)
16 16
     })
17 17
 }
18 18