瀏覽代碼

解决微信绑定

shenjj 7 年之前
父節點
當前提交
fbef6c8950
共有 3 個文件被更改,包括 9 次插入7 次删除
  1. 1 5
      components/mobile/Home.vue
  2. 3 1
      pages/mobile/wechat/index.vue
  3. 5 1
      store/index.js

+ 1 - 5
components/mobile/Home.vue

@@ -216,11 +216,7 @@
             // window.location.href = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxd29bbca61728b189&redirect_uri=http://cuy53h.natappfree.cc&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect`
           } else if (ua.match(/micromessenger/i) && ua.match(/micromessenger/i)[0] === 'micromessenger') {
             info = info && JSON.parse(info)
-            if (info) {
-              // if (info.status === 1) {
-              //   this.$store.dispatch('GerWechatInfo', {code: '', openId: info.openid})
-              // }
-            } else {
+            if (!info) {
               this.$store.dispatch('GerWechatInfo', {code: this.$route.query.code})
             }
         }

+ 3 - 1
pages/mobile/wechat/index.vue

@@ -76,8 +76,10 @@
         // window.location.href = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxb3274b676737a319&redirect_uri=https://www.usoftmall.com/mobile/wechat&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect`
       } else if (info) {
         info = JSON.parse(info)
-        if (info.status === 1) {
+        if (info.openid) {
           this.$store.dispatch('GerWechatInfo', {code: '', openId: info.openid})
+        } else {
+          window.location.href = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxb3274b676737a319&redirect_uri=https://www.usoftmall.com/mobile/wechat&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect`
         }
       } else {
         this.$store.dispatch('GerWechatInfo', {code: this.$route.query.code})

+ 5 - 1
store/index.js

@@ -476,7 +476,11 @@ export const actions = {
     return axios.get('/wx/getWxUserInfo', { params: params })
       .then(response => {
         commit('option/REQUEST_WECHATINFO_STATUS_SUCCESS', response.data)
-        localStorage.setItem('USOFTMALLWECHATINFO', JSON.stringify(response.data))
+        if (response.data.openid) {
+          localStorage.setItem('USOFTMALLWECHATINFO', JSON.stringify(response.data))
+        } else {
+          localStorage.removeItem('USOFTMALLWECHATINFO')
+        }
       }, err => {
         localStorage.removeItem('USOFTMALLWECHATINFO')
         commit('option/REQUEST_WECHATINFO_STATUS_FAILURE', err)