tabber.vue 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <template>
  2. <uv-tabbar :customStyle="customStyle" activeColor="#0061FF" inactiveColor="#A6A6A6" :value="activeIndex">
  3. <uv-tabbar-item v-for="(item, index) in tabList" :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 tabList = ref([
  11. {
  12. id: 1,
  13. text: '访客预约',
  14. icon: 'account'
  15. },
  16. {
  17. id: 2,
  18. text: '到访代办',
  19. icon: 'file-text'
  20. },
  21. {
  22. id: 3,
  23. text: '预约记录',
  24. icon: 'clock'
  25. }
  26. ])
  27. // 当前高亮索引
  28. const activeIndex = ref(0)
  29. // 导航栏样式
  30. const customStyle = {
  31. height: '120rpx'
  32. }
  33. onLoad(() => {
  34. const i = uni.getStorageSync('Tab-activeIndex')
  35. i ? (activeIndex.value = i) : (activeIndex.value = 0)
  36. })
  37. // 切换导航栏回调
  38. const handleChange = (index, item) => {
  39. if (index != activeIndex.value) {
  40. activeIndex.value = index
  41. uni.setStorageSync('Tab-activeIndex', activeIndex.value)
  42. if (item.icon === 'account') {
  43. uni.redirectTo({
  44. url: '/pagesReservation/reservation/reservation'
  45. })
  46. } else if (item.icon === 'file-text') {
  47. uni.redirectTo({
  48. url: '/pagesReservation/backlog/backlog'
  49. })
  50. } else if (item.icon === 'clock') {
  51. uni.redirectTo({
  52. url: '/pagesReservation/record/record'
  53. })
  54. }
  55. }
  56. }
  57. </script>
  58. <style lang="scss" scoped></style>