96 lines
1.9 KiB
Vue
96 lines
1.9 KiB
Vue
<template>
|
|
<view class="app-tabbar">
|
|
<view class="tabbar-inner">
|
|
<view
|
|
v-for="tab in tabs"
|
|
:key="tab.name"
|
|
class="tab-item"
|
|
:class="{ active: current === tab.name }"
|
|
@tap="onChange(tab.name)"
|
|
>
|
|
<FaIcon
|
|
:name="tab.icon"
|
|
:color="current === tab.name ? '#3973ff' : '#8a94ad'"
|
|
:size="20"
|
|
/>
|
|
<text class="tab-text">{{ tab.text }}</text>
|
|
</view>
|
|
</view>
|
|
<view class="safe-area" />
|
|
</view>
|
|
</template>
|
|
|
|
<script setup>
|
|
/**
|
|
* 子系统内底部 tabbar。
|
|
*
|
|
* 每个子系统(crm / erp / oa / cms / toolbox)都有独立的页面组与独立的 tabbar,
|
|
* 通过 group(子系统目录名)解析路由;导航页 nav.vue 不使用本组件。
|
|
*/
|
|
const props = defineProps({
|
|
group: {
|
|
type: String,
|
|
required: true
|
|
},
|
|
current: {
|
|
type: String,
|
|
default: 'home'
|
|
}
|
|
})
|
|
|
|
const tabs = [
|
|
{ name: 'home', text: '概览', icon: 'gauge' },
|
|
{ name: 'functions', text: '功能', icon: 'table-cells' },
|
|
{ name: 'todo', text: '待办', icon: 'circle-check' },
|
|
{ name: 'mine', text: '我的', icon: 'user' }
|
|
]
|
|
|
|
function onChange(name) {
|
|
if (name === props.current) return
|
|
// 子系统内部页面与 tab 一一对应,用 redirectTo 避免页面栈堆积
|
|
uni.redirectTo({ url: `/pages/${props.group}/${name}/${name}` })
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
@import '@/src/styles/theme.scss';
|
|
|
|
.app-tabbar {
|
|
flex-shrink: 0;
|
|
background: $color-card;
|
|
border-top: 1rpx solid $color-border;
|
|
box-shadow: $shadow-header;
|
|
}
|
|
|
|
.tabbar-inner {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-around;
|
|
padding: 10rpx 0 6rpx;
|
|
}
|
|
|
|
.tab-item {
|
|
flex: 1;
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
gap: 4rpx;
|
|
padding: 8rpx 0;
|
|
|
|
&.active .tab-text {
|
|
color: $color-primary;
|
|
font-weight: 600;
|
|
}
|
|
}
|
|
|
|
.tab-text {
|
|
font-size: 22rpx;
|
|
color: $color-text-muted;
|
|
}
|
|
|
|
.safe-area {
|
|
height: constant(safe-area-inset-bottom);
|
|
height: env(safe-area-inset-bottom);
|
|
}
|
|
</style>
|