From 999f9a47da7783388d0214b9f8d987ea2d9f2916 Mon Sep 17 00:00:00 2001 From: heyujie <516346543@qq.com> Date: 星期一, 11 四月 2022 13:55:05 +0800 Subject: [PATCH] 子账户管理新 --- src/scripts/httpRequest.ts | 31 ++++++++++++++++++++----------- 1 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/scripts/httpRequest.ts b/src/scripts/httpRequest.ts index 8ac414b..194dfe6 100644 --- a/src/scripts/httpRequest.ts +++ b/src/scripts/httpRequest.ts @@ -2,7 +2,7 @@ import axios from 'axios' import qs from 'qs' import { Notification } from 'element-ui' -// import router from '@/router' + import router from '@/router' const Axios = axios.create({ responseType: 'json', @@ -78,7 +78,10 @@ // window.sessionStorage.setItem('policeCameravideoIsLoginTimeout', JSON.stringify(true)) // } + return res.data ? res.data : {} + + /* //return res.data ? res.data : {}; */ }, @@ -96,10 +99,9 @@ case 401: errJson.status = error.response.status errJson.message = '鏈巿鏉冿紝璇烽噸鏂扮櫥褰�(401)' - window.parent.postMessage({ - msg: "logout" - }, '*') - // console.log("鏍囧織浣嶏細",AuthData.isLoginout) + router.push({ + path: '/login' + }) // if (!AuthData.isLoginout) { // Notification({ // title:"", @@ -157,16 +159,23 @@ } else { errJson.message = '杩炴帴鏈嶅姟鍣ㄥけ璐�!' - Notification({ - title: '', - showClose: true, - message: '杩炴帴鏈嶅姟鍣ㄥけ璐�!', - type: 'error' - }) + // router.push({ // path: '/login' // }); } + console.log(error.response); + + if(error.response&&error.response.data&&!error.response.data.success ) { + errJson.message =error.response.data.msg + } + + Notification({ + title: '閿欒', + showClose: true, + message:errJson.message, + type: 'error' + }) // 杩斿洖 response 閲岀殑閿欒淇℃伅 return Promise.reject(errJson) } -- Gitblit v1.8.0