You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

46 lines
954 B

// 封装微信request 请求
function request(url, data = {}, method = "GET", params) {
let ajaxTimes = 0
var contentType = params && params.header ? params.header['Content-Type'] : 'application/json'
// console.log(params)
ajaxTimes++
// uni.showLoading({
// title: '加载中',
// mask: true,
// })
return new Promise(function(resolve, reject) {
console.log(data)
uni.request({
url: url,
data: data,
method: method,
header: {
'Content-Type': contentType,
// 'Authorization': wx.getStorageSync('token')
'token': wx.getStorageSync('token')
},
// 如果成功
success: (res) => {
resolve(res.data)
},
// 如果失败
fail: (err) => {
// console.log(err)
reject(err)
},
// 完成
complete: () => {
// console.log('完成')
ajaxTimes--
// console.log(ajaxTimes)
if (ajaxTimes === 0) {
uni.hideLoading()
}
}
})
})
}
module.exports = {
request,
}