deguodaigou/utils/bin.js

44 lines
915 B
JavaScript
Raw Normal View History

2019-12-13 10:29:54 +08:00
//请求接口
let request = function (obj){
let {
url,
2019-12-18 18:10:15 +08:00
data,
2019-12-13 10:29:54 +08:00
method,
header,
dataType,
responseType,
complete
} = obj
2019-12-18 18:10:15 +08:00
url="http://daigou.sdbairui.com/index.php/WXAPI/" + url
if(method == "POST" || method == "post"){
if(header == undefined){
header ={}
}
header['content-type'] = "application/x-www-form-urlencoded"
}
2019-12-19 14:18:09 +08:00
if(data == undefined){
data = {}
}
data.openid = wx.getStorageSync("openid")
2019-12-13 10:29:54 +08:00
return new Promise((res,rej)=>{
2019-12-18 18:10:15 +08:00
wx.request({
2019-12-13 10:29:54 +08:00
url,
2019-12-18 18:10:15 +08:00
data,
2019-12-13 10:29:54 +08:00
method,
header,
dataType,
responseType,
success(data){
res(data)
},
fail(data){
rej(data)
},
complete
})
})
}
module.exports = {
request
}