Bladeren bron

Merge branch 'feature/yc-login-1110'

yangc 8 jaren geleden
bovenliggende
commit
6de0bf881c

+ 1 - 1
components/common/buyOrCar/buyComponent.vue

@@ -13,7 +13,7 @@
         if (!this.$store.state.option.user.logged) {
           this.$http.get('/login/page', {params: {returnUrl: window.location.href}}).then(response => {
             if (response.data) {
-              this.$router.push('/auth/login')
+              window.location.href = response.data.content + '&baseUrl=' + encodeURIComponent(window.location.protocol + '//' + window.location.host + response.data.baseUrl)
             }
           })
         } else {

+ 6 - 4
components/default/Header.vue

@@ -77,13 +77,16 @@
     },
     methods: {
       logout () {
-        this.$router.push('/auth/logout')
+        this.$http.get('/logout/crossBefore').then(response => {
+          if (response.data) {
+            window.location.href = response.data.logoutUrl + encodeURIComponent(window.location.protocol + '//' + window.location.host + response.data.baseUrl)
+          }
+        })
       },
       onLoginClick () {
         this.$http.get('/login/page', {params: {returnUrl: window.location.href}}).then(response => {
           if (response.data) {
-            this.$router.push('/auth/login')
-//            window.location.href = response.data.content
+            window.location.href = response.data.content + '&baseUrl=' + encodeURIComponent(window.location.protocol + '//' + window.location.host + response.data.baseUrl)
           }
         })
         // TODO 待Account Center改版
@@ -91,7 +94,6 @@
       onRegisterClick () {
         this.$http.get('/register/page').then(response => {
           if (response.data) {
-        //    this.$router.push('/auth/login')
             window.location.href = response.data.content
           }
         })

+ 1 - 1
components/default/RightBar.vue

@@ -148,7 +148,7 @@
       goLogin: function () {
         this.$http.get('/login/page', {params: {returnUrl: window.location.href}}).then(response => {
           if (response.data) {
-            this.$router.push('/auth/login')
+            window.location.href = response.data.content + '&baseUrl=' + encodeURIComponent(window.location.protocol + '//' + window.location.host + response.data.baseUrl)
           }
         })
       },

+ 2 - 2
components/product/component/ComponentDetail.vue

@@ -111,7 +111,7 @@
         } else {
           this.$http.get('/login/page', {params: {returnUrl: window.location.href}}).then(response => {
             if (response.data) {
-              this.$router.push('/auth/login')
+              window.location.href = response.data.content + '&baseUrl=' + encodeURIComponent(window.location.protocol + '//' + window.location.host + response.data.baseUrl)
             }
           })
         }
@@ -120,7 +120,7 @@
         if (url === '1') {
           this.$http.get('/login/page', {params: {returnUrl: window.location.href}}).then(response => {
             if (response.data) {
-              this.$router.push('/auth/login')
+              window.location.href = response.data.content + '&baseUrl=' + encodeURIComponent(window.location.protocol + '//' + window.location.host + response.data.baseUrl)
             }
           })
         } else {

+ 1 - 1
components/provider/NewStore.vue

@@ -57,7 +57,7 @@ export default {
       if (!this.user.logged) {
         this.$http.get('/login/page', {params: {returnUrl: window.location.href}}).then(response => {
           if (response.data) {
-            this.$router.push('/auth/login')
+            window.location.href = response.data.content + '&baseUrl=' + encodeURIComponent(window.location.protocol + '//' + window.location.host + response.data.baseUrl)
           }
         })
       } else {

+ 1 - 1
components/searchStore/StoreContent.vue

@@ -97,7 +97,7 @@
         if (!this.user.logged) {
           this.$http.get('/login/page').then(response => {
             if (response.data) {
-              this.$router.push('/auth/login')
+              window.location.href = response.data.content + '&baseUrl=' + encodeURIComponent(window.location.protocol + '//' + window.location.host + response.data.baseUrl)
             }
           })
         } else {

+ 1 - 1
components/store/CommodityInfo.vue

@@ -310,7 +310,7 @@ export default {
       if (!this.$store.state.option.user.logged) {
         this.$http.get('/login/page', {params: {returnUrl: window.location.href}}).then(response => {
           if (response.data) {
-            this.$router.push('/auth/login')
+            window.location.href = response.data.content + '&baseUrl=' + encodeURIComponent(window.location.protocol + '//' + window.location.host + response.data.baseUrl)
           }
         })
       } else {

+ 1 - 1
components/store/RecommendProduct.vue

@@ -72,7 +72,7 @@
         if (!this.$store.state.option.user.logged) {
           this.$http.get('/login/page', {params: {returnUrl: window.location.href}}).then(response => {
             if (response.data) {
-              this.$router.push('/auth/login')
+              window.location.href = response.data.content + '&baseUrl=' + encodeURIComponent(window.location.protocol + '//' + window.location.host + response.data.baseUrl)
             }
           })
         } else {

+ 1 - 1
components/store/common/StoreHeader.vue

@@ -100,7 +100,7 @@ export default {
       if (!this.user.logged) {
         this.$http.get('/login/page', {params: {returnUrl: window.location.href}}).then(response => {
           if (response.data) {
-            this.$router.push('/auth/login')
+            window.location.href = response.data.content + '&baseUrl=' + encodeURIComponent(window.location.protocol + '//' + window.location.host + response.data.baseUrl)
           }
         })
       } else {

+ 0 - 10
layouts/main.vue

@@ -20,15 +20,5 @@
       MainHeader,
       MainNav
     }
-//    data () {
-//      return {
-//        url: window.location.href
-//      }
-//    },
-//    watch: {
-//      url: function (val, oldVal) {
-//        console.log(val)
-//      }
-//    }
   }
 </script>

+ 5 - 1
middleware/authenticated.js

@@ -4,6 +4,10 @@ export default function ({ isServer, store, req, redirect }) {
   if (isServer && !req) return
 
   if (!store.state.option.user.logged) {
-    redirect('/auth/login')
+    this.$http.get('/logout/crossBefore').then(response => {
+      if (response.data) {
+        window.location.href = response.data.logoutUrl + encodeURIComponent(window.location.protocol + '//' + window.location.host + response.data.baseUrl)
+      }
+    })
   }
 }

+ 0 - 56
pages/SSRProxy/loginProxy.vue

@@ -1,56 +0,0 @@
-<template>
-  <!-- Login 代理页面 -->
-  <div>
-  </div>
-</template>
-<script>
-
-export default {
-  layout: 'login',
-  mounted () {
-    this.crossBefore()
-  },
-  methods: {
-    async crossBefore () {
-      try {
-        let { data } = await this.$http.get('/login/crossBefore')
-        const params = data || {}
-        this.proxyLogin(params.askUrl, params.askData, params.loginUrl)
-      } catch (err) {
-        this.$router.replace('/')
-        console.log(err)
-      }
-    },
-    proxyLogin (askUrl, askData, loginUrl) {
-      const crossAfter = this.crossAfter
-      this.$jsonp(`${askUrl}?askData=${askData}`, function (err, data) {
-        if (err) throw err
-
-        // 判断是否已经登录
-        if (data.error) {
-          // 如果未登录,跳转登录界面
-          window.location.href = loginUrl
-        } else {
-          crossAfter(data.content)
-        }
-      })
-    },
-    async crossAfter (content) {
-      if (!content && content === '') {
-        this.$router.replace('/')
-      }
-
-      try {
-        let { data } = await this.$http.post('/login/crossAfter', {}, { params: { replyTxt: content } })
-
-        this.$store.dispatch('loadUserInfo', data)
-
-        window.location.href = data.returnUrl || '/'
-      } catch (err) {
-        this.$router.replace('/')
-        console.log(err)
-      }
-    }
-  }
-}
-</script>

+ 0 - 35
pages/SSRProxy/logoutProxy.vue

@@ -1,35 +0,0 @@
-<template>
-  <!-- Login 代理页面 -->
-  <div>
-  </div>
-</template>
-<script>
-  export default {
-    layout: 'login',
-    mounted () {
-      this.crossBefore()
-    },
-    methods: {
-      async crossBefore () {
-        try {
-          let { data } = await this.$http.get('/logout/crossBefore')
-          const params = data || {}
-          this.proxyLogout(params.askUrl, params.returnUrl, params.logoutUrl)
-        } catch (err) {
-          this.$router.replace('/')
-          console.log(err)
-        }
-      },
-      proxyLogout (askUrl, returnUrl, logoutUrl) {
-        this.$jsonp(`${askUrl}`, function (err, data) {
-          if (err) throw err
-          if (data.error) {
-            window.location.href = logoutUrl
-          } else {
-            window.location.href = returnUrl && returnUrl !== 'null' ? returnUrl : '/'
-          }
-        })
-      }
-    }
-  }
-</script>

+ 0 - 55
pages/auth/login.vue

@@ -1,55 +0,0 @@
-<template>
-  <!-- Login 代理页面 -->
-  <div>
-  </div>
-</template>
-<script>
-
-export default {
-  layout: 'login',
-  mounted () {
-    this.crossBefore()
-  },
-  methods: {
-    async crossBefore () {
-      try {
-        let { data } = await this.$http.get('/login/crossBefore')
-        const params = data || {}
-        this.proxyLogin(params.askUrl, params.askData, params.loginUrl)
-      } catch (err) {
-        this.$router.replace('/')
-        console.log(err)
-      }
-    },
-    proxyLogin (askUrl, askData, loginUrl) {
-      const crossAfter = this.crossAfter
-      this.$jsonp(`${askUrl}?askData=${askData}`, function (err, data) {
-        if (err) throw err
-
-        // 判断是否已经登录
-        if (data.error) {
-          // 如果未登录,跳转登录界面
-          window.location.href = loginUrl
-        } else {
-          crossAfter(data.content)
-        }
-      })
-    },
-    async crossAfter (content) {
-      if (!content || content === '') {
-        this.$router.replace('/')
-      }
-
-      try {
-        let { data } = await this.$http.post('/login/crossAfter', {}, { params: { replyTxt: content } })
-
-        this.$store.dispatch('loadUserInfo', data)
-        window.location.href = data.returnUrl || '/'
-      } catch (err) {
-        this.$router.replace('/')
-        console.log(err)
-      }
-    }
-  }
-}
-</script>

+ 0 - 35
pages/auth/logout.vue

@@ -1,35 +0,0 @@
-<template>
-  <!-- Login 代理页面 -->
-  <div>
-  </div>
-</template>
-<script>
-export default {
-  layout: 'login',
-  mounted () {
-    this.crossBefore()
-  },
-  methods: {
-    async crossBefore () {
-      try {
-        let { data } = await this.$http.get('/logout/crossBefore')
-        const params = data || {}
-        this.proxyLogout(params.askUrl, params.returnUrl, params.logoutUrl)
-      } catch (err) {
-        this.$router.replace('/')
-        console.log(err)
-      }
-    },
-    proxyLogout (askUrl, returnUrl, logoutUrl) {
-      this.$jsonp(`${askUrl}`, function (err, data) {
-        if (err) throw err
-        if (data.error) {
-          window.location.href = logoutUrl
-        } else {
-          window.location.href = returnUrl && returnUrl !== 'null' ? returnUrl : '/'
-        }
-      })
-    }
-  }
-}
-</script>

+ 0 - 56
pages/platform-b2c/login/proxy.vue

@@ -1,56 +0,0 @@
-<template>
-  <!-- Login 代理页面 -->
-  <div>
-  </div>
-</template>
-<script>
-
-export default {
-  layout: 'login',
-  mounted () {
-    this.crossBefore()
-  },
-  methods: {
-    async crossBefore () {
-      try {
-        let { data } = await this.$http.get('/login/crossBefore')
-        const params = data || {}
-        this.proxyLogin(params.askUrl, params.askData, params.loginUrl)
-      } catch (err) {
-        this.$router.replace('/')
-        console.log(err)
-      }
-    },
-    proxyLogin (askUrl, askData, loginUrl) {
-      const crossAfter = this.crossAfter
-      this.$jsonp(`${askUrl}?askData=${askData}`, function (err, data) {
-        if (err) throw err
-
-        // 判断是否已经登录
-        if (data.error) {
-          // 如果未登录,跳转登录界面
-          window.location.href = loginUrl
-        } else {
-          crossAfter(data.content)
-        }
-      })
-    },
-    async crossAfter (content) {
-      if (!content && content === '') {
-        this.$router.replace('/')
-      }
-
-      try {
-        let { data } = await this.$http.post('/login/crossAfter', {}, { params: { replyTxt: content } })
-
-        this.$store.dispatch('loadUserInfo', data)
-
-        window.location.href = data.returnUrl || '/'
-      } catch (err) {
-        this.$router.replace('/')
-        console.log(err)
-      }
-    }
-  }
-}
-</script>

+ 0 - 35
pages/platform-b2c/logout/proxy.vue

@@ -1,35 +0,0 @@
-<template>
-  <!-- Login 代理页面 -->
-  <div>
-  </div>
-</template>
-<script>
-  export default {
-    layout: 'login',
-    mounted () {
-      this.crossBefore()
-    },
-    methods: {
-      async crossBefore () {
-        try {
-          let { data } = await this.$http.get('/logout/crossBefore')
-          const params = data || {}
-          this.proxyLogout(params.askUrl, params.returnUrl, params.logoutUrl)
-        } catch (err) {
-          this.$router.replace('/')
-          console.log(err)
-        }
-      },
-      proxyLogout (askUrl, returnUrl, logoutUrl) {
-        this.$jsonp(`${askUrl}`, function (err, data) {
-          if (err) throw err
-          if (data.error) {
-            window.location.href = logoutUrl
-          } else {
-            window.location.href = returnUrl && returnUrl !== 'null' ? returnUrl : '/'
-          }
-        })
-      }
-    }
-  }
-</script>