|
@@ -1,7 +1,8 @@
|
|
|
import axios from 'axios'
|
|
|
-import { Message, MessageBox, Notification } from 'element-ui'
|
|
|
+import {Message, MessageBox, Notification} from 'element-ui'
|
|
|
import auth from '@/utils/auth'
|
|
|
import errorCode from '@/utils/errorCode'
|
|
|
+import MxConst from "@/common/MxConst";
|
|
|
|
|
|
axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8'
|
|
|
axios.defaults.headers['accessFrom'] = 'front'
|
|
@@ -14,12 +15,16 @@ const service = axios.create({
|
|
|
})
|
|
|
// request拦截器
|
|
|
service.interceptors.request.use(config => {
|
|
|
+ const token = auth.getToken()
|
|
|
// 附加授权header
|
|
|
delete config.headers['Authorization']
|
|
|
- if (auth.getToken() && config['withoutToken'] !== true) {
|
|
|
- config.headers['Authorization'] = 'Bearer ' + auth.getToken() // 让每个请求携带自定义token 请根据实际情况自行修改
|
|
|
+ if (token && config['withoutToken'] !== true) {
|
|
|
+ config.headers['Authorization'] = 'Bearer ' + token // 让每个请求携带自定义token 请根据实际情况自行修改
|
|
|
+ }
|
|
|
+ // auto add `NoToken` suffix for request url
|
|
|
+ if (config.autoFitNoToken && (config.withoutToken || !token)) {
|
|
|
+ config.url = config.url + 'NoToken'
|
|
|
}
|
|
|
-
|
|
|
// 映射params参数
|
|
|
if ((config.method == 'get' || config['paramsAsGet']) && config.params) {
|
|
|
let url = config.url + '?'
|
|
@@ -75,7 +80,7 @@ service.interceptors.response.use(res => {
|
|
|
cancelButtonText: '取消',
|
|
|
type: 'warning'
|
|
|
}).then(() => {
|
|
|
- const { cardNo, mobile } = res.data
|
|
|
+ const {cardNo, mobile} = res.data
|
|
|
location.href = `/renew?cardNo=${cardNo}&mobile=${mobile}`
|
|
|
})
|
|
|
return Promise.reject('error')
|
|
@@ -97,7 +102,7 @@ service.interceptors.response.use(res => {
|
|
|
},
|
|
|
error => {
|
|
|
console.log('err' + error)
|
|
|
- let { message } = error
|
|
|
+ let {message} = error
|
|
|
if (message == 'Network Error') {
|
|
|
message = '网络连接异常'
|
|
|
} else if (message.includes('timeout')) {
|