54 lines
1.1 KiB
Vue
54 lines
1.1 KiB
Vue
<template>
|
|
<wd-tabbar
|
|
v-model="active"
|
|
fixed
|
|
bordered
|
|
safe-area-inset-bottom
|
|
placeholder
|
|
active-color="#1677FF"
|
|
inactive-color="#8A9199"
|
|
@change="onChange"
|
|
>
|
|
<wd-tabbar-item title="消息" icon="chat" />
|
|
<wd-tabbar-item title="通讯录" icon="usergroup" />
|
|
<wd-tabbar-item title="打卡" icon="clock" />
|
|
<wd-tabbar-item title="工作台" icon="app" />
|
|
<wd-tabbar-item title="我" icon="user" />
|
|
</wd-tabbar>
|
|
</template>
|
|
|
|
<script>
|
|
const PATHS = [
|
|
'/pages/tabs/messages',
|
|
'/pages/tabs/contacts',
|
|
'/pages/tabs/clock',
|
|
'/pages/tabs/workbench',
|
|
'/pages/tabs/me'
|
|
]
|
|
|
|
export default {
|
|
data() {
|
|
return { active: 0 }
|
|
},
|
|
mounted() {
|
|
this.sync()
|
|
uni.$on('fy-tab', (i) => { this.active = i })
|
|
},
|
|
unmounted() {
|
|
uni.$off('fy-tab')
|
|
},
|
|
methods: {
|
|
sync() {
|
|
const pages = getCurrentPages()
|
|
const route = pages.length ? '/' + pages[pages.length - 1].route : ''
|
|
const i = PATHS.indexOf(route)
|
|
if (i >= 0) this.active = i
|
|
},
|
|
onChange({ value }) {
|
|
const url = PATHS[value]
|
|
if (url) uni.switchTab({ url })
|
|
}
|
|
}
|
|
}
|
|
</script>
|