- 新增用户消息中心组件 UserMessageView - 新增师傅消息中心组件 MasterMessageView - 新增用户订单列表组件 UserOrdersView - 重构订单列表页,复用独立组件 - 新增系统工具 getWindowInfoSafe 兼容多端系统信息获取 - 重构 TabBar 组件,支持单母页模式和事件回调 - 优化消息跳转逻辑,支持角色自适应 Tab 切换
207 行
4.7 KiB
Vue
207 行
4.7 KiB
Vue
<template>
|
||
<view class="yjyf-tabbar-container">
|
||
<view class="tabbar">
|
||
<!-- 1. 首页 -->
|
||
<view class="tab" :class="{ on: activeIndex === 0 }" @tap="switchTab(0)">
|
||
<image class="tab-icon" :src="activeIndex === 0 ? '/static/tabbar/home-active.svg' : '/static/tabbar/home.svg'" mode="aspectFit" />
|
||
<text class="tab-txt">首页</text>
|
||
</view>
|
||
|
||
<!-- 2. 订单 -->
|
||
<view class="tab" :class="{ on: activeIndex === 1 }" @tap="switchTab(1)">
|
||
<image class="tab-icon" :src="activeIndex === 1 ? '/static/tabbar/order-active.svg' : '/static/tabbar/order.svg'" mode="aspectFit" />
|
||
<text class="tab-txt">订单</text>
|
||
</view>
|
||
|
||
<!-- 3. 中央上浮主按钮:立即下单 -->
|
||
<view class="tab tab-center">
|
||
<view class="fab" :class="{ active: activeIndex === 'order' }" @tap="onOrder">
|
||
<image class="fab-icon" src="/static/tabbar/order-quick.svg" mode="aspectFit" />
|
||
<text class="fab-txt">立即下单</text>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 4. 消息 -->
|
||
<view class="tab" :class="{ on: activeIndex === 2 }" @tap="switchTab(2)">
|
||
<image class="tab-icon" :src="activeIndex === 2 ? '/static/tabbar/message-active.svg' : '/static/tabbar/message.svg'" mode="aspectFit" />
|
||
<text class="tab-txt">消息</text>
|
||
</view>
|
||
|
||
<!-- 5. 我的 -->
|
||
<view class="tab" :class="{ on: activeIndex === 3 }" @tap="switchTab(3)">
|
||
<image class="tab-icon" :src="activeIndex === 3 ? '/static/tabbar/mine-active.svg' : '/static/tabbar/mine.svg'" mode="aspectFit" />
|
||
<text class="tab-txt">我的</text>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 底部防遮挡垫高占位 -->
|
||
<view class="tabbar-placeholder"></view>
|
||
</view>
|
||
</template>
|
||
|
||
<script setup>
|
||
import { ref, watch } from 'vue';
|
||
import { isLogin, toLogin } from '@/utils/request.js';
|
||
|
||
const props = defineProps({
|
||
current: {
|
||
type: [Number, String],
|
||
default: 0
|
||
},
|
||
standalone: {
|
||
type: Boolean,
|
||
default: false
|
||
}
|
||
});
|
||
|
||
const emit = defineEmits(['change']);
|
||
|
||
const activeIndex = ref(props.current);
|
||
watch(() => props.current, (val) => {
|
||
activeIndex.value = val;
|
||
});
|
||
|
||
const TAB_ROUTES = [
|
||
'/pages/index/index',
|
||
'/pages/order/list',
|
||
'/pages/message/message',
|
||
'/pages/mine/mine'
|
||
];
|
||
|
||
function needLogin() {
|
||
if (isLogin()) return true;
|
||
toLogin();
|
||
return false;
|
||
}
|
||
|
||
function onOrder() {
|
||
if (activeIndex.value === 'order') return;
|
||
if (!needLogin()) return;
|
||
uni.navigateTo({ url: '/pages/category/category' });
|
||
}
|
||
|
||
function switchTab(index) {
|
||
if (activeIndex.value === index) return;
|
||
if (index > 0 && !needLogin()) return;
|
||
|
||
activeIndex.value = index;
|
||
emit('change', index);
|
||
|
||
if (props.standalone) {
|
||
const targetUrl = TAB_ROUTES[index];
|
||
if (targetUrl) {
|
||
uni.redirectTo({
|
||
url: targetUrl,
|
||
fail: () => {
|
||
uni.reLaunch({ url: targetUrl });
|
||
}
|
||
});
|
||
}
|
||
}
|
||
}
|
||
</script>
|
||
|
||
<style scoped>
|
||
.yjyf-tabbar-container {
|
||
position: relative;
|
||
z-index: 99;
|
||
}
|
||
|
||
/* ---------- 自定义底部导航栏 (保持 content-box 避免被 safe-area 挤压高度) ---------- */
|
||
.tabbar {
|
||
position: fixed;
|
||
left: 0;
|
||
right: 0;
|
||
bottom: 0;
|
||
z-index: 99;
|
||
box-sizing: content-box !important;
|
||
height: 112rpx;
|
||
padding-bottom: constant(safe-area-inset-bottom);
|
||
padding-bottom: env(safe-area-inset-bottom);
|
||
display: flex;
|
||
background: #ffffff;
|
||
box-shadow: 0 -6rpx 24rpx rgba(0, 0, 0, 0.07);
|
||
}
|
||
|
||
.tab {
|
||
flex: 1;
|
||
height: 112rpx;
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: center;
|
||
justify-content: center;
|
||
padding-bottom: 8rpx;
|
||
}
|
||
|
||
.tab-txt {
|
||
margin-top: 8rpx;
|
||
font-size: 22rpx;
|
||
line-height: 1.2;
|
||
color: #9A9A9A;
|
||
}
|
||
|
||
.tab.on .tab-txt {
|
||
color: #F0710D;
|
||
font-weight: 600;
|
||
}
|
||
|
||
/* 底部图标 */
|
||
.tab-icon {
|
||
width: 44rpx;
|
||
height: 44rpx;
|
||
flex-shrink: 0;
|
||
}
|
||
|
||
/* ---------- 中央上浮主按钮 ---------- */
|
||
.tab-center {
|
||
position: relative;
|
||
height: 112rpx;
|
||
overflow: visible;
|
||
}
|
||
|
||
.fab {
|
||
position: absolute;
|
||
left: 50%;
|
||
top: -52rpx;
|
||
width: 128rpx;
|
||
height: 128rpx;
|
||
margin-left: -64rpx;
|
||
border-radius: 50%;
|
||
background: linear-gradient(135deg, #FFA93F 0%, #F0710D 100%);
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: center;
|
||
justify-content: center;
|
||
box-shadow: 0 10rpx 28rpx rgba(240, 113, 13, 0.45);
|
||
border: 8rpx solid #ffffff;
|
||
box-sizing: border-box;
|
||
transition: transform 0.15s ease, box-shadow 0.15s ease;
|
||
}
|
||
|
||
.fab:active {
|
||
transform: scale(0.94);
|
||
box-shadow: 0 4rpx 16rpx rgba(240, 113, 13, 0.35);
|
||
}
|
||
|
||
.fab-icon {
|
||
width: 52rpx;
|
||
height: 52rpx;
|
||
}
|
||
|
||
.fab-txt {
|
||
font-size: 20rpx;
|
||
font-weight: 600;
|
||
color: #ffffff;
|
||
line-height: 1;
|
||
margin-top: 4rpx;
|
||
letter-spacing: 0.5rpx;
|
||
}
|
||
|
||
.tabbar-placeholder {
|
||
height: 112rpx;
|
||
padding-bottom: constant(safe-area-inset-bottom);
|
||
padding-bottom: env(safe-area-inset-bottom);
|
||
box-sizing: content-box !important;
|
||
}
|
||
</style>
|