deguodaigou/utils/bin.js
2019-12-18 18:10:15 +08:00

40 lines
818 B
JavaScript

//请求接口
let request = function (obj){
let {
url,
data,
method,
header,
dataType,
responseType,
complete
} = obj
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"
}
return new Promise((res,rej)=>{
wx.request({
url,
data,
method,
header,
dataType,
responseType,
success(data){
res(data)
},
fail(data){
rej(data)
},
complete
})
})
}
module.exports = {
request
}