|
@@ -57,35 +57,44 @@ function request(url, data = {}, method = "POST", header = "application/x-www-fo
|
|
|
success: function (res) {
|
|
|
// wx.hideLoading();
|
|
|
if (res.statusCode == 200) {
|
|
|
-
|
|
|
- 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']
|
|
|
- if (res.data.errno == 401 && !~notLogins.indexOf(currPage)) {
|
|
|
+
|
|
|
+ if(res.data.code == 3012){
|
|
|
+ wx.clearStorageSync('token')
|
|
|
+ //兼容删除微信用户,导致登录状态依然存在。会白屏
|
|
|
gotoLogin()
|
|
|
- } else {
|
|
|
- const jx = (data) => {
|
|
|
- for (let key in data) {
|
|
|
- if (data[key] instanceof Object) {
|
|
|
- jx(data[key])
|
|
|
- } else if (key === 'list_pic_url') {
|
|
|
- data[key] = data[key] && data[key].split('#$#')[0]
|
|
|
- console.error(`${key}: ${data[key]}`, data)
|
|
|
+ }else{
|
|
|
+ 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']
|
|
|
+ if (res.data.errno == 401 && !~notLogins.indexOf(currPage)) {
|
|
|
+ gotoLogin()
|
|
|
+ } else {
|
|
|
+ const jx = (data) => {
|
|
|
+ for (let key in data) {
|
|
|
+ if (data[key] instanceof Object) {
|
|
|
+ jx(data[key])
|
|
|
+ } else if (key === 'list_pic_url') {
|
|
|
+ data[key] = data[key] && data[key].split('#$#')[0]
|
|
|
+ console.error(`${key}: ${data[key]}`, data)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ jx(res.data)
|
|
|
+ resolve(res.data);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if (url === api.UserInfo) {
|
|
|
+ let info = wx.getStorageSync('userInfo')
|
|
|
+ info.isAdmin = res.data.data.isAdmin
|
|
|
+ wx.setStorageSync('userInfo', info);
|
|
|
}
|
|
|
- jx(res.data)
|
|
|
- resolve(res.data);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- if (url === api.UserInfo) {
|
|
|
- let info = wx.getStorageSync('userInfo')
|
|
|
- info.isAdmin = res.data.data.isAdmin
|
|
|
- wx.setStorageSync('userInfo', info);
|
|
|
}
|
|
|
+
|
|
|
|
|
|
} else {
|
|
|
+
|
|
|
+
|
|
|
reject(res.errMsg);
|
|
|
}
|
|
|
|