张延森 3 anni fa
parent
commit
87dbef864e
6 ha cambiato i file con 49 aggiunte e 19 eliminazioni
  1. 6
    0
      public/index.html
  2. 10
    0
      public/js/vconsole.min.js
  3. 18
    7
      src/main.js
  4. 6
    5
      src/pages/Honghe.vue
  5. 7
    6
      src/router/index.js
  6. 2
    1
      src/utils/wx.js

+ 6
- 0
public/index.html Vedi File

@@ -6,6 +6,11 @@
6 6
     <meta name="viewport" content="width=device-width,initial-scale=1.0">
7 7
     <link rel="icon" href="<%= BASE_URL %>favicon.ico">
8 8
     <script src="https://res2.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
9
+
10
+    <!-- 调式用 -->
11
+    <!-- <script src="js/vconsole.min.js"></script>
12
+    <script>const vConsole = new VConsole();</script> -->
13
+
9 14
     <title>抽取幸运签,解锁隐藏福利</title>
10 15
     <style>
11 16
       .page-loading-wrapper {
@@ -18,6 +23,7 @@
18 23
         z-index: 999;
19 24
         background: url(./images/loadingBgc.jpg) no-repeat 100% 100%;
20 25
         display: flex;
26
+        /* display: none; */
21 27
         justify-content: center;
22 28
         align-items: center;
23 29
       }

+ 10
- 0
public/js/vconsole.min.js
File diff suppressed because it is too large
Vedi File


+ 18
- 7
src/main.js Vedi File

@@ -4,13 +4,24 @@ import App from './App.vue'
4 4
 import router from './router/index'//路由
5 5
 
6 6
 import { redirect } from './utils/wx'
7
-redirect()
8 7
 
9
-Vue.config.productionTip = false
8
+function main() {
10 9
 
11
-Vue.component('modal', Modal)
10
+  // if (redirect()) {
11
+  //   // 如果页面跳转了, 后面代码强制不执行
12
+  //   return;
13
+  // }
12 14
 
13
-const app = new Vue({
14
-  router,
15
-  render: h => h(App),
16
-}).$mount('#app')
15
+  redirect()
16
+  
17
+  Vue.config.productionTip = false
18
+    
19
+  Vue.component('modal', Modal)
20
+  
21
+  const app = new Vue({
22
+    router,
23
+    render: h => h(App),
24
+  }).$mount('#app')
25
+}
26
+
27
+main()

+ 6
- 5
src/pages/Honghe.vue Vedi File

@@ -253,12 +253,13 @@ export default {
253 253
       this.binggo = false
254 254
     },
255 255
     handleMonthClick(month) {
256
-      this.list.map((item) => {
257
-        if (item.id == month.id) {
258
-          item.mode = 2
259
-        }
260
-      })
256
+      if (!this.person || !this.personId) {
257
+        alert('为了您能够正常参与抽奖,请刷新页面并同意授权微信昵称!')
258
+        return
259
+      }
260
+      
261 261
       this.currentMonth = month
262
+      this.currentMonth.mode = 2
262 263
 
263 264
       // 如果点击可以抽奖
264 265
       if (month.id === this.bingoId && !this.noPrize) {

+ 7
- 6
src/router/index.js Vedi File

@@ -34,24 +34,25 @@ const router = new Router({
34 34
 router.beforeEach((to, from, next) => {
35 35
   const [person, setPerson] = useModel('person')
36 36
 
37
+  // console.log('-----person.personId---->', person.personId)
38
+
37 39
   // 未登录
38 40
   if (!person.personId) {
39 41
     getUserInfo().then(userinfo => {
40 42
       login(userinfo).then(res => {
43
+        // console.log('-----login---->', res)
41 44
         const { user, token } = res;
42 45
         setPerson(user)
43 46
         setToken(token)
44
-
45
-        next()
46 47
       }).catch(() => {
47
-        return redirect(true)
48
+        alert('系统异常, 请刷新重试')
48 49
       })
49 50
     }).catch(() => {
50
-      return redirect(true)
51
+      // do nothing
51 52
     })
52
-  } else {
53
-    next()
54 53
   }
54
+
55
+  next()
55 56
 })
56 57
 
57 58
 export default router;

+ 2
- 1
src/utils/wx.js Vedi File

@@ -74,9 +74,10 @@ export function redirect (force) {
74 74
   localStorage.setItem('wxcode', queryCode)
75 75
 
76 76
   if (force || !queryCode || queryCode === originCode) {
77
+    
77 78
     const local = encodeURIComponent(location.origin + location.pathname)
78 79
     const url = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxd3bab568bc42d1de&redirect_uri=${local}&response_type=code&scope=snsapi_userinfo&state=123#wechat_redirect`
79
-    window.location.href = url
80
+    window.location.href = url;
80 81
   }
81 82
 }
82 83