域名备案通过已经两天,服务器配置都没有问题,路径也没有问题。get后台请求成功,获取不到数据。
/**
* get请求
*/
_get(url, data, success, fail, complete, check_login) {
wx.showNavigationBarLoading();
let _this = this;
// 构造请求参数
data = data || {};
data.wxapp_id = _this.getWxappId();
// if (typeof check_login === 'undefined')
// check_login = true;
// 构造get请求
let request = () => {
data.token = wx.getStorageSync('token');
wx.request({
url: _this.api_root + url,
header: {
'content-type': 'application/json'
},
data: data,
success(res) {
if (res.statusCode !== 200 || typeof res.data !== 'object') {
console.log(res);
_this.showError('网络请求出错');
return false;
}
if (res.data.code === -1) {
// 登录态失效, 重新登录
wx.hideNavigationBarLoading();
_this.doLogin(2);
} else if (res.data.code === 0) {
_this.showError(res.data.msg, () => {
fail && fail(res);
});
return false;
} else {
success && success(res.data);
}
},
fail(res) {
_this.showError(res.errMsg, () => {
fail && fail(res);
});
},
complete(res) {
wx.hideNavigationBarLoading();
complete && complete(res);
},
});
};