import { getCurrentPageUrl } from '@/utils/util' const app = getApp() Component({ properties: {}, data: { imageUrl: app.globalData.imageUrl, isChild: 0, active: 0, list: [ { pagePath: '/patient/pages/index/index', text: '首页', pageName: 'BTN_PATHOMENAV', icon: 'tabbar2-1', iconActive: 'tabbar2-1-active', }, { pagePath: '/patient/pages/file/index', text: '档案', pageName: 'BTN_PROFILE_CLICK', icon: 'tabbar2-3', iconActive: 'tabbar2-3-active', }, { pagePath: '/patient/pages/knowledge/index', text: '知识库', pageName: 'BTN_KNOWLEDGEBASE_CLICK', icon: 'tabbar2-2', iconActive: 'tabbar2-2-active', }, { pagePath: '/patient/pages/my/index', text: '我的', pageName: 'BTN_MY_CLICK', icon: 'tabbar2-4', iconActive: 'tabbar2-4-active', }, ], }, observers: {}, lifetimes: { ready() { const pagePath = getCurrentPageUrl() const active = this.data.list.findIndex((item) => item.pagePath === pagePath) this.setData({ active, anyWhere: app.globalData.anyWhere, }) }, }, methods: { onChange() {}, handleNav(e) { const { index } = e.currentTarget.dataset const { list } = this.data const { pagePath, pageName } = list[index] if (pageName) { app.mpBehavior({ PageName: pageName }) } wx.reLaunch({ url: pagePath, }) }, }, })