Browse Source

401登录拦截

yangc 7 years ago
parent
commit
5de18baa17
2 changed files with 10 additions and 3 deletions
  1. 1 1
      components/applyPurchase/SayPrice.vue
  2. 9 2
      plugins/axios.js

+ 1 - 1
components/applyPurchase/SayPrice.vue

@@ -347,7 +347,7 @@
     width: 476px;
     top: 50%;
     left: 50%;
-    margin-top: -325px;
+    margin-top: -162px;
     margin-left: -238px;
     overflow-y: auto;
     /*-webkit-box-shadow: 0 5px 15px rgba(0,0,0,.5);*/

+ 9 - 2
plugins/axios.js

@@ -65,8 +65,15 @@ service.interceptors.response.use(response => {
   }
   return response
 }, error => {
-  if (--reqCount <= 0 && !process.server) {
-    document.getElementById('loading').setAttribute('class', 'loading')
+  if (!process.server) {
+    if (--reqCount <= 0) {
+      document.getElementById('loading').setAttribute('class', 'loading')
+    }
+    // 401拦截
+    if (error.response.status === 401 && !/\/store-service\/stores$/g.test(error.response.config.url)) {
+      window.location.href = `/auth/login?returnUrl=${window.location.href}`
+      return
+    }
   }
   return Promise.reject(error)
 })