|
|
|
@ -2,7 +2,7 @@
|
|
|
|
|
* @Author: ch
|
|
|
|
|
* @Date: 2022-03-17 17:42:32
|
|
|
|
|
* @LastEditors: ch
|
|
|
|
|
* @LastEditTime: 2022-06-28 11:38:02
|
|
|
|
|
* @LastEditTime: 2022-06-29 16:02:20
|
|
|
|
|
* @Description: 项目接口请求统一处理器,返回一个需要token和不需要token的请求封装方法
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
@ -107,24 +107,25 @@ MsbRequestTk.baseUrl = ENV.baseUrl;
|
|
|
|
|
MsbRequestTk.use('request', (option) => {
|
|
|
|
|
const token = $store.state.token;
|
|
|
|
|
option.header.uid = uuid;
|
|
|
|
|
if(!token){
|
|
|
|
|
|
|
|
|
|
if(!token && && !config.headers.notVerifyToken){
|
|
|
|
|
// 登录状态处理,没有token直接跳转至登录
|
|
|
|
|
uni.redirectTo({
|
|
|
|
|
url: '/login'
|
|
|
|
|
});
|
|
|
|
|
return Promise.reject({message:'要先登录才能操作哦~'});
|
|
|
|
|
}else{
|
|
|
|
|
option.header = {...option.header, Authorization:token};
|
|
|
|
|
|
|
|
|
|
if(option.header.repeat){
|
|
|
|
|
// 如果当前请求不允许重复调用,则检查重复请求,当前接口有正在请求则不发起请求
|
|
|
|
|
const isRepeatVerify = repeatVerify(option);
|
|
|
|
|
if(isRepeatVerify){
|
|
|
|
|
return isRepeatVerify;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
delete config.headers.notVerifyToken
|
|
|
|
|
option.header = {...option.header, Authorization:token};
|
|
|
|
|
|
|
|
|
|
if(option.header.repeat){
|
|
|
|
|
// 如果当前请求不允许重复调用,则检查重复请求,当前接口有正在请求则不发起请求
|
|
|
|
|
const isRepeatVerify = repeatVerify(option);
|
|
|
|
|
if(isRepeatVerify){
|
|
|
|
|
return isRepeatVerify;
|
|
|
|
|
}
|
|
|
|
|
return option;
|
|
|
|
|
}
|
|
|
|
|
return option;
|
|
|
|
|
})
|
|
|
|
|
MsbRequestTk.use('success', successIntercept);
|
|
|
|
|
MsbRequestTk.use('error', errorIntercept);
|
|
|
|
|