3.23更新 登录页面请求报错
This commit is contained in:
parent
da0676441b
commit
4ae2b50539
@ -25,9 +25,9 @@ Component({
|
||||
this.triggerEvent('handleFocus',true)
|
||||
},
|
||||
goInquirtForm(){
|
||||
wx.navigateTo({
|
||||
url: '/pages/sickDetail/sickDetail',
|
||||
})
|
||||
// wx.navigateTo({
|
||||
// url: '/patient/pages/expertDetail/expertDetail?doctor_id=516904855116750848',
|
||||
// })
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@ -23,7 +23,7 @@ Page({
|
||||
is_online:0,
|
||||
sort_order:1,
|
||||
inquiry_type:'1,3',
|
||||
inquiry_mode:'1,2,6',
|
||||
inquiry_mode:'1,2',
|
||||
navName:"专家问诊",
|
||||
scrollHeight:300,
|
||||
sickList:[],
|
||||
|
||||
@ -7,15 +7,20 @@ let isLock=false;
|
||||
let host=hostConfig().host;
|
||||
//loding 是否加loading弹窗
|
||||
function request(url, method, data, loding = false) {
|
||||
if(isLock) return;
|
||||
let whitelist = ["/login/wechat_mobile_login", '/login/mobile_login','/code/phone','/patient/index',"/popup","/sign/im"];//接口白名单;
|
||||
if(whitelist.indexOf(url) != -1){
|
||||
isLock=false;
|
||||
}
|
||||
if(isLock) {
|
||||
return Promise.reject("请求被lock,正常报错");
|
||||
};
|
||||
if (loding) {
|
||||
// wx.showLoading({
|
||||
// title: '加载中',
|
||||
// mask: true
|
||||
// })
|
||||
wx.showLoading({
|
||||
title: '加载中',
|
||||
mask: true
|
||||
})
|
||||
}
|
||||
let token = wx.getStorageSync('AUTH_TOKEN');
|
||||
console.log(token);
|
||||
if (!token) {
|
||||
let freelist = ["/login/wechat_mobile_login", '/login/mobile_login','/code/phone','/patient/index',"/popup","/sign/im"];//接口白名单
|
||||
let currentUrl=getCurrentPageUrl();
|
||||
@ -45,6 +50,7 @@ function request(url, method, data, loding = false) {
|
||||
data: data,
|
||||
header: header,
|
||||
success: function (res) {
|
||||
|
||||
var Authorization_token = res.header.Authorization;
|
||||
if (Authorization_token) {
|
||||
wx.setStorageSync('AUTH_TOKEN', Authorization_token); //当token快过期时,服务器会返回新token,本地刷新
|
||||
@ -84,12 +90,14 @@ function request(url, method, data, loding = false) {
|
||||
}else if (Number(res.data.code) == 401 || Number(res.data.code) == 403 || Number(res.data.code) == 405 || Number(res.data.code) == 406) {
|
||||
let redirectUrl=formatUrl();
|
||||
if(!isLock){
|
||||
wx.setStorageSync('AUTH_TOKEN','');
|
||||
isLock=true;
|
||||
wx.reLaunch({
|
||||
url: '/patient/pages/login/login?redirectUrl='+redirectUrl
|
||||
});
|
||||
}
|
||||
|
||||
reject(res.data);
|
||||
|
||||
} else {
|
||||
wx.showToast({
|
||||
title: res.data.message,
|
||||
@ -98,6 +106,7 @@ function request(url, method, data, loding = false) {
|
||||
})
|
||||
}
|
||||
isLock=false;
|
||||
reject(res.data);
|
||||
},
|
||||
fail: function (res) {
|
||||
console.log(res)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user