فهرست منبع

pref: handle app reLogin error

wangyuan 2 سال پیش
والد
کامیت
97a772ba1b
1فایلهای تغییر یافته به همراه21 افزوده شده و 1 حذف شده
  1. 21 1
      api/request.js

+ 21 - 1
api/request.js

@@ -23,8 +23,28 @@ export const wxRequest = (url,data) => {
         if (response.statusCode !== 200) {
           reject(response.data.msg || '请求错误')
         } else {
-          if (response.data.code !== '000') {
+          if (response.data.code !== '000' && response.data.code !== '102') {
             reject(response.data.msg || '请求错误')
+          } else if (response.data.code == '102') {
+            wx.hideLoading()
+            // 重新登录
+            wx.showModal({
+              content: response.data.msg,
+              confirmColor: '#333',
+              showCancel: false,
+              success (res) {
+                if (res.confirm) {
+                  app.globalData.userInfo.login = false
+                  app.globalData.accessToken = ''
+                  app.globalData.userInfo.headImg= ''
+                  app.globalData.userInfo.userName = ''
+                  app.globalData.userInfo.phoneNumber = ''
+                  wx.reLaunch({
+                    url: '/pages/my/my',
+                  })
+                }
+              }
+            })
           } else {
             resolve(response.data)
           }