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.

39 lines
859 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

/**
*
* 分包使用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
}