| | |
| | | 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', |
| | |
| | | // window.sessionStorage.setItem('policeCameravideoIsLoginTimeout', JSON.stringify(true)) |
| | | // } |
| | | |
| | | |
| | | return res.data ? res.data : {} |
| | | |
| | | |
| | | |
| | | /* //return res.data ? res.data : {}; */ |
| | | }, |
| | |
| | | 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:"", |
| | |
| | | |
| | | } 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) |
| | | } |