患者 3.1
This commit is contained in:
+18
-13
@@ -9,10 +9,10 @@ let host=hostConfig().host;
|
||||
function request(url, method, data, loding = false) {
|
||||
if(isLock) return;
|
||||
if (loding) {
|
||||
wx.showLoading({
|
||||
title: '加载中',
|
||||
mask: true
|
||||
})
|
||||
// wx.showLoading({
|
||||
// title: '加载中',
|
||||
// mask: true
|
||||
// })
|
||||
}
|
||||
let token = wx.getStorageSync('AUTH_TOKEN');
|
||||
if (!token) {
|
||||
@@ -36,13 +36,16 @@ function request(url, method, data, loding = false) {
|
||||
'Authorization': 'Bearer ' + token
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
console.log('1111111111111111111');
|
||||
console.log(host + url)
|
||||
wx.request({
|
||||
url: host + url,
|
||||
method: method,
|
||||
data: data,
|
||||
header: header,
|
||||
success: function (res) {
|
||||
|
||||
console.log('-----------------------------');
|
||||
console.log(res);
|
||||
var Authorization_token = res.header.Authorization;
|
||||
if (Authorization_token) {
|
||||
wx.setStorageSync('AUTH_TOKEN', Authorization_token); //当token快过期时,服务器会返回新token,本地刷新
|
||||
@@ -97,14 +100,16 @@ function request(url, method, data, loding = false) {
|
||||
}
|
||||
isLock=false;
|
||||
},
|
||||
// fail: function (res) {
|
||||
// wx.showToast({
|
||||
// title: '网络错误,请稍后再试',
|
||||
// icon: 'none',
|
||||
// duration: 2000
|
||||
// })
|
||||
// reject(false)
|
||||
// }
|
||||
fail: function (res) {
|
||||
console.log(res)
|
||||
console.log(2222222222222222);
|
||||
// wx.showToast({
|
||||
// title: '网络错误,请稍后再试',
|
||||
// icon: 'none',
|
||||
// duration: 2000
|
||||
// })
|
||||
// reject(false)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user