소스 검색

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)
           }