|
@@ -56,14 +56,21 @@ function request(url, data = {}, method = "POST", header = "application/x-www-fo
|
|
|
},
|
|
|
success: function (res) {
|
|
|
// wx.hideLoading();
|
|
|
-
|
|
|
+
|
|
|
|
|
|
if (!Object.prototype.hasOwnProperty.call(res.data, 'data')) {
|
|
|
res.data.data = res.data.message;
|
|
|
+
|
|
|
+ for (let key in res.data.message) {
|
|
|
+ //为了兼容旧接口数据
|
|
|
+ if (key != 'data') {
|
|
|
+ res.data[key] = res.data.message[key]
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- if (!Object.prototype.hasOwnProperty.call(res.data, 'errno')) {
|
|
|
- if(Object.prototype.hasOwnProperty.call(res.data, 'code')){
|
|
|
+ if (!Object.prototype.hasOwnProperty.call(res.data, 'errno')) {
|
|
|
+ if (Object.prototype.hasOwnProperty.call(res.data, 'code')) {
|
|
|
res.data.errno = (res.data.code === 200 || res.data.code === 0) ? 0 : res.data.code;
|
|
|
}
|
|
|
}
|
|
@@ -73,10 +80,10 @@ function request(url, data = {}, method = "POST", header = "application/x-www-fo
|
|
|
let pages = getCurrentPages()
|
|
|
let currPage = pages[pages.length - 1].route
|
|
|
let notLogins = ['pages/index/index', 'pages/catalog/catalog', 'pages/category/category', 'pages/ucenter/index/index']
|
|
|
- console.log('test',res.data.code == 401 && !~notLogins.indexOf(currPage))
|
|
|
-
|
|
|
+ console.log('test', res.data.code == 401 && !~notLogins.indexOf(currPage))
|
|
|
+ console.log(res)
|
|
|
if (res.data.code == 401 && !~notLogins.indexOf(currPage)) {
|
|
|
-
|
|
|
+
|
|
|
resolve(res.data);
|
|
|
gotoLogin()
|
|
|
} else {
|
|
@@ -90,6 +97,7 @@ function request(url, data = {}, method = "POST", header = "application/x-www-fo
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ console.error(res.data)
|
|
|
jx(res.data)
|
|
|
resolve(res.data);
|
|
|
}
|