MrShi
6 小时以前 fbc074229fd4736f1ae2793c9daebf04726188b2
small-program/components/custom-tabbar/custom-tabbar.vue
@@ -19,6 +19,7 @@
         return {
            safeAreaBottom: 0,
            showLogin: false,
            currentPath: '',
            memberTabList: [
               {
                  text: '首页',
@@ -76,11 +77,8 @@
      computed: {
         ...mapState(['userType', 'token']),
         currentIndex() {
            const pages = getCurrentPages()
            const currentPage = pages[pages.length - 1]
            const currentPath = '/' + currentPage.route
            const list = this.tabList
            const index = list.findIndex(item => item.pagePath === currentPath)
            const index = list.findIndex(item => item.pagePath === this.currentPath)
            return index > -1 ? index : 0
         },
         tabList() {
@@ -92,12 +90,31 @@
      },
      created() {
         this.getSafeAreaBottom()
         this.updateCurrentPath()
      },
      onShow() {
         this.updateCurrentPath()
      },
      watch: {
         userType() {
            this.$forceUpdate()
         }
      },
      activated() {
         this.$forceUpdate()
      },
      methods: {
         getSafeAreaBottom() {
            const systemInfo = uni.getSystemInfoSync()
            this.safeAreaBottom = systemInfo.safeAreaInsets.bottom || 0
         },
         updateCurrentPath() {
            const pages = getCurrentPages()
            if (pages.length > 0) {
               const currentPage = pages[pages.length - 1]
               this.currentPath = '/' + currentPage.route
            }
         },
         switchTab(item) {
            if (item.pagePath === '/pages/itinerary/itinerary' && !this.token) {
               this.showLogin = true