/**
* 封封微信的的request obj是操作成功之后的调用 catch_obj是如果失败怎么调用
*/
/**
* 封封微信的的request
*/
function request(url, data = {},obj={},catch_obj={}, method = "POST") {
return new Promise(function (resolve, reject) {
wx.request({
url: url,
data: data,
method: method,
header: {
'token': wx.getStorageSync('token')
},
success: function (res) {
if (res.data.code ==200){
resolve(res.data);
}else{
reject(res.data);
}
},
fail: function (err) {
console.log("请求失败了");
reject()
}
})
}).then(obj).catch(function (res) {
if (res.code == 101 || res.code == 102 || res.code == 104){
wx.navigateTo({
url: '/pages/auth/auth/auth'
})
}else if(res.code != null){
wx.showToast({
title: res.message,
icon: 'none',
duration: 2000
})
}
catch_obj()
});
}
util.request("URL", { },function(res){
console.log(111)
console.log(res)
}, function () {
that.setData({
disabled: false
})
})