Browse Source

移动端企业注册注册完成跳转商城首页且登录状态

hangb 7 years ago
parent
commit
4b909a708b

+ 62 - 1
components/mobile/registerEnterprise/index.vue

@@ -425,7 +425,33 @@
           .then(response => {
             this.$indicator.close()
             if (response.data.success) {
-              window.location.href = '/overRegister/overEnterprise'
+              if (response.data.content) {
+                let param = response.data.content.data
+                let a = ''
+                for (let n in param) {
+                  a += (n + '=' + encodeURIComponent(param[n]) + '&')
+                }
+                let params = a.substr(0, a.length - 1)
+                this.isShowLoading = true
+                if (response.data.content.currentUrl) {
+                  this.$jsonp(`${response.data.content.currentUrl}?${params}`, {
+                    name: 'successCallback',
+                    timeout: 3000
+                  }, (err, data) => {
+                    if (err) {
+                      this.$message.error('注册成功,请点击下方“立即登录”完成登录')
+                      this.isShowLoading = false
+                      throw err
+                    } else {
+                      this.loginOther(response, params)
+                    }
+                  })
+                } else {
+                  this.loginOther(response, params, 3000)
+                }
+              } else {
+                window.location.href = '/overRegister/overEnterprise'
+              }
             } else {
               this.downToast(response.data.errMsg)
             }
@@ -467,6 +493,41 @@
             }
           }
         }
+      },
+      getJsonp: function (url, timeout = 500) {
+        return new Promise((resolve, reject) => {
+          this.$jsonp(url, {
+            name: 'successCallback',
+            timeout: timeout
+          }, function (err, data) {
+            if (err) {
+              reject(err)
+              throw err
+            } else {
+              resolve(data)
+            }
+          })
+        })
+      },
+      crossAfter (url) {
+        try {
+          window.location.href = url
+        } catch (err) {
+          console.log(err)
+        }
+      },
+      loginOther (response, a, timeout) {
+        const crossAfter = this.crossAfter
+        let promises = []
+        for (let i in response.data.content.loginUrls) {
+          promises.push(this.getJsonp(`${response.data.content.loginUrls[i]}?${a}`))
+        }
+        let returnUrl = decodeURIComponent(this.$route.query.returnURL)
+        Promise.all(promises).then(() => {
+          crossAfter(returnUrl || 'http://www.ubtob.com', timeout)
+        }).catch(() => {
+          crossAfter(returnUrl || 'http://www.ubtob.com', timeout)
+        })
       }
     }
   }

+ 0 - 1
components/register/EnterpriseRegistration.vue

@@ -786,7 +786,6 @@
               } else {
                 window.location.href = '/overRegister/overEnterprise'
               }
-              console.log('response.data', response.data)
             } else {
               return Promise.reject(response.data)
             }