tabbar.vue 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <template>
  2. <u-tabbar
  3. :value="currIndex"
  4. :fixed="true"
  5. :placeholder="false"
  6. :safeAreaInsetBottom="false"
  7. >
  8. <u-tabbar-item text="首页" icon="home" @click="changeTab(HOME_INDEX)"></u-tabbar-item>
  9. <u-tabbar-item text="车辆管理" icon="car" @click="changeTab(CAR_INDEX)"></u-tabbar-item>
  10. <u-tabbar-item text="车辆监测" icon="eye" @click="changeTab(MONITOR_INDEX)"></u-tabbar-item>
  11. <u-tabbar-item text="实时联动" icon="share" @click="changeTab(LIVE_INDEX)"></u-tabbar-item>
  12. <!-- <u-tabbar-item text="我的" icon="account" @click="changeTab(4)"></u-tabbar-item> -->
  13. </u-tabbar>
  14. </template>
  15. <script>
  16. import { HOME_INDEX, CAR_INDEX, MONITOR_INDEX, LIVE_INDEX } from '../../config/constants'
  17. import { isDriver, isAdmin } from '@/utils/common.js'
  18. export default {
  19. data() {
  20. return {
  21. HOME_INDEX, CAR_INDEX, MONITOR_INDEX, LIVE_INDEX,
  22. curr: 0
  23. }
  24. },
  25. computed: {
  26. currIndex() {
  27. return getApp().globalData.tabIndex
  28. },
  29. isDriver,
  30. isAdmin
  31. },
  32. mounted() {
  33. },
  34. methods: {
  35. changeTab(index) {
  36. getApp().globalData.tabIndex = index
  37. if(index === HOME_INDEX) {
  38. uni.redirectTo({
  39. url: '/pages/home/home'
  40. })
  41. }else if(index === CAR_INDEX) {
  42. uni.redirectTo({
  43. url: '/pages/carManager/carManager'
  44. })
  45. }else if(index == MONITOR_INDEX) {
  46. uni.redirectTo({
  47. url: '/pages/monitor/monitor'
  48. })
  49. } else if(index === LIVE_INDEX) {
  50. } else if(index === 4) {
  51. }
  52. }
  53. }
  54. }
  55. </script>
  56. <style>
  57. </style>