重构前端代码架构, 完善我的内容区
This commit is contained in:
@@ -42,20 +42,21 @@ export default {
|
||||
iconPath: '/static/tabbar/team.png',
|
||||
selectedIconPath: '/static/tabbar/team_active.png',
|
||||
},
|
||||
{
|
||||
key: 'champion',
|
||||
text: '销冠',
|
||||
pagePath: '/pages/champion/champion',
|
||||
iconPath: '/static/tabbar/insight.png',
|
||||
selectedIconPath: '/static/tabbar/insight_active.png',
|
||||
},
|
||||
{
|
||||
key: 'workspace',
|
||||
text: '工作台',
|
||||
pagePath: '/pages/workspace/workspace',
|
||||
iconPath: '/static/tabbar/workspace.png',
|
||||
selectedIconPath: '/static/tabbar/workspace_active.png',
|
||||
},
|
||||
// 已从导航中移除,但保留代码
|
||||
// {
|
||||
// key: 'champion',
|
||||
// text: '销冠',
|
||||
// pagePath: '/pages/champion/champion',
|
||||
// iconPath: '/static/tabbar/insight.png',
|
||||
// selectedIconPath: '/static/tabbar/insight_active.png',
|
||||
// },
|
||||
// {
|
||||
// key: 'workspace',
|
||||
// text: '工作台',
|
||||
// pagePath: '/pages/workspace/workspace',
|
||||
// iconPath: '/static/tabbar/workspace.png',
|
||||
// selectedIconPath: '/static/tabbar/workspace_active.png',
|
||||
// },
|
||||
{
|
||||
key: 'ucenter',
|
||||
text: '我的',
|
||||
@@ -77,6 +78,13 @@ export default {
|
||||
iconPath: '/static/tabbar/reception.png',
|
||||
selectedIconPath: '/static/tabbar/reception_active.png',
|
||||
},
|
||||
{
|
||||
key: 'common_begin_reception',
|
||||
text: '开始接待',
|
||||
pagePath: '/pages/furniture_reception/common_begin_reception',
|
||||
iconPath: '/static/tabbar/reception.png',
|
||||
selectedIconPath: '/static/tabbar/reception_active.png',
|
||||
},
|
||||
{
|
||||
key: 'furniture_customer',
|
||||
text: '客户',
|
||||
@@ -97,7 +105,37 @@ export default {
|
||||
computed: {
|
||||
visibleTabs() {
|
||||
const allowedKeys = this.getAllowedKeys();
|
||||
return this.allTabs.filter((t) => allowedKeys.includes(t.key));
|
||||
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));
|
||||
return result;
|
||||
},
|
||||
},
|
||||
created() {
|
||||
@@ -219,11 +257,16 @@ export default {
|
||||
|
||||
// 会议相关的tab key列表
|
||||
const meetingTabKeys = ['meeting_summary'];
|
||||
// 已从导航中移除的tab key列表(代码保留但不显示)
|
||||
const removedTabKeys = ['champion', 'workspace'];
|
||||
|
||||
// admin_furniture 角色:只显示家具相关的tab和ucenter
|
||||
if (isAdminFurniture) {
|
||||
// 检查是否有任何角色名等于 "furniture" 字符串(精确匹配)
|
||||
const hasFurnitureRole = roles.includes('furniture');
|
||||
|
||||
// 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] admin_furniture ->', furnitureTabs);
|
||||
console.log('[TabBar][allowed] furniture/admin_furniture role ->', furnitureTabs, 'roles:', roles);
|
||||
return furnitureTabs;
|
||||
}
|
||||
|
||||
@@ -236,10 +279,10 @@ export default {
|
||||
|
||||
// 非 meeting_admin 角色:排除所有会议相关的tab
|
||||
if (isAdmin) {
|
||||
// admin 角色:显示所有tab(包括 ucenter),但排除会议相关的tab和家具相关的tab
|
||||
// admin 角色:显示所有tab(包括 ucenter),但排除会议相关的tab、家具相关的tab、以及reception和customer
|
||||
const all = this.allTabs
|
||||
.map((t) => t.key)
|
||||
.filter((key) => !meetingTabKeys.includes(key) && !['furniture_reception', 'furniture_customer', 'furniture_top_sales'].includes(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;
|
||||
@@ -256,10 +299,10 @@ export default {
|
||||
return studentTabs;
|
||||
}
|
||||
|
||||
// 其他角色:隐藏作业/教务/语音/表达,同时排除会议相关的tab和家具相关的tab,但确保包含ucenter
|
||||
// 其他角色:隐藏作业/教务/语音/表达,同时排除会议相关的tab、家具相关的tab、以及reception和customer,但确保包含ucenter
|
||||
const otherTabs = this.allTabs
|
||||
.map((t) => t.key)
|
||||
.filter((key) => !['homework', 'edu', 'voice', 'expression', 'furniture_reception', 'furniture_customer', 'furniture_top_sales', ...meetingTabKeys].includes(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');
|
||||
@@ -270,8 +313,8 @@ export default {
|
||||
// #ifdef H5
|
||||
toggleNativeTabs() {
|
||||
// H5 平台自定义 tabbar 不生效,直接根据角色显隐原生 tabbar 项
|
||||
// 当前位置顺序:接待、客户、团队、销冠、工作台、我的、总结和统计、家具接待、家具客户、家具销冠
|
||||
const ORDER = ['reception', 'customer', 'team', 'champion', 'workspace', 'ucenter', 'meeting_summary', 'furniture_reception', 'furniture_customer', 'furniture_top_sales'];
|
||||
// 当前位置顺序(根据 pages.json 中的 tabBar.list 顺序):接待、客户、团队、总结和统计、家具接待、开始接待、家具客户、家具销冠、我的
|
||||
const ORDER = ['reception', 'customer', 'team', 'meeting_summary', 'furniture_reception', 'common_begin_reception', 'furniture_customer', 'furniture_top_sales', 'ucenter'];
|
||||
const allowed = this.getAllowedKeys();
|
||||
// 限制重试次数,防止渲染时机未就绪
|
||||
this._h5TabRetries = (this._h5TabRetries || 0) + 1;
|
||||
|
||||
Reference in New Issue
Block a user