index.vue 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <!--
  2. * @Author: wjc
  3. * @Date: 2024-07-08 16:31:21
  4. * @LastEditors: wjc
  5. * @LastEditTime: 2024-07-12 17:03:13
  6. * @Description:
  7. -->
  8. <template>
  9. <up-tabbar
  10. :value="appStore.selectedTabbar"
  11. class="m-tabbar"
  12. :fixed="true"
  13. :z-index="99"
  14. :placeholder="true"
  15. :safe-area-inset-bottom="true"
  16. @change="handleChange"
  17. >
  18. <up-tabbar-item v-for="(item, index) in tabbarList" :key="index">
  19. <template #active-icon>
  20. <view class="flex items-center gap-4px bg-bg-page rounded-18px px-20px py-4px duration-300">
  21. <image class="tabbar-icon" :src="`/${item.selectedIconPath}`"></image>
  22. <view class="text-14px">{{ item.text }}</view>
  23. </view>
  24. </template>
  25. <template #inactive-icon>
  26. <view>
  27. <image class="tabbar-icon" :src="`/${item.iconPath}`"></image>
  28. </view>
  29. </template>
  30. </up-tabbar-item>
  31. </up-tabbar>
  32. </template>
  33. <script setup lang="ts">
  34. import { tabBar } from '@/pages.json'
  35. import { useAppStore } from '@/stores/modules/appStore'
  36. defineOptions({ name: 'MTabBar' })
  37. const appStore = useAppStore()
  38. const tabbarList = ref(tabBar.list)
  39. const handleChange = (val: number) => {
  40. appStore.setTabbar(val)
  41. uni.switchTab({
  42. url: `/${tabbarList.value[val].pagePath}`,
  43. })
  44. }
  45. </script>
  46. <style scoped lang="scss">
  47. .m-tabbar {
  48. @apply h-55px;
  49. :deep(.u-tabbar__content) {
  50. @apply bg-bg-card h-55px duration-300;
  51. border-color: var(--border-color-1) !important;
  52. .u-tabbar__content__item-wrapper {
  53. @apply h-55px;
  54. .u-tabbar-item__icon {
  55. @apply w-full;
  56. }
  57. }
  58. }
  59. .tabbar-icon {
  60. @apply wh-32px;
  61. }
  62. }
  63. </style>