|
|
|
@ -23,7 +23,7 @@ axios.defaults.headers.post['Content-Type'] = 'application/json;charset=UTF-8'; |
|
|
|
|
|
|
|
|
|
// 请求拦截器
|
|
|
|
|
axios.interceptors.request.use(config => { |
|
|
|
|
let token = store.state.token |
|
|
|
|
let token = store.state.loginToken |
|
|
|
|
if(token){ |
|
|
|
|
config.headers.token = token |
|
|
|
|
} |
|
|
|
@ -124,6 +124,10 @@ export function getToken(){ |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
let tokenStatus = { |
|
|
|
|
0: '用户未登录,请登录后操作!', |
|
|
|
|
1: 'token错误,请重新登录!' |
|
|
|
|
} |
|
|
|
|
/** |
|
|
|
|
* get方法,对应get请求 |
|
|
|
|
*/ |
|
|
|
@ -134,6 +138,11 @@ export function get(url, params){ |
|
|
|
|
params: params |
|
|
|
|
}) |
|
|
|
|
.then(res => { |
|
|
|
|
if(typeof res.data == 'number'){ |
|
|
|
|
this.$message.error(tokenStatus[res.data])
|
|
|
|
|
setTimeout(logouts,1500) |
|
|
|
|
return false |
|
|
|
|
} |
|
|
|
|
if(res.data.code == 99999){ |
|
|
|
|
this.$message.error( |
|
|
|
|
res.data.message |
|
|
|
@ -228,6 +237,11 @@ export function post(url, params) { |
|
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
|
axios.post(url,params) |
|
|
|
|
.then(res => { |
|
|
|
|
if(typeof res.data == 'number'){ |
|
|
|
|
this.$message.error(tokenStatus[res.data])
|
|
|
|
|
setTimeout(logouts,1500) |
|
|
|
|
return false |
|
|
|
|
} |
|
|
|
|
if(res.data.code == 99999){ |
|
|
|
|
this.$message.error( |
|
|
|
|
res.data.message |
|
|
|
@ -325,6 +339,11 @@ export function post(url, params) { |
|
|
|
|
return new Promise((resolve, reject) =>{ |
|
|
|
|
axios.delete(url, {params}) |
|
|
|
|
.then(res => { |
|
|
|
|
if(typeof res.data == 'number'){ |
|
|
|
|
this.$message.error(tokenStatus[res.data])
|
|
|
|
|
setTimeout(logouts,1500) |
|
|
|
|
return false |
|
|
|
|
} |
|
|
|
|
if(res.data.code == 99999){ |
|
|
|
|
this.$message.error( |
|
|
|
|
res.data.message |
|
|
|
@ -408,6 +427,11 @@ export function delbody(url, params){ |
|
|
|
|
return new Promise((resolve, reject) =>{ |
|
|
|
|
axios.delete(url, {data: params}) |
|
|
|
|
.then(res => { |
|
|
|
|
if(typeof res.data == 'number'){ |
|
|
|
|
this.$message.error(tokenStatus[res.data])
|
|
|
|
|
setTimeout(logouts,1500) |
|
|
|
|
return false |
|
|
|
|
} |
|
|
|
|
if(res.data.code == 99999){ |
|
|
|
|
this.$message.error( |
|
|
|
|
res.data.message |
|
|
|
@ -496,6 +520,11 @@ export function put(url, params){ |
|
|
|
|
return new Promise((resolve, reject) =>{ |
|
|
|
|
axios.put(url, params) |
|
|
|
|
.then(res => { |
|
|
|
|
if(typeof res.data == 'number'){ |
|
|
|
|
this.$message.error(tokenStatus[res.data])
|
|
|
|
|
setTimeout(logouts,1500) |
|
|
|
|
return false |
|
|
|
|
} |
|
|
|
|
if(res.data.code == 99999){ |
|
|
|
|
this.$message.error( |
|
|
|
|
res.data.message |
|
|
|
|