Get 请求的 请求头
post(url, postData, doSuccess, doFail) {
wx.request({
//项目的真正接口,通过字符串拼接方式实现
url: this.globalData.api + url,
header: {
"content-type": "application/json;charset=UTF-8",
"content-type": "application/x-www-form-urlencoded"
},
data: postData,
method: 'POST',
success: function (res) {
//参数值为res.data,直接将返回的数据传入
doSuccess(res.data);
},
fail: function () {
doFail();
},
})
},
//GET请求,不需传参,直接URL调用,
get(url, doSuccess, doFail) {
wx.request({
url: this.globalData.api + url,
header: {
"content-type": "application/json;charset=UTF-8"
},
method: 'GET',
success: function (res) {
doSuccess(res.data);
},
fail: function () {
doFail();
},
})
},
globalData: {
appid: "wxa029a958fd744f64",
api: "https://www.3daitech.cn:8443",
approot: "",
userInfo: null,
}
网友评论