This commit is contained in:
zhangmanman
2021-08-09 15:57:37 +08:00
parent c661dd0e16
commit 540d76bdb8
158 changed files with 4914 additions and 788 deletions

View File

@@ -11,13 +11,20 @@ const api = "https://lifetest.ysd-bs.com/api/" //正式地址
const header = {
"Accept" : "application/json"
}
let isToken = true
/**
* 请求
* @property {Object} req
*/
const req = (obj) => {
const req = (obj, noToken) => {
// 检查是否无需要token
if(noToken != undefined){
isToken = noToken
}
// header
if(obj.token){
header.Authorization = obj.token || ''
@@ -32,7 +39,11 @@ const req = (obj) => {
"Accept" : "application/json",
"Authorization" : wx.getStorageSync("token") || ""
}
if(!isToken){
obj.header.Authorization = ''
}
wx.request({
url : api + obj.url,
header : obj.header || {},
@@ -60,6 +71,9 @@ const req = (obj) => {
icon : "none"
})
reject(err)
},
complete(){
if(!isToken) isToken = true
}
})
})