import { getCurrentPageUrl } from '@/utils/util' const app = getApp() Component({ properties: {}, data: { imageUrl: app.globalData.imageUrl, isChild: 0, active: 0, list: [ { pagePath: '/patient/pages/home/index', text: '首页', icon: 'tabbar2-1', iconActive: 'tabbar2-1-active', }, { pagePath: '/pages/knowledge/index', text: '知识库', icon: 'tabbar2-2', iconActive: 'tabbar2-2-active', }, { pagePath: '/patient/pages/file/index', text: '档案', icon: 'tabbar2-3', iconActive: 'tabbar2-3-active', }, { pagePath: '/patient/pages/my/index', text: '我的', 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 = list[index].pagePath wx.reLaunch({ url: pagePath, }) }, }, })