- 新增 invoice_title、showcase、wallet_log 模型及对应语言包 - 新增后台控制器、视图及搜索字段配置 - 修复服务类目删除保护逻辑 - 优化后台登录页面文案及样式 - 新增前端角色切换逻辑及页面拦截 - 新增 SVG 图标及样式变量 - 修复接口权限及下拉框默认值问题
212 行
4.9 KiB
Vue
212 行
4.9 KiB
Vue
<template>
|
||
<view class="yjyf-master-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/master/home-active.svg' : '/static/tabbar/master/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/master/order-active.svg' : '/static/tabbar/master/order.svg'" mode="aspectFit" />
|
||
<text class="tab-txt">订单</text>
|
||
</view>
|
||
|
||
<!-- 3. 消息 -->
|
||
<view class="tab" :class="{ on: activeIndex === 2 }" @tap="switchTab(2)">
|
||
<view class="icon-box">
|
||
<image class="tab-icon" :src="activeIndex === 2 ? '/static/tabbar/master/message-active.svg' : '/static/tabbar/master/message.svg'" mode="aspectFit" />
|
||
<view class="unread-badge" v-if="unreadCount > 0">
|
||
<text class="unread-txt">{{ unreadCount > 99 ? '99+' : unreadCount }}</text>
|
||
</view>
|
||
</view>
|
||
<text class="tab-txt">消息</text>
|
||
</view>
|
||
|
||
<!-- 4. 我的 (师傅中心) -->
|
||
<view class="tab" :class="{ on: activeIndex === 3 }" @tap="switchTab(3)">
|
||
<image class="tab-icon" :src="activeIndex === 3 ? '/static/tabbar/master/mine-active.svg' : '/static/tabbar/master/mine.svg'" mode="aspectFit" />
|
||
<text class="tab-txt">我的</text>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 底部防遮挡垫高占位 -->
|
||
<view class="tabbar-placeholder"></view>
|
||
</view>
|
||
</template>
|
||
|
||
<script setup>
|
||
import { ref, watch, onMounted, onBeforeUnmount } from 'vue';
|
||
import api from '@/utils/api.js';
|
||
import { isLogin } from '@/utils/request.js';
|
||
import { setRole } from '@/utils/role.js';
|
||
|
||
const props = defineProps({
|
||
current: {
|
||
type: Number,
|
||
default: 0
|
||
},
|
||
// 默认 true:师傅端 4 个 Tab 均为独立页面,点击通过路由切换对应页面
|
||
standalone: {
|
||
type: Boolean,
|
||
default: true
|
||
}
|
||
});
|
||
|
||
const emit = defineEmits(['change']);
|
||
|
||
const activeIndex = ref(props.current);
|
||
const unreadCount = ref(0);
|
||
|
||
async function fetchUnread() {
|
||
if (!isLogin()) {
|
||
unreadCount.value = 0;
|
||
return;
|
||
}
|
||
try {
|
||
const res = await api.messageUnread({ type: 'master' });
|
||
unreadCount.value = Number(res?.unread || 0);
|
||
} catch (e) {}
|
||
}
|
||
|
||
watch(() => props.current, (val) => {
|
||
activeIndex.value = val;
|
||
fetchUnread();
|
||
});
|
||
|
||
onMounted(() => {
|
||
fetchUnread();
|
||
uni.$on('yjyf:refreshUnread', fetchUnread);
|
||
});
|
||
|
||
onBeforeUnmount(() => {
|
||
uni.$off('yjyf:refreshUnread', fetchUnread);
|
||
});
|
||
|
||
const TAB_ROUTES = [
|
||
'/pages/master/hall',
|
||
'/pages/master/orders',
|
||
'/pages/message/message?role=master',
|
||
'/pages/master/workbench'
|
||
];
|
||
|
||
function switchTab(index) {
|
||
setRole('master');
|
||
if (activeIndex.value === index) return;
|
||
activeIndex.value = index;
|
||
|
||
// 触发父容器事件(方案 A 单母页 0ms 秒切)
|
||
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>
|
||
/* #ifdef MP-WEIXIN */
|
||
:host {
|
||
display: block;
|
||
width: 100%;
|
||
flex-shrink: 0;
|
||
}
|
||
/* #endif */
|
||
|
||
.yjyf-master-tabbar-container {
|
||
position: relative;
|
||
z-index: 99;
|
||
flex-shrink: 0;
|
||
}
|
||
|
||
.tabbar {
|
||
position: fixed;
|
||
left: 0;
|
||
right: 0;
|
||
bottom: 0;
|
||
z-index: 99;
|
||
box-sizing: content-box !important;
|
||
height: 104rpx;
|
||
padding-bottom: constant(safe-area-inset-bottom);
|
||
padding-bottom: env(safe-area-inset-bottom);
|
||
display: flex;
|
||
background: #ffffff;
|
||
border-top: 1rpx solid #ECECEC;
|
||
box-shadow: 0 -4rpx 16rpx rgba(0, 0, 0, 0.05);
|
||
}
|
||
|
||
.tab {
|
||
flex: 1;
|
||
height: 104rpx;
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: center;
|
||
justify-content: center;
|
||
padding-bottom: 6rpx;
|
||
}
|
||
|
||
.icon-box {
|
||
position: relative;
|
||
display: inline-flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
}
|
||
.unread-badge {
|
||
position: absolute;
|
||
top: -10rpx;
|
||
right: -22rpx;
|
||
min-width: 32rpx;
|
||
height: 32rpx;
|
||
padding: 0 8rpx;
|
||
border-radius: 16rpx;
|
||
background: #E8331B;
|
||
border: 2rpx solid #FFFFFF;
|
||
display: inline-flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
box-sizing: border-box;
|
||
}
|
||
.unread-txt {
|
||
font-size: 22rpx;
|
||
color: #FFFFFF;
|
||
font-weight: 700;
|
||
line-height: 1;
|
||
transform: scale(0.85);
|
||
}
|
||
.tab-icon {
|
||
width: 44rpx;
|
||
height: 44rpx;
|
||
flex-shrink: 0;
|
||
}
|
||
|
||
.tab-txt {
|
||
margin-top: 6rpx;
|
||
font-size: 22rpx;
|
||
line-height: 1.2;
|
||
color: #8E8E93;
|
||
transition: color 0.15s ease;
|
||
}
|
||
|
||
.tab.on .tab-txt {
|
||
color: #F0710D;
|
||
font-weight: 600;
|
||
}
|
||
|
||
.tabbar-placeholder {
|
||
height: 104rpx;
|
||
padding-bottom: constant(safe-area-inset-bottom);
|
||
padding-bottom: env(safe-area-inset-bottom);
|
||
box-sizing: content-box !important;
|
||
}
|
||
</style>
|