Browse Source

修正微信跳转

shenjj 7 years ago
parent
commit
9950de6b22
1 changed files with 14 additions and 3 deletions
  1. 14 3
      pages/mobile/wechat/index.vue

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

@@ -80,9 +80,16 @@
        }
     },
     mounted() {
+      let info = localStorage.getItem('USOFTMALLWECHATINFO')
+      localStorage.setItem('RETURNURL', this.$route.query.url || '')
+      if (!info && !this.$route.query.code) {
+        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) {
+        this.$store.commit('option/REQUEST_WECHATINFO_STATUS_SUCCESS', JSON.parse(info))
+      } else {
+        this.$store.dispatch('GerWechatInfo', {code: this.$route.query.code})
+      }
       this.$nextTick(() => {
-      // let info = localStorage.getItem('USOFTMALLWECHATINFO')
-      // this.$store.commit('option/REQUEST_WECHATINFO_STATUS_SUCCESS', JSON.parse(info))
         if (this.BScroll) {
           this.BScroll.refresh()
         } else {
@@ -98,7 +105,11 @@
         userAccount.spaceUU = item.uu
         this.$http.get('/newLogin/other', {params: userAccount}).then(res => {
           this.$store.dispatch('loadUserInfo').then(() => {
-             if (this.$route.query.url && this.$route.query.url !== '') {
+             let _url = localStorage.getItem('RETURNURL')
+             if (_url !== '') {
+               localStorage.removeItem('RETURNURL')
+               this.$router.replace(_url)
+             } else if (this.$route.query.url && this.$route.query.url !== '') {
                 this.$router.replace(this.$route.query.url)
              } else {
                this.goLastPage()