|
@@ -0,0 +1,57 @@
|
|
|
+<!--
|
|
|
+ * @Author: wjc
|
|
|
+ * @Date: 2024-07-08 16:31:21
|
|
|
+ * @LastEditors: wjc
|
|
|
+ * @LastEditTime: 2024-07-08 17:56:11
|
|
|
+ * @Description:
|
|
|
+-->
|
|
|
+<template>
|
|
|
+ <up-tabbar
|
|
|
+ :value="selected"
|
|
|
+ class="m-tabbar"
|
|
|
+ :fixed="true"
|
|
|
+ :placeholder="true"
|
|
|
+ :safe-area-inset-bottom="true"
|
|
|
+ @change="handleChange"
|
|
|
+ >
|
|
|
+ <up-tabbar-item v-for="(item, index) in tabbarList" :key="index" :text="item.text">
|
|
|
+ <template #active-icon>
|
|
|
+ <image class="tabbar-icon" :src="`/${item.selectedIconPath}`"></image>
|
|
|
+ </template>
|
|
|
+ <template #inactive-icon>
|
|
|
+ <image class="tabbar-icon" :src="`/${item.iconPath}`"></image>
|
|
|
+ </template>
|
|
|
+ </up-tabbar-item>
|
|
|
+ </up-tabbar>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script setup lang="ts">
|
|
|
+ import { tabBar } from '@/pages.json'
|
|
|
+ import { useAppStore } from '@/stores/modules/appStore'
|
|
|
+
|
|
|
+ defineOptions({ name: 'MTabBar' })
|
|
|
+
|
|
|
+ const appStore = useAppStore()
|
|
|
+ const selected = ref(appStore.selectedTabbar)
|
|
|
+ const tabbarList = ref(tabBar.list)
|
|
|
+
|
|
|
+ watchEffect(() => {
|
|
|
+ selected.value = appStore.selectedTabbar
|
|
|
+ })
|
|
|
+
|
|
|
+ const handleChange = (val: number) => {
|
|
|
+ appStore.setTabbar(val)
|
|
|
+ uni.switchTab({
|
|
|
+ url: `/${tabbarList.value[val].pagePath}`,
|
|
|
+ })
|
|
|
+ }
|
|
|
+</script>
|
|
|
+
|
|
|
+<style scoped lang="scss">
|
|
|
+ .m-tabbar {
|
|
|
+ @apply h-50px;
|
|
|
+ }
|
|
|
+ .tabbar-icon {
|
|
|
+ @apply wh-32px;
|
|
|
+ }
|
|
|
+</style>
|