|
|
@ -20,11 +20,11 @@ service.interceptors.request.use(config => { |
|
|
|
config.headers.token = token |
|
|
|
config.headers.token = token |
|
|
|
} |
|
|
|
} |
|
|
|
return config; |
|
|
|
return config; |
|
|
|
}, err => { |
|
|
|
}, err => { |
|
|
|
Message.error({ |
|
|
|
Message.error({ |
|
|
|
message: '退出登陆', |
|
|
|
message: '退出登陆', |
|
|
|
onClose: function () { |
|
|
|
onClose: function () { |
|
|
|
router.push({name: 'login'}); |
|
|
|
router.push({ name: 'login' }); |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
return Promise.reject(err); |
|
|
|
return Promise.reject(err); |
|
|
@ -36,9 +36,18 @@ service.interceptors.response.use( |
|
|
|
response => { |
|
|
|
response => { |
|
|
|
const res = response.data; |
|
|
|
const res = response.data; |
|
|
|
if (res.status == 200 || res.status == 10000 || res.status == 30001) { |
|
|
|
if (res.status == 200 || res.status == 10000 || res.status == 30001) { |
|
|
|
return Promise.resolve(res).catch(e => {}); |
|
|
|
return Promise.resolve(res).catch(e => { }); |
|
|
|
|
|
|
|
} else if (res.code === 401) { |
|
|
|
|
|
|
|
// 账号互踢
|
|
|
|
|
|
|
|
if (!logouted) { |
|
|
|
|
|
|
|
Message.error(res.msg.includes('顶') ? '您的账号已在其他设备登录,您已被迫下线!' : '登录过期,请重新登录!') |
|
|
|
|
|
|
|
setTimeout(() => { |
|
|
|
|
|
|
|
history.back() |
|
|
|
|
|
|
|
}, 1500) |
|
|
|
|
|
|
|
logouted = 1 |
|
|
|
|
|
|
|
} |
|
|
|
} else if (!res.status) { |
|
|
|
} else if (!res.status) { |
|
|
|
return Promise.resolve(res).catch(e => {}); |
|
|
|
return Promise.resolve(res).catch(e => { }); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
Message.error(res.message) |
|
|
|
Message.error(res.message) |
|
|
|
return Promise.reject(res) |
|
|
|
return Promise.reject(res) |
|
|
@ -59,7 +68,6 @@ service.interceptors.response.use( |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
default: |
|
|
|
default: |
|
|
|
// Message.error(error.response.data.message)
|
|
|
|
|
|
|
|
Promise.reject(error.response); |
|
|
|
Promise.reject(error.response); |
|
|
|
} |
|
|
|
} |
|
|
|
return Promise.reject(error.response); |
|
|
|
return Promise.reject(error.response); |
|
|
@ -67,7 +75,7 @@ service.interceptors.response.use( |
|
|
|
} |
|
|
|
} |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
function get(url, params) { |
|
|
|
function get (url, params) { |
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
service.get(url, { params: params }).then(res => { |
|
|
|
service.get(url, { params: params }).then(res => { |
|
|
|
resolve(res); |
|
|
|
resolve(res); |
|
|
@ -77,7 +85,7 @@ function get(url, params) { |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function post(url, params) { |
|
|
|
function post (url, params) { |
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
service.post(url, params).then(res => { |
|
|
|
service.post(url, params).then(res => { |
|
|
|
resolve(res); |
|
|
|
resolve(res); |
|
|
@ -87,7 +95,7 @@ function post(url, params) { |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function del(url, params) { |
|
|
|
function del (url, params) { |
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
service.delete(url, { |
|
|
|
service.delete(url, { |
|
|
|
params |
|
|
|
params |
|
|
@ -99,7 +107,7 @@ function del(url, params) { |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function put(url, params) { |
|
|
|
function put (url, params) { |
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
service.put(url, params).then(res => { |
|
|
|
service.put(url, params).then(res => { |
|
|
|
resolve(res); |
|
|
|
resolve(res); |
|
|
|