| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350 |
- <template>
- <view class="tab-bar-wrap">
- <!-- 普通用户 TabBar:4 Tab(5等分,中间放按钮) -->
- <view v-if="currentRole !== 'teacher'" class="tab-bar">
- <view
- v-for="(item, index) in leftTabs"
- :key="index"
- class="tab-item"
- :class="{ active: isActive(item) }"
- @click="switchTab(item)"
- >
- <image
- class="tab-icon"
- :src="isActive(item) ? item.selectedIcon : item.icon"
- mode="aspectFit"
- ></image>
- <text class="tab-text">{{ item.text }}</text>
- </view>
- <!-- 中间五维按钮(占 20% 槽位) -->
- <view class="center-btn" @click="openDimPanel">
- <view class="center-btn-inner">
- <text class="center-btn-icon">⭐</text>
- </view>
- <text class="center-btn-label">五维</text>
- </view>
- <view
- v-for="(item, index) in rightTabs"
- :key="index"
- class="tab-item"
- :class="{ active: isActive(item) }"
- @click="switchTab(item)"
- >
- <image
- class="tab-icon"
- :src="isActive(item) ? item.selectedIcon : item.icon"
- mode="aspectFit"
- ></image>
- <text class="tab-text">{{ item.text }}</text>
- </view>
- </view>
- <!-- 规划师 TabBar:5 Tab(不变) -->
- <view v-else class="tab-bar">
- <view
- v-for="(item, index) in teacherTabs"
- :key="index"
- class="tab-item"
- :class="{ active: isActive(item) }"
- @click="switchTab(item)"
- >
- <image
- class="tab-icon"
- :src="isActive(item) ? item.selectedIcon : item.icon"
- mode="aspectFit"
- ></image>
- <text class="tab-text">{{ item.text }}</text>
- </view>
- </view>
- <!-- 五维横排展开 -->
- <view class="dim-fan-overlay" v-if="showDimPanel" @click="closeDimPanel">
- <view class="dim-fan-row">
- <view
- v-for="(dim, idx) in dimensions"
- :key="idx"
- :class="['dim-fan-item', { 'dim-fan-item-up': dim.code === 'mind', 'dim-fan-item-mid': dim.code === 'action' || dim.code === 'body' }]"
- @click.stop="goDimension(dim)"
- >
- <view
- class="dim-fan-circle"
- :class="{ 'fan-active': fanActive }"
- :style="{ backgroundColor: dim.color, transitionDelay: (0.05 * idx) + 's' }"
- >
- <text class="dim-fan-emoji">{{ dim.icon }}</text>
- </view>
- <text
- class="dim-fan-label"
- :class="{ 'fan-active': fanActive }"
- :style="{ transitionDelay: (0.05 * idx) + 's' }"
- >{{ dim.name }}</text>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- currentIndex: 0,
- showDimPanel: false,
- fanActive: false,
- normalTabs: [
- { text: '首页', pagePath: '/pages/index-home/index', icon: '/static/tab-home.png', selectedIcon: '/static/tab-home-active.png' },
- { text: '健康', pagePath: '/pages/health-main/index', icon: '/static/tab-health.png', selectedIcon: '/static/tab-health-active.png' },
- { text: '成长', pagePath: '/pages/growth-main/index', icon: '/static/tab-growth.png', selectedIcon: '/static/tab-growth-active.png' },
- { text: '我的', pagePath: '/pages/profile-main/profile', icon: '/static/tab-profile.png', selectedIcon: '/static/tab-profile-active.png' }
- ],
- teacherTabs: [
- { text: '首页', pagePath: '/pages/teacher/index', icon: '/static/tab-action.png', selectedIcon: '/static/tab-action-active.png' },
- { text: '家庭', pagePath: '/pages/teacher/families', icon: '/static/tab-family.png', selectedIcon: '/static/tab-family-active.png' },
- { text: '团队', pagePath: '/pages/teacher/team', icon: '/static/tab-team.png', selectedIcon: '/static/tab-team-active.png' },
- { text: '成长记录', pagePath: '/pages/growth-main/index', icon: '/static/tab-growth.png', selectedIcon: '/static/tab-growth-active.png' },
- { text: '我的', pagePath: '/pages/teacher/teacher-profile', icon: '/static/tab-profile.png', selectedIcon: '/static/tab-profile-active.png' }
- ],
- dimensions: [
- { code: 'wealth', name: '富', desc: '利他创富', icon: '💧', color: '#F59E0B', bgColor: 'rgba(245,158,11,0.15)' },
- { code: 'action', name: '行', desc: '知行合一', icon: '🌿', color: '#10B981', bgColor: 'rgba(16,185,129,0.15)' },
- { code: 'mind', name: '心', desc: '大爱传承', icon: '🔥', color: '#FF6B9D', bgColor: 'rgba(255,107,157,0.15)' },
- { code: 'body', name: '身', desc: '主动健康', icon: '🌏', color: '#FF8C42', bgColor: 'rgba(255,140,66,0.15)' },
- { code: 'wisdom', name: '智', desc: '赋能未来', icon: '⚡', color: '#6366F1', bgColor: 'rgba(99,102,241,0.15)' }
- ]
- }
- },
- computed: {
- currentRole() {
- return uni.getStorageSync('currentRole') || 'parent'
- },
- leftTabs() {
- return this.normalTabs.slice(0, 2)
- },
- rightTabs() {
- return this.normalTabs.slice(2)
- }
- },
- mounted() {
- this.updateSelected()
- uni.$on('switchRole', () => {
- this.updateSelected()
- })
- },
- methods: {
- isActive(item) {
- var pages = getCurrentPages()
- if (!pages.length) return false
- var currentPath = '/' + pages[pages.length - 1].route
- return item.pagePath === currentPath
- },
- updateSelected() {
- var pages = getCurrentPages()
- if (pages.length) {
- var currentPage = pages[pages.length - 1]
- var currentPath = '/' + currentPage.route
- var tabs = this.currentRole === 'teacher' ? this.teacherTabs : this.normalTabs
- var idx = tabs.findIndex(function(t) { return t.pagePath === currentPath })
- this.currentIndex = idx >= 0 ? idx : 0
- }
- },
- switchTab(item) {
- // TabBar 注册页用 switchTab,非 TabBar 页用 redirectTo
- var tabBarPages = ['/pages/index-home/index', '/pages/health-main/index', '/pages/growth-main/index', '/pages/profile-main/profile']
- if (tabBarPages.indexOf(item.pagePath) !== -1) {
- uni.switchTab({ url: item.pagePath })
- } else {
- uni.redirectTo({ url: item.pagePath })
- }
- },
- openDimPanel() {
- this.showDimPanel = true
- this.fanActive = false
- var self = this
- setTimeout(function() {
- self.fanActive = true
- }, 30)
- },
- closeDimPanel() {
- this.fanActive = false
- var self = this
- setTimeout(function() {
- self.showDimPanel = false
- }, 200)
- },
- goDimension(dim) {
- this.closeDimPanel()
- var dimMap = {
- action: '/pages/action-detail/index',
- mind: '/pages/mind-detail/index',
- body: '/pages/body-detail/index',
- wisdom: '/pages/wisdom-detail/index',
- wealth: '/pages/wealth/index'
- }
- var url = dimMap[dim.code]
- if (!url) return
- var tabBarPages = ['/pages/index-home/index', '/pages/health-main/index', '/pages/growth-main/index', '/pages/profile-main/profile']
- if (tabBarPages.indexOf(url) !== -1) {
- uni.switchTab({ url: url })
- } else {
- uni.navigateTo({ url: url })
- }
- }
- }
- }
- </script>
- <style scoped>
- .tab-bar-wrap {
- position: fixed;
- bottom: 0;
- left: 0;
- right: 0;
- z-index: 999;
- }
- .tab-bar {
- display: flex;
- height: 100rpx;
- background: #fff;
- padding-bottom: env(safe-area-inset-bottom);
- border-top: 1rpx solid #eee;
- position: relative;
- }
- .tab-item {
- width: 20%;
- flex: none;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- position: relative;
- z-index: 1;
- }
- .tab-icon {
- width: 48rpx;
- height: 48rpx;
- margin-bottom: 4rpx;
- }
- .tab-text {
- font-size: 22rpx;
- color: #999;
- }
- .tab-item.active .tab-text {
- color: #F97316;
- }
- /* 中间五维按钮(占 20% 槽位) */
- .center-btn {
- width: 20%;
- flex: none;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: flex-start;
- padding-top: 0;
- position: relative;
- z-index: 2;
- }
- .center-btn-inner {
- width: 88rpx;
- height: 88rpx;
- border-radius: 50%;
- background: linear-gradient(135deg, #F97316, #FB923C);
- display: flex;
- align-items: center;
- justify-content: center;
- margin-top: -20rpx;
- flex-shrink: 0;
- box-shadow: 0 4rpx 16rpx rgba(249,115,22,0.4);
- }
- .center-btn-icon {
- font-size: 40rpx;
- line-height: 1;
- }
- .center-btn-label {
- font-size: 20rpx;
- color: #999;
- text-align: center;
- margin-top: 2rpx;
- }
- /* 五维横排展开 */
- .dim-fan-overlay {
- position: fixed;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- z-index: 1000;
- background: rgba(0,0,0,0.4);
- animation: fadeIn 0.2s ease;
- }
- .dim-fan-row {
- position: absolute;
- bottom: 140rpx;
- left: 0;
- right: 0;
- display: flex;
- justify-content: center;
- padding: 0 16rpx;
- }
- .dim-fan-item {
- display: flex;
- flex-direction: column;
- align-items: center;
- width: 120rpx;
- }
- .dim-fan-item.dim-fan-item-up {
- margin-top: -120rpx;
- }
- .dim-fan-item.dim-fan-item-mid {
- margin-top: -60rpx;
- }
- .dim-fan-circle {
- width: 88rpx;
- height: 88rpx;
- border-radius: 50%;
- display: flex;
- align-items: center;
- justify-content: center;
- opacity: 0;
- transform: scale(0);
- transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
- box-shadow: 0 4rpx 16rpx rgba(0,0,0,0.15);
- }
- .dim-fan-circle.fan-active {
- opacity: 1;
- transform: scale(1);
- }
- .dim-fan-emoji {
- font-size: 40rpx;
- line-height: 1;
- }
- .dim-fan-label {
- font-size: 22rpx;
- color: #fff;
- font-weight: 600;
- margin-top: 8rpx;
- text-align: center;
- opacity: 0;
- transform: translateY(-10rpx);
- transition: all 0.3s ease;
- }
- .dim-fan-label.fan-active {
- opacity: 1;
- transform: translateY(0);
- }
- @keyframes fadeIn {
- from { opacity: 0; }
- to { opacity: 1; }
- }
- </style>
|