Browse Source

feat: 优化登陆,自定义tab等

xiansin 2 years ago
parent
commit
14625029d2
3 changed files with 10 additions and 4 deletions
  1. 3 0
      mini/App.vue
  2. 1 1
      mini/components/TabBar/index.vue
  3. 6 3
      mini/utils/request/responseInterceptors.js

+ 3 - 0
mini/App.vue

xqd
@@ -1,6 +1,9 @@
 <script>
 
 export default {
+  globalData: {
+    isLogin: false
+  },
   async onLaunch(options) {
     console.log('App Launch')
     const path = options.path ? '/' + options.path : '/pages/index/index'

+ 1 - 1
mini/components/TabBar/index.vue

xqd
@@ -88,7 +88,7 @@ export default {
     },
     calc() {
       let active = 1
-      const page = uni.$u.page()
+      const page = uni.$u.page().replace('//', '/')
       this.list.forEach((obj, index) => {
         if (obj.pagePath === page) {
           active = index

+ 6 - 3
mini/utils/request/responseInterceptors.js

xqd
@@ -25,9 +25,12 @@ module.exports = vm => {
       // 401 登录超时 402 需要登录
       if (typeof error.data.status_code !== 'undefined') {
         if (error.data.status_code === 401 || error.data.status_code === 402) {
-          uni.reLaunch({
-            url: '/pages/login'
-          })
+          if (!getApp().globalData.isLogin) {
+            getApp().globalData.isLogin = true
+            uni.reLaunch({
+              url: '/pages/login'
+            })
+          }
           return Promise.resolve()
         }
       }