删除底部导航销冠,调整小程序前端架构

This commit is contained in:
zhonghua.li
2026-02-07 13:17:19 +08:00
parent 4e192fe9f9
commit 11cc4a7664
56 changed files with 6365 additions and 8590 deletions

View File

@@ -48,13 +48,6 @@ export default {
iconPath: '/static/tabbar/customer.png',
selectedIconPath: '/static/tabbar/customer_active.png',
},
{
key: 'furniture_top_sales',
text: '销冠',
pagePath: 'pages/furniture_top_sales/furniture_top_sales',
iconPath: '/static/tabbar/insight.png',
selectedIconPath: '/static/tabbar/insight_active.png',
},
{
key: 'ucenter',
text: '我的',
@@ -94,35 +87,28 @@ export default {
],
};
},
computed: {
computed: {
furnitureTabs() {
// 强制返回所有家具角色的tab
// 强制返回所有家具角色的tab使用与pages.json相同的路径格式
return [
{
key: 'furniture_reception',
text: '接待',
pagePath: '/pages/furniture_reception/furniture_reception',
pagePath: 'pages/furniture_reception/furniture_reception', // 移除开头的/
iconPath: '/static/tabbar/reception.png',
selectedIconPath: '/static/tabbar/reception_active.png',
},
{
key: 'furniture_customer',
text: '客户',
pagePath: '/pages/furniture_customer/furniture_customer',
pagePath: 'pages/furniture_customer/furniture_customer', // 移除开头的/
iconPath: '/static/tabbar/customer.png',
selectedIconPath: '/static/tabbar/customer_active.png',
},
{
key: 'furniture_top_sales',
text: '销冠',
pagePath: '/pages/furniture_top_sales/furniture_top_sales',
iconPath: '/static/tabbar/insight.png',
selectedIconPath: '/static/tabbar/insight_active.png',
},
{
key: 'ucenter',
text: '我的',
pagePath: '/pages/ucenter/ucenter',
pagePath: 'pages/ucenter/ucenter', // 移除开头的/
iconPath: '/static/tabbar/me.png',
selectedIconPath: '/static/tabbar/me_active.png',
}
@@ -132,37 +118,14 @@ export default {
visibleTabs() {
console.log('=== CUSTOM TABBAR VISIBLE TABS CALCULATED ===');
console.log('VISIBLE TABS CALC - THIS MUST SHOW IN H5');
const allowedKeys = this.getAllowedKeys();
console.log('[TabBar][visibleTabs] STEP1 - getAllowedKeys returned:', JSON.stringify(allowedKeys));
// 创建 key 到 tab 的映射
const tabMap = {};
this.allTabs.forEach(tab => {
tabMap[tab.key] = tab;
});
// 强制将 ucenter 移到最后一个位置:先收集所有非 ucenter 的 keys然后添加 ucenter
const otherKeys = [];
let hasUcenter = false;
allowedKeys.forEach(key => {
if (key !== 'ucenter') {
otherKeys.push(key);
} else {
hasUcenter = true;
}
});
console.log('[TabBar][visibleTabs] STEP2 - after filtering, otherKeys:', JSON.stringify(otherKeys), 'hasUcenter:', hasUcenter);
// 如果有 ucenter将其添加到最后一个位置
const finalKeys = hasUcenter ? [...otherKeys, 'ucenter'] : otherKeys;
console.log('[TabBar][visibleTabs] STEP3 - finalKeys after moving ucenter to end:', JSON.stringify(finalKeys));
// 按照排序后的 keys 顺序返回 tabs
const result = finalKeys
.filter(key => tabMap[key])
.map(key => tabMap[key]);
console.log('[TabBar][visibleTabs] STEP4 - final result keys:', result.map(t => t.key), 'texts:', result.map(t => t.text));
// 简化逻辑直接返回家具相关的tabs跳过权限检查
const furnitureKeys = ['furniture_reception', 'furniture_customer', 'ucenter'];
const result = furnitureKeys.map(key => {
return this.allTabs.find(tab => tab.key === key);
}).filter(Boolean);
console.log('[TabBar][visibleTabs] 直接返回家具tabs:', result.map(t => t.key), 'texts:', result.map(t => t.text));
return result;
},
},
@@ -183,6 +146,29 @@ export default {
uni.$on('tabbar:refresh', this.handleExternalRefresh);
// 初始化时同步一次
this.handleExternalRefresh();
// H5平台额外处理页面刷新后的显示问题
// #ifdef H5
// 监听页面显示事件确保刷新后tabBar正确显示
uni.on('onShow', () => {
setTimeout(() => {
console.log('H5: 页面显示事件触发刷新tabBar');
this.handleExternalRefresh();
this.forceH5TabBarSetup();
}, 300);
});
// 监听浏览器刷新事件
if (typeof window !== 'undefined') {
window.addEventListener('load', () => {
setTimeout(() => {
console.log('H5: 页面加载完成刷新tabBar');
this.handleExternalRefresh();
this.forceH5TabBarSetup();
}, 500);
});
}
// #endif
},
beforeDestroy() {
uni.$off('tabbar:refresh', this.handleExternalRefresh);
@@ -285,84 +271,19 @@ export default {
console.log('[TabBar][refresh] currentPath:', this.currentPath, 'roleName:', this.roleName, 'visibleKeys:', this.visibleTabs.map(t => t.key), 'roles:', this.roles);
},
getAllowedKeys() {
const roles = this.roles || [];
console.log('=== CUSTOM TABBAR GET ALLOWED KEYS CALLED ===');
console.log('GET ALLOWED KEYS - THIS MUST SHOW IN H5, roles:', roles);
console.log('GET ALLOWED KEYS - 简化版本总是返回家具相关tabs');
const isTeacher = roles.includes('speaking_training_teacher');
const isStudent = roles.includes('speaking_training_students');
const isAdmin = roles.includes('admin');
const isMeetingAdmin = roles.includes('meeting_admin');
const isAdminFurniture = roles.includes('admin_furniture');
// 会议相关的tab key列表
const meetingTabKeys = ['meeting_summary'];
// 已从导航中移除的tab key列表代码保留但不显示
const removedTabKeys = ['champion', 'workspace'];
// 检查是否有任何角色名等于 "furniture" 字符串(精确匹配)
const hasFurnitureRole = roles.includes('furniture');
console.log('[TabBar][getAllowedKeys] role checks:', {
isAdminFurniture,
hasFurnitureRole,
isAdmin,
isMeetingAdmin,
roles
});
// admin_furniture 和 furniture 角色:显示 furniture_reception, furniture_customer, furniture_top_sales 和 ucenter相同顺序
if (isAdminFurniture || hasFurnitureRole) {
const furnitureTabs = ['furniture_reception', 'furniture_customer', 'furniture_top_sales', 'ucenter'];
console.log('[TabBar][allowed] furniture/admin_furniture role ->', furnitureTabs, 'roles:', roles);
return furnitureTabs;
}
if (isMeetingAdmin) {
// meeting_admin 角色显示会议相关的tab和ucenter我的
const meetingAdminTabs = [...meetingTabKeys, 'ucenter'];
console.log('[TabBar][allowed] meeting_admin ->', meetingAdminTabs);
return meetingAdminTabs;
}
// 非 meeting_admin 角色排除所有会议相关的tab
if (isAdmin) {
// admin 角色显示所有tab包括 ucenter但排除会议相关的tab、家具相关的tab、以及reception和customer
const all = this.allTabs
.map((t) => t.key)
.filter((key) => !meetingTabKeys.includes(key) && !['furniture_reception', 'common_begin_reception', 'furniture_customer', 'furniture_top_sales', 'reception', 'customer', ...removedTabKeys].includes(key));
// 确保 ucenter 被包含(用于"我的"页面)
console.log('[TabBar][allowed] admin ->', all, 'includes ucenter:', all.includes('ucenter'));
return all;
}
if (isTeacher && !isAdmin) {
const teacherTabs = ['ucenter'];
console.log('[TabBar][allowed] teacher ->', teacherTabs);
return teacherTabs;
}
if (isStudent && !isAdmin) {
const studentTabs = ['ucenter'];
console.log('[TabBar][allowed] student ->', studentTabs);
return studentTabs;
}
// 其他角色:隐藏作业/教务/语音/表达同时排除会议相关的tab、家具相关的tab、以及reception和customer但确保包含ucenter
const otherTabs = this.allTabs
.map((t) => t.key)
.filter((key) => !['homework', 'edu', 'voice', 'expression', 'furniture_reception', 'common_begin_reception', 'furniture_customer', 'furniture_top_sales', 'reception', 'customer', ...meetingTabKeys, ...removedTabKeys].includes(key));
// 确保 ucenter 被包含(任何角色都应该能看到"我的"
if (!otherTabs.includes('ucenter')) {
otherTabs.push('ucenter');
}
console.log('[TabBar][allowed] other ->', otherTabs, 'roles:', roles);
return otherTabs;
// 简化逻辑总是返回家具相关的tabs
const furnitureTabs = ['furniture_reception', 'furniture_customer', 'ucenter'];
console.log('[TabBar][allowed] 简化逻辑 ->', furnitureTabs);
return furnitureTabs;
},
// #ifdef H5
toggleNativeTabs() {
// H5 平台自定义 tabbar 不生效,直接根据角色显隐原生 tabbar 项
// 当前位置顺序(根据 pages.json 中的 tabBar.list 顺序):接待、客户、团队、总结和统计、家具接待、开始接待、家具客户、家具销冠、我的
const ORDER = ['furniture_reception', 'furniture_customer', 'furniture_top_sales', 'ucenter', 'reception', 'customer', 'team', 'meeting_summary', 'common_begin_reception'];
// 当前位置顺序(根据 pages.json 中的 tabBar.list 顺序):接待、客户、团队、总结和统计、家具接待、开始接待、家具客户、我的
const ORDER = ['furniture_reception', 'furniture_customer', 'ucenter', 'reception', 'customer', 'team', 'meeting_summary', 'common_begin_reception'];
const allowed = this.getAllowedKeys();
// 限制重试次数,防止渲染时机未就绪
this._h5TabRetries = (this._h5TabRetries || 0) + 1;
@@ -393,7 +314,6 @@ export default {
const tabBarList = [
'pages/furniture_reception/furniture_reception',
'pages/furniture_customer/furniture_customer',
'pages/furniture_top_sales/furniture_top_sales',
'pages/ucenter/ucenter'
];
const normalizedPath = pagePath.startsWith('/') ? pagePath.substring(1) : pagePath;
@@ -434,7 +354,6 @@ export default {
el.textContent && (
el.textContent.includes('接待') ||
el.textContent.includes('客户') ||
el.textContent.includes('销冠') ||
el.textContent.includes('我的')
)
);
@@ -471,9 +390,9 @@ export default {
return;
}
// 按文本内容排序:接待、客户、销冠、我的
// 按文本内容排序:接待、客户、我的
const sortedElements = tabElements.sort((a, b) => {
const order = ['接待', '客户', '销冠', '我的'];
const order = ['接待', '客户', '我的'];
const aIndex = order.findIndex(text => a.textContent.includes(text));
const bIndex = order.findIndex(text => b.textContent.includes(text));
return aIndex - bIndex;
@@ -483,7 +402,7 @@ export default {
// 处理每个元素
sortedElements.forEach((element, index) => {
const keyMap = ['furniture_reception', 'furniture_customer', 'furniture_top_sales', 'ucenter'];
const keyMap = ['furniture_reception', 'furniture_customer', 'ucenter'];
const key = keyMap[index];
const shouldShow = allowed.includes(key);