家具行业前端代码框架
This commit is contained in:
@@ -70,6 +70,27 @@ export default {
|
||||
iconPath: '/static/tabbar/insight.png',
|
||||
selectedIconPath: '/static/tabbar/insight_active.png',
|
||||
},
|
||||
{
|
||||
key: 'furniture_reception',
|
||||
text: '接待',
|
||||
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',
|
||||
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',
|
||||
},
|
||||
],
|
||||
};
|
||||
},
|
||||
@@ -145,11 +166,40 @@ export default {
|
||||
return;
|
||||
}
|
||||
if (this.currentPath === item.pagePath) return;
|
||||
|
||||
// uni.switchTab 需要相对路径(去掉前导斜杠)
|
||||
const url = item.pagePath.startsWith('/') ? item.pagePath.substring(1) : item.pagePath;
|
||||
|
||||
uni.switchTab({
|
||||
url: item.pagePath,
|
||||
complete: () => {
|
||||
url: url,
|
||||
success: () => {
|
||||
console.log('[TabBar][switchTab] success:', url);
|
||||
this.updateActivePath();
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error('[TabBar][switchTab] fail:', err, 'url:', url);
|
||||
// 如果 switchTab 失败,尝试使用 reLaunch(适用于 tabBar 页面)
|
||||
uni.reLaunch({
|
||||
url: url,
|
||||
fail: (err2) => {
|
||||
console.error('[TabBar][reLaunch] fail:', err2, 'url:', url);
|
||||
uni.showToast({
|
||||
title: '页面跳转失败,请检查页面配置',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
});
|
||||
},
|
||||
success: () => {
|
||||
this.updateActivePath();
|
||||
}
|
||||
});
|
||||
},
|
||||
complete: () => {
|
||||
// 延迟更新,确保页面切换完成
|
||||
setTimeout(() => {
|
||||
this.updateActivePath();
|
||||
}, 100);
|
||||
},
|
||||
});
|
||||
},
|
||||
handleExternalRefresh() {
|
||||
@@ -165,10 +215,18 @@ export default {
|
||||
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'];
|
||||
|
||||
// admin_furniture 角色:只显示家具相关的tab和ucenter
|
||||
if (isAdminFurniture) {
|
||||
const furnitureTabs = ['furniture_reception', 'furniture_customer', 'furniture_top_sales', 'ucenter'];
|
||||
console.log('[TabBar][allowed] admin_furniture ->', furnitureTabs);
|
||||
return furnitureTabs;
|
||||
}
|
||||
|
||||
if (isMeetingAdmin) {
|
||||
// meeting_admin 角色:显示会议相关的tab和ucenter(我的)
|
||||
const meetingAdminTabs = [...meetingTabKeys, 'ucenter'];
|
||||
@@ -178,10 +236,10 @@ export default {
|
||||
|
||||
// 非 meeting_admin 角色:排除所有会议相关的tab
|
||||
if (isAdmin) {
|
||||
// admin 角色:显示所有tab(包括 ucenter),但排除会议相关的tab
|
||||
// admin 角色:显示所有tab(包括 ucenter),但排除会议相关的tab和家具相关的tab
|
||||
const all = this.allTabs
|
||||
.map((t) => t.key)
|
||||
.filter((key) => !meetingTabKeys.includes(key));
|
||||
.filter((key) => !meetingTabKeys.includes(key) && !['furniture_reception', 'furniture_customer', 'furniture_top_sales'].includes(key));
|
||||
// 确保 ucenter 被包含(用于"我的"页面)
|
||||
console.log('[TabBar][allowed] admin ->', all, 'includes ucenter:', all.includes('ucenter'));
|
||||
return all;
|
||||
@@ -198,10 +256,10 @@ export default {
|
||||
return studentTabs;
|
||||
}
|
||||
|
||||
// 其他角色:隐藏作业/教务/语音/表达,同时排除会议相关的tab,但确保包含ucenter
|
||||
// 其他角色:隐藏作业/教务/语音/表达,同时排除会议相关的tab和家具相关的tab,但确保包含ucenter
|
||||
const otherTabs = this.allTabs
|
||||
.map((t) => t.key)
|
||||
.filter((key) => !['homework', 'edu', 'voice', 'expression', ...meetingTabKeys].includes(key));
|
||||
.filter((key) => !['homework', 'edu', 'voice', 'expression', 'furniture_reception', 'furniture_customer', 'furniture_top_sales', ...meetingTabKeys].includes(key));
|
||||
// 确保 ucenter 被包含(任何角色都应该能看到"我的")
|
||||
if (!otherTabs.includes('ucenter')) {
|
||||
otherTabs.push('ucenter');
|
||||
@@ -212,8 +270,8 @@ export default {
|
||||
// #ifdef H5
|
||||
toggleNativeTabs() {
|
||||
// H5 平台自定义 tabbar 不生效,直接根据角色显隐原生 tabbar 项
|
||||
// 当前位置顺序:接待、客户、团队、销冠、工作台、我的、总结和统计
|
||||
const ORDER = ['reception', 'customer', 'team', 'champion', 'workspace', 'ucenter', 'meeting_summary'];
|
||||
// 当前位置顺序:接待、客户、团队、销冠、工作台、我的、总结和统计、家具接待、家具客户、家具销冠
|
||||
const ORDER = ['reception', 'customer', 'team', 'champion', 'workspace', 'ucenter', 'meeting_summary', 'furniture_reception', 'furniture_customer', 'furniture_top_sales'];
|
||||
const allowed = this.getAllowedKeys();
|
||||
// 限制重试次数,防止渲染时机未就绪
|
||||
this._h5TabRetries = (this._h5TabRetries || 0) + 1;
|
||||
|
||||
Reference in New Issue
Block a user