| | |
| | | return { |
| | | safeAreaBottom: 0, |
| | | showLogin: false, |
| | | currentPath: '', |
| | | memberTabList: [ |
| | | { |
| | | text: '首页', |
| | |
| | | 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() { |
| | |
| | | }, |
| | | 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 |