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