[baozhangchao] 3 anos atrás
pai
commit
cd1ffd743e

src/assets/shareImage/转发预览图.jpg → public/images/share.jpg Ver arquivo


BIN
src/assets/ButtonImage/paused.png Ver arquivo


BIN
src/assets/ButtonImage/play.png Ver arquivo


BIN
src/assets/TipsImage/3-3.png Ver arquivo


+ 0
- 1
src/components/BackPage.vue Ver arquivo

@@ -28,7 +28,6 @@ export default {
28 28
 .index-image {
29 29
   height: 100vh;
30 30
   overflow: hidden;
31
-  z-index: 2000;
32 31
 
33 32
   .bg-image {
34 33
     width: 100vw;

+ 87
- 0
src/components/BgMusic.vue Ver arquivo

@@ -0,0 +1,87 @@
1
+<template>
2
+  <div class="bg-music" :class="{ ['icon-playing']: playing }" @click="handleClick" v-show="show">
3
+    <audio :src="url" ref="audioRef" loop @loadedmetadata="show = true" @play="handlePlay"></audio>
4
+  </div>
5
+</template>
6
+
7
+<script>
8
+export default {
9
+  name: 'BgMusic',
10
+  data() {
11
+    const { origin, pathname } = window.location
12
+
13
+    return {
14
+      show: false,
15
+      playing: false,
16
+      url: `${origin}${pathname}bg.mp3`
17
+    }
18
+  },
19
+  mounted() {
20
+    document.body.addEventListener('click', this.handleClick)
21
+
22
+    this.$nextTick(() => {
23
+      this.handleIOSAudio()
24
+    })
25
+  },
26
+  methods: {
27
+    handleIOSAudio() {
28
+      const isiOS = !!navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)
29
+      if (isiOS) {
30
+        document.addEventListener(
31
+          'WeixinJSBridgeReady',
32
+          () => {
33
+            this.$refs.audioRef.load()
34
+          },
35
+          false
36
+        )
37
+      }
38
+    },
39
+    handleClick() {
40
+      if (!this.show || !this.$refs.audioRef) return
41
+
42
+      if (this.playing) {
43
+        this.$refs.audioRef.pause()
44
+      } else {
45
+        this.$refs.audioRef.play()
46
+      }
47
+
48
+      this.playing = !this.playing
49
+    },
50
+
51
+    handlePlay() {
52
+      document.body.removeEventListener('click', this.handleClick)
53
+    }
54
+  }
55
+}
56
+</script>
57
+
58
+<style lang="less" scoped>
59
+.bg-music {
60
+  position: fixed;
61
+  top: 1em;
62
+  right: 1em;
63
+  z-index: 10;
64
+
65
+  width: 2em;
66
+  height: 2em;
67
+  background-image: url('~@/assets/ButtonImage/play.png');
68
+  background-repeat: no-repeat;
69
+  background-size: 100% 100%;
70
+
71
+  &.icon-playing {
72
+    background-image: url('~@/assets/indexImg/paused.png');
73
+    animation: musicrotate 3s linear infinite;
74
+  }
75
+
76
+  & > audio {
77
+    max-width: 1px;
78
+    max-height: 1px;
79
+  }
80
+}
81
+
82
+@keyframes musicrotate {
83
+  100% {
84
+    transform: rotate(360deg);
85
+  }
86
+}
87
+</style>

+ 43
- 2
src/pages/OverPage.vue Ver arquivo

@@ -6,6 +6,9 @@
6 6
       </div>
7 7
       <img v-if="route.query.type =='win'" :src="winTopImage" class="overImage-top-box" />
8 8
       <img v-else :src="loseTopImage" class="overImage-top-box" />
9
+      <div v-show="visImage" @click="goShares" class="visImage">
10
+        <img :src="shareImag" />
11
+      </div>
9 12
 
10 13
       <div class="IKnow-box">
11 14
         <div class="IKnow-box-top">
@@ -16,6 +19,9 @@
16 19
           <img :src="goTop" @click="goTops" />
17 20
         </div>
18 21
       </div>
22
+      <!-- <div v-show="visImage" class="visImage">
23
+        <img :src="shareImag" />
24
+      </div>-->
19 25
     </div>
20 26
   </BackPage>
21 27
 </template>
@@ -29,9 +35,13 @@ import loseTopImage from '@/assets/RoundaboutImage/2-12.png'
29 35
 import tryAgain from '@/assets/ButtonImage/再玩一次.png'
30 36
 import goShare from '@/assets/ButtonImage/和好友一起玩.png'
31 37
 import goTop from '@/assets/ButtonImage/排行榜.png'
38
+import shareImag from '@/assets/shareImage/share.png'
39
+import { ref } from '@vue/reactivity'
32 40
 
33 41
 export default {
34 42
   setup() {
43
+    let visImage = ref(false)
44
+
35 45
     const route = useRoute() //跳转
36 46
     const router = useRouter() //拿参
37 47
     const tryAgains = () => {
@@ -49,15 +59,16 @@ export default {
49 59
       })
50 60
     }
51 61
     const goShares = () => {
62
+      visImage.value = !visImage.value
63
+      console.log(visImage)
52 64
       //     router.push({
53 65
       //   path: '/TopRulePage',
54 66
       //   query: {
55 67
       //     // type: 'top'
56 68
       //     type: 'top'
57 69
       //   }
58
-      // })
70
+      // }) const data = ref(initValue)
59 71
     }
60
-    goShare
61 72
 
62 73
     return {
63 74
       overImage,
@@ -67,6 +78,8 @@ export default {
67 78
       goShare,
68 79
       goTop,
69 80
       route,
81
+      visImage,
82
+      shareImag,
70 83
       tryAgains,
71 84
       goTops,
72 85
       goShares
@@ -94,6 +107,22 @@ export default {
94 107
   top: 9vh;
95 108
   left: 15vw;
96 109
 }
110
+.visImage {
111
+  width: 100%;
112
+  height: 100%;
113
+  background-color: rgba(0, 0, 0, 0.8);
114
+  position: absolute;
115
+  top: 0;
116
+  z-index: 888;
117
+  > img {
118
+    position: absolute;
119
+
120
+    top: 5vh;
121
+    right: 3vw;
122
+    width: 6vw;
123
+    animation: tipup 1s ease infinite;
124
+  }
125
+}
97 126
 .IKnow-box {
98 127
   position: absolute;
99 128
   bottom: 7vh;
@@ -116,4 +145,16 @@ export default {
116 145
     }
117 146
   }
118 147
 }
148
+
149
+@keyframes tipup {
150
+  0% {
151
+    transform: translateY(0%);
152
+  }
153
+  50% {
154
+    transform: translateY(5%);
155
+  }
156
+  100% {
157
+    transform: translateY(0%);
158
+  }
159
+}
119 160
 </style>

+ 0
- 1
src/pages/TopRulePage.vue Ver arquivo

@@ -137,7 +137,6 @@ export default {
137 137
   position: absolute;
138 138
   width: 100vw;
139 139
   z-index: 500;
140
-
141 140
   display: flex;
142 141
   bottom: 7vh;
143 142
 

+ 8
- 6
src/pages/homePage.vue Ver arquivo

@@ -2,6 +2,7 @@
2 2
 <template>
3 3
   <div>
4 4
     <BackPage>
5
+      <BgMusic />
5 6
       <div class="TitleBox">
6 7
         <img :src="gameTitle" />
7 8
       </div>
@@ -17,9 +18,9 @@
17 18
 import { useRouter } from 'vue-router'
18 19
 import backHome from '@/assets/BackImage/backHome.jpg'
19 20
 import gameTitle from '@/assets/BackImage/首页大标.png'
20
-
21 21
 import gameSatrt from '@/assets/ButtonImage/开始游戏.png'
22 22
 import gameRule from '@/assets/ButtonImage/游戏规则.png'
23
+import BgMusic from '@/components/BackPage.vue'
23 24
 
24 25
 export default {
25 26
   setup() {
@@ -32,10 +33,10 @@ export default {
32 33
 
33 34
       // 带有路径的对象
34 35
       router.push({
35
-        path: '/game'
36
-        // query: {
37
-        //   type: 'win'
38
-        // }
36
+        path: '/OverPage',
37
+        query: {
38
+          type: 'win'
39
+        }
39 40
       })
40 41
     }
41 42
     const goRule = () => {
@@ -58,7 +59,8 @@ export default {
58 59
       gameSatrt,
59 60
       gameRule,
60 61
       gameTitle,
61
-      goRule
62
+      goRule,
63
+      BgMusic
62 64
     }
63 65
   }
64 66
 }

+ 31
- 0
src/utils/initial.js Ver arquivo

@@ -169,3 +169,34 @@ export function redirect (force) {
169 169
     window.location.href = url;
170 170
   }
171 171
 }
172
+
173
+
174
+/**
175
+ * 获取 openid
176
+ * @returns 
177
+ */
178
+export function getOpenId () {
179
+  if (process.env.NODE_ENV === 'development') return Promise.resolve('123');
180
+
181
+  const code = getCode()
182
+  if (!code) {
183
+    return Promise.reject("获取用户信息失败, 请刷新重试")
184
+  }
185
+
186
+  return request(`https://api.h5.njyunzhi.com/mp/openid?code=${encodeURIComponent(code)}`)
187
+}
188
+
189
+/**
190
+ * 获取 openid
191
+ * @returns 
192
+ */
193
+export function getUserInfo () {
194
+  if (process.env.NODE_ENV === 'development') return Promise.resolve({ openid: '123' });
195
+
196
+  const code = getCode()
197
+  if (!code) {
198
+    return Promise.reject("获取用户信息失败, 请刷新重试")
199
+  }
200
+
201
+  return request(`https://api.h5.njyunzhi.com/mp/userinfo?code=${encodeURIComponent(code)}`)
202
+}