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.
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* 分包使用:https://developers.weixin.qq.com/miniprogram/dev/framework/subpackages/basic.html
|
|
|
|
|
*
|
|
|
|
|
* @param {string} url
|
|
|
|
|
* @param {GET|POST} method
|
|
|
|
|
* @param {string/object/ArrayBuffer} data
|
|
|
|
|
*/
|
|
|
|
|
function request(url,method,data) {
|
|
|
|
|
wx.showLoading({
|
|
|
|
|
title: '加载数据...',
|
|
|
|
|
mask:true
|
|
|
|
|
})
|
|
|
|
|
const promise = new Promise((resolve, reject) => {
|
|
|
|
|
wx.request({
|
|
|
|
|
url: url,
|
|
|
|
|
method:method,
|
|
|
|
|
data:data,
|
|
|
|
|
header: {
|
|
|
|
|
'Content-Type': 'application/x-www-form-urlencoded'
|
|
|
|
|
},
|
|
|
|
|
success(res){
|
|
|
|
|
resolve(res)
|
|
|
|
|
},
|
|
|
|
|
fail(err){
|
|
|
|
|
reject(err)
|
|
|
|
|
},
|
|
|
|
|
complete(){
|
|
|
|
|
wx.hideLoading()
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
return promise;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
|
request
|
|
|
|
|
}
|