Ver Fonte

开通卖家中心登录验证

yangc há 8 anos atrás
pai
commit
2c836673a3
3 ficheiros alterados com 32 adições e 8 exclusões
  1. 2 8
      middleware/authenticated.js
  2. 15 0
      pages/auth/login.vue
  3. 15 0
      pages/register-saler/index.vue

+ 2 - 8
middleware/authenticated.js

@@ -1,13 +1,7 @@
-
-export default function ({ isServer, store, req, redirect }) {
+export default function ({ isServer, store, req, redirect, route }) {
   // If nuxt generate, pass this middleware
   if (isServer && !req) return
-
   if (!store.state.option.user.logged) {
-    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)
-      }
-    })
+    return redirect('/auth/login')
   }
 }

+ 15 - 0
pages/auth/login.vue

@@ -0,0 +1,15 @@
+<template>
+
+</template>
+<script>
+  export default {
+    layout: 'login',
+    mounted () {
+      this.$http.get('/login/page', {params: {returnUrl: window.location.protocol + '//' + window.location.host}}).then(response => {
+        if (response.data) {
+          window.location.href = response.data.content + '&baseUrl=' + encodeURIComponent(window.location.protocol + '//' + window.location.host + response.data.baseUrl)
+        }
+      })
+    }
+  }
+</script>

+ 15 - 0
pages/register-saler/index.vue

@@ -10,10 +10,25 @@
   import { RegHeader, Register } from '~components/register-saler'
   export default {
     name: 'index',
+    middleware: 'authenticated',
     components: {
       RegHeader,
       Register
+    },
+    computed: {
+      user () {
+        return this.$store.state.option.user
+      }
     }
+//    mounted () {
+//      if (!this.user.logged) {
+//        this.$http.get('/login/page', {params: {returnUrl: window.location.href}}).then(response => {
+//          if (response.data) {
+//            window.location.href = response.data.content + '&baseUrl=' + encodeURIComponent(window.location.protocol + '//' + window.location.host + response.data.baseUrl)
+//          }
+//        })
+//      }
+//    }
   }
 </script>
 <style>