deguodaigou/utils/bin.js

57 lines
1.2 KiB
JavaScript
Raw Normal View History

2019-12-23 14:13:27 +08:00
//请求接口
let request = function (obj){
let {
url,
data,
method,
header,
dataType,
responseType,
complete,
name,
urldata
} = obj
url="http://daigou.sdbairui.com/index.php/WXAPI/" + url
let text = ""
for(let i in urldata){
if(urldata[i] == undefined){
text += `/${i}`
}else{
text += `/${i}/${urldata[i]}`
}
}
url+=text
// if(method == "POST" || method == "post"){
// if(header == undefined){
// header ={}
// }
// header['content-type'] = "application/x-www-form-urlencoded"
// }
if(data == undefined){
data = {}
}
data[name || 'openid'] = wx.getStorageSync("openid")
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
2019-12-13 10:29:54 +08:00
}