tabber.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <template>
  2. <uv-tabbar :customStyle="customStyle" activeColor="#0061FF" inactiveColor="#A6A6A6" :value="activeIndex">
  3. <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>
  4. </uv-tabbar>
  5. </template>
  6. <script setup>
  7. import { ref } from 'vue'
  8. import { onLoad } from '@dcloudio/uni-app'
  9. // 展示的导航栏
  10. const allList = ref([])
  11. // 教师权限导航栏数组
  12. const tabList = ref([
  13. {
  14. id: 1,
  15. text: '访客预约',
  16. icon: 'account'
  17. },
  18. {
  19. id: 2,
  20. text: '到访代办',
  21. icon: 'file-text'
  22. },
  23. {
  24. id: 3,
  25. text: '预约记录',
  26. icon: 'clock'
  27. }
  28. ])
  29. // 家长权限导航栏数组
  30. const tabList2 = ref([
  31. {
  32. id: 1,
  33. text: '访客预约',
  34. icon: 'account'
  35. },
  36. {
  37. id: 3,
  38. text: '预约记录',
  39. icon: 'clock'
  40. }
  41. ])
  42. // 当前高亮索引
  43. const activeIndex = ref(0)
  44. // 导航栏样式
  45. const customStyle = {
  46. height: '120rpx'
  47. }
  48. onLoad(() => {
  49. const userType = uni.getStorageSync('userInfo').identityId
  50. if (userType == 1) {
  51. allList.value = tabList2.value
  52. } else if (userType == 2) {
  53. allList.value = tabList2.value
  54. } else {
  55. allList.value = tabList.value
  56. }
  57. const i = uni.getStorageSync('Tab-activeIndex')
  58. i ? (activeIndex.value = i) : (activeIndex.value = 0)
  59. })
  60. // 切换导航栏回调
  61. const handleChange = (index, item) => {
  62. if (index != activeIndex.value) {
  63. activeIndex.value = index
  64. uni.setStorageSync('Tab-activeIndex', activeIndex.value)
  65. if (item.icon === 'account') {
  66. uni.redirectTo({
  67. url: '/pagesReservation/reservation/reservation'
  68. })
  69. } else if (item.icon === 'file-text') {
  70. uni.redirectTo({
  71. url: '/pagesReservation/backlog/backlog'
  72. })
  73. } else if (item.icon === 'clock') {
  74. uni.redirectTo({
  75. url: '/pagesReservation/record/record'
  76. })
  77. }
  78. }
  79. }
  80. </script>
  81. <style lang="scss" scoped></style>