From c986f2f56bb153a9b6cebc74b4d9334c85ddfdda Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期一, 04 一月 2021 18:54:02 +0800
Subject: [PATCH] 2020-01-04

---
 src/api/index.js |   21 ++++++++++++---------
 1 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/src/api/index.js b/src/api/index.js
index 8d1b215..8dd84df 100644
--- a/src/api/index.js
+++ b/src/api/index.js
@@ -56,7 +56,7 @@
   return Promise.reject(error)
 })
 
-const setCurrentUrl = () => {
+const setCurrentUrl = (res) => {
   if (!!(window.history && window.history.pushState)) {
     if (window.location.href.indexOf('paramsmain') > -1) {
       let _href = window.location.href.split('#')
@@ -64,6 +64,7 @@
     }
 
     sessionStorage.clear()
+    sessionStorage.setItem('loginError', JSON.stringify({request: res.config ? res.config.data : '', response: JSON.stringify(res.data)}))
     window.history.replaceState(null, null, window.location.href.split('#')[0] + '#/login')
     window.location.reload()
   }
@@ -77,19 +78,21 @@
       response.data.ErrCode = 'E'
       return Promise.resolve(response.data)
     } else {
-      setCurrentUrl()
+      setCurrentUrl(response)
     }
   } else {
     return Promise.resolve(response.data)
   }
 }, (error) => {
-  notification.error({
-    className: 'notification-custom-error',
-    bottom: 0,
-    message: '鐘舵�佺爜-' + error.response.status + '锛岃鑱旂郴绠$悊鍛�',
-    placement: 'bottomRight',
-    duration: 15
-  })
+  if (error && error.response) {
+    notification.error({
+      className: 'notification-custom-error',
+      bottom: 0,
+      message: '鐘舵�佺爜-' + error.response.status + '锛岃鑱旂郴绠$悊鍛�',
+      placement: 'bottomRight',
+      duration: 15
+    })
+  }
   return Promise.reject(error)
 })
 

--
Gitblit v1.8.0