GR:function(a,b,c,d){//全局请求
let data=c;//data数据
data.token=wx.getStorageSync('token');//默认追加全局需要的参数
wx.request({
url: 'https:xxxxxxx'+b,//全局api接口拼接
method: a,//请求方式
data: data,//传递是数据
header: {
'Content-Type': 'application/x-www-form-urlencoded'
},
success: d;//回调
})
}
2.调用
let data={name:777};
app.GR('GET','XXXXX',data,function(res){
console.log("请求成功")
})
网友评论