const promisic = function(func){
return function(params={}){
return new Promise((resolve,reject) =>{
const args = Object.assign(params,{
success:(res)=>{
resolve(res);
},
fail:(error)=>{
reject(error);
}
});
func(args);
});
}
}
调用
promisic(wx.request)({
url:'',
data: data,
})
static async request({url,data,callback,method='GET'}){
await promisic(wx.request)({
url:`${config.apiBaseUrl}${url}`,
data:data,
method:method,
header:{
appkey:config.appkey,
clientkey:config.clientkey
}
})
}