Browse Source

PC、移动端个人注册注册完成跳转商城首页且登录状态 以及移动注册页面点击下方登录增加查询字符串

hangb 7 years ago
parent
commit
7461e9ebf1

+ 10 - 2
components/mobile/footerMobile.vue

@@ -1,13 +1,21 @@
 <template>
 <template>
 <div class="footer">
 <div class="footer">
   <span>已有账户?</span>&nbsp;&nbsp;
   <span>已有账户?</span>&nbsp;&nbsp;
-  <a href="/">立即登录</a>
+  <a :href="returnLogin">立即登录</a>
 </div>
 </div>
 </template>
 </template>
 
 
 <script>
 <script>
   export default {
   export default {
-    name: 'footerMobile'
+    name: 'footerMobile',
+    data () {
+      return {
+        returnLogin: ''
+      }
+    },
+    mounted () {
+      this.returnLogin = window.location.origin + window.location.search
+    }
   }
   }
 </script>
 </script>
 
 

+ 63 - 2
components/mobile/registerPersonal/index.vue

@@ -274,8 +274,34 @@
             .then(response => {
             .then(response => {
               this.$indicator.close()
               this.$indicator.close()
               if (response.data.success) {
               if (response.data.success) {
-                let userUU = response.data.content.userUU
-                window.location.href = `/overRegister/${userUU}`
+                if (response.data.content.data) {
+                  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 {
+                  let userUU = response.data.content.userUU
+                  window.location.href = `/overRegister/${userUU}`
+                }
               } else if (response.data.error) {
               } else if (response.data.error) {
                 this.$toast({
                 this.$toast({
                   message: response.data.errMsg,
                   message: response.data.errMsg,
@@ -287,6 +313,41 @@
               this.downToast('请检查网络是否正常或联系服务商')
               this.downToast('请检查网络是否正常或联系服务商')
             })
             })
         }
         }
+      },
+      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)
+        })
       }
       }
     }
     }
   }
   }

+ 63 - 2
components/register/PersonalRegistration.vue

@@ -411,8 +411,34 @@
               .then(response => {
               .then(response => {
                 this.isShowLoading = false
                 this.isShowLoading = false
                 if (response.data.success) {
                 if (response.data.success) {
-                  let userUU = response.data.content.userUU
-                  window.location.href = `/overRegister/${userUU}`
+                  if (response.data.content.data) {
+                    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 {
+                    let userUU = response.data.content.userUU
+                    window.location.href = `/overRegister/${userUU}`
+                  }
                 } else {
                 } else {
                   return Promise.reject(response.data)
                   return Promise.reject(response.data)
                 }
                 }
@@ -485,6 +511,41 @@
             this.isShowLoading = false
             this.isShowLoading = false
             this.$message.error(err.errMsg)
             this.$message.error(err.errMsg)
           })
           })
+      },
+      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)
+        })
       }
       }
     }
     }
   }
   }