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-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
|
|
|
|
}
|