所有请求都是封装到这个函数里面:
wxrequest:function(action,params,callback){
var that=this;
wx.request({
// url: 'http://localhost:3000/wx/emo',
url: 'https://XXX.leanapp.cn/wx/emo',
method:'get',
data: {
userid:that.globalData.userid,
action: action,
params:params
},
header: {
'Content-Type': 'application/json'
},
success: function(res) {
if(res.data.sendMsg!='ok'){
callback(res.data.getdata);
}
else{
callback(null, res.data.getdata);
}
},
fail:function(err){
console.log(err);
callback('网络出现故障,请稍后重试');
}
})
},