|
|
|
|
@ -212,7 +212,67 @@ const request = options => {
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (res.data.hasOwnProperty("errcode")) {
|
|
|
|
|
|
|
|
|
|
// token鉴权失败
|
|
|
|
|
if (res.data?.errcode === 40001) {
|
|
|
|
|
if(options.requestType=='bd'){
|
|
|
|
|
|
|
|
|
|
uni.showModal({
|
|
|
|
|
title:'用户信息已失效',
|
|
|
|
|
confirmText:'重新登陆',
|
|
|
|
|
success:function(res){
|
|
|
|
|
if(res.confirm){
|
|
|
|
|
uni.removeStorageSync(userInfo_BD_token)
|
|
|
|
|
uni.redirectTo({
|
|
|
|
|
url:'/pages/index/login'
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
|
}else{
|
|
|
|
|
uni.showModal({
|
|
|
|
|
title:'用户信息已失效',
|
|
|
|
|
confirmText:'重新获取',
|
|
|
|
|
success:function(res){
|
|
|
|
|
if(res.confirm){
|
|
|
|
|
uni.removeStorageSync(user_info_key)
|
|
|
|
|
uni.login({
|
|
|
|
|
provider: 'weixin',
|
|
|
|
|
success: (res) => {
|
|
|
|
|
let url = HOST + '/api/mobile/user/login?code=' + res.code;
|
|
|
|
|
uni.request({
|
|
|
|
|
url: url,
|
|
|
|
|
method: 'GET',
|
|
|
|
|
success: result => {
|
|
|
|
|
let user_info = result.data
|
|
|
|
|
uni.setStorageSync(user_info_key, user_info)
|
|
|
|
|
|
|
|
|
|
const currentPage = getCurrentPages()[getCurrentPages().length - 1];
|
|
|
|
|
const currentPagePath ="/" + currentPage.route;
|
|
|
|
|
const currentPageOptions = currentPage.options;
|
|
|
|
|
const queryString = Object.keys(currentPageOptions)
|
|
|
|
|
.map(key => `${key}=${currentPageOptions[key]}`)
|
|
|
|
|
.join('&');
|
|
|
|
|
// 使用uni.reLaunch方法刷新当前页面
|
|
|
|
|
|
|
|
|
|
uni.reLaunch({
|
|
|
|
|
url: `${currentPagePath}?${queryString}`
|
|
|
|
|
});
|
|
|
|
|
console.log("reLaunch",`${currentPagePath}?${queryString}`)
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
// login end
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}) // showConfirm end
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (options.utilFail != undefined) {
|
|
|
|
|
// console.log("res",res.data.errmsg)
|
|
|
|
|
options.utilFail(res.data.errmsg || '接口发生未知错误');
|
|
|
|
|
|