| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- <template>
- <uv-tabbar :customStyle="customStyle" activeColor="#0061FF" inactiveColor="#A6A6A6" :value="activeIndex">
- <uv-tabbar-item v-for="(item, index) in allList" :key="item.id" :text="item.text" :icon="item.icon" @click="handleChange(index, item)"></uv-tabbar-item>
- </uv-tabbar>
- </template>
- <script setup>
- import { ref } from 'vue'
- import { onLoad } from '@dcloudio/uni-app'
- // 展示的导航栏
- const allList = ref([])
- // 教师权限导航栏数组
- const tabList = ref([
- {
- id: 1,
- text: '访客预约',
- icon: 'account'
- },
- {
- id: 2,
- text: '到访代办',
- icon: 'file-text'
- },
- {
- id: 3,
- text: '预约记录',
- icon: 'clock'
- }
- ])
- // 家长权限导航栏数组
- const tabList2 = ref([
- {
- id: 1,
- text: '访客预约',
- icon: 'account'
- },
- {
- id: 3,
- text: '预约记录',
- icon: 'clock'
- }
- ])
- // 当前高亮索引
- const activeIndex = ref(0)
- // 导航栏样式
- const customStyle = {
- height: '120rpx'
- }
- onLoad(() => {
- const userType = uni.getStorageSync('userInfo').identityId
- if (userType == 1) {
- allList.value = tabList2.value
- } else if (userType == 2) {
- allList.value = tabList2.value
- } else {
- allList.value = tabList.value
- }
- const i = uni.getStorageSync('Tab-activeIndex')
- i ? (activeIndex.value = i) : (activeIndex.value = 0)
- })
- // 切换导航栏回调
- const handleChange = (index, item) => {
- if (index != activeIndex.value) {
- activeIndex.value = index
- uni.setStorageSync('Tab-activeIndex', activeIndex.value)
- if (item.icon === 'account') {
- uni.redirectTo({
- url: '/pagesReservation/reservation/reservation'
- })
- } else if (item.icon === 'file-text') {
- uni.redirectTo({
- url: '/pagesReservation/backlog/backlog'
- })
- } else if (item.icon === 'clock') {
- uni.redirectTo({
- url: '/pagesReservation/record/record'
- })
- }
- }
- }
- </script>
- <style lang="scss" scoped></style>
|