Selaa lähdekoodia

Merge branch 'master' of http://git.ycjcjy.com/support-game/wechat

陈冉 6 vuotta sitten
vanhempi
commit
e6c306e1be
2 muutettua tiedostoa jossa 13 lisäystä ja 8 poistoa
  1. 6
    8
      src/App.vue
  2. 7
    0
      src/store/vote.js

+ 6
- 8
src/App.vue Näytä tiedosto

@@ -32,6 +32,7 @@ export default {
32 32
     ...mapactivityState({
33 33
       activity: s => s.activity || {},
34 34
       theme: s => `${s.theme}`,
35
+      code: s => s.code,
35 36
     })
36 37
   },
37 38
   created() {
@@ -39,15 +40,12 @@ export default {
39 40
     console.log("process.env.NODE_ENV =>", env)
40 41
     if (env === 'production' || env === 'test') {
41 42
       if (location.search && this.toolClass.UrlSearch(location.search).code) {
42
-        this.code = this.toolClass.UrlSearch(location.search).code
43
-        let oldCode = localStorage.getItem('code')
44
-        if (this.code === oldCode) {
45
-          localStorage.setItem('code', this.code)
43
+        const code = this.toolClass.UrlSearch(location.search).code
44
+        if (this.code === code) {
46 45
           this.toolClass.getCode(this.appid[env])
47 46
         } else {
48
-          localStorage.setItem('code', this.code)
49
-          // this.showPage = true
50
-          this.getUser({code: this.code }).then(() => {
47
+          this.setCode(code)
48
+          this.getUser({ code }).then(() => {
51 49
             this.showPage = true
52 50
           })
53 51
         }
@@ -59,7 +57,7 @@ export default {
59 57
     }
60 58
   },
61 59
   methods: {
62
-    ...mapIndexActions(["getUser"])
60
+    ...mapIndexActions(["getUser","setCode"])
63 61
   }
64 62
 };
65 63
 </script>

+ 7
- 0
src/store/vote.js Näytä tiedosto

@@ -11,6 +11,7 @@ export default {
11 11
     toplist: [],
12 12
     list: [],
13 13
     theme: 1,
14
+    code: '',
14 15
   },
15 16
   mutations: {
16 17
     updateActivity(state, data) {
@@ -48,6 +49,9 @@ export default {
48 49
       state.list = state.list.map(x => {
49 50
         return x.MemberId === data.MemberId ? data : x
50 51
       })
52
+    },
53
+    setCode(state, code) {
54
+      state.code = code
51 55
     }
52 56
   },
53 57
   actions: {
@@ -189,5 +193,8 @@ export default {
189 193
         }).catch(reject)
190 194
       })
191 195
     },
196
+    setCode({ commit }, code) {
197
+      commit('setCode', code)
198
+    },
192 199
   }
193 200
 }