diff --git a/components/AppLayout/AppLayout.vue b/components/AppLayout/AppLayout.vue index e9b405f..c439a44 100644 --- a/components/AppLayout/AppLayout.vue +++ b/components/AppLayout/AppLayout.vue @@ -6,6 +6,7 @@ > @@ -49,7 +50,7 @@ const emit = defineEmits(['onScrollBottom']); defineProps({ title: { type: String, - default: '标题', + default: '', }, border: { type: Boolean, diff --git a/components/CustomTabBar/CustomTabBar.vue b/components/CustomTabBar/CustomTabBar.vue index 49ffe5c..72cc36a 100644 --- a/components/CustomTabBar/CustomTabBar.vue +++ b/components/CustomTabBar/CustomTabBar.vue @@ -154,6 +154,79 @@ watch(() => userInfo.value, (newUserInfo, oldUserInfo) => { // 切换tab const switchTab = (item, index) => { + // 检查是否为"发布岗位"页面,需要判断企业信息是否完整 + if (item.path === '/pages/job/publishJob') { + // 检查用户是否已登录 + const token = uni.getStorageSync('token') || ''; + const hasLogin = userStore.hasLogin; + + if (!token || !hasLogin) { + // 未登录,发送事件显示登录弹窗 + uni.$emit('showLoginModal'); + return; // 不进行页面跳转 + } + + // 已登录,检查企业信息是否完整 + const cachedUserInfo = uni.getStorageSync('userInfo') || {}; + const storeUserInfo = userInfo.value || {}; + const currentUserInfo = storeUserInfo.id ? storeUserInfo : cachedUserInfo; + + // 判断企业信息字段company是否为null或undefined + if (!currentUserInfo.company || currentUserInfo.company === null) { + // 企业信息为空,跳转到企业信息补全页面 + uni.navigateTo({ + url: '/pages/complete-info/company-info', + }); + } else { + // 企业信息完整,跳转到发布岗位页面 + uni.navigateTo({ + url: '/pages/job/publishJob', + }); + } + + currentItem.value = item.id; + return; + } + + // 检查是否为"我的"页面,需要登录验证和用户类型判断 + if (item.path === '/pages/mine/mine') { + // 检查用户是否已登录 + const token = uni.getStorageSync('token') || ''; + const hasLogin = userStore.hasLogin; + + if (!token || !hasLogin) { + // 未登录,发送事件显示登录弹窗 + uni.$emit('showLoginModal'); + return; // 不进行页面跳转 + } + + // 已登录,根据用户类型跳转到不同的"我的"页面 + const cachedUserInfo = uni.getStorageSync('userInfo') || {}; + const storeIsCompanyUser = userInfo.value?.isCompanyUser; + const cachedIsCompanyUser = cachedUserInfo.isCompanyUser; + + // 获取用户类型 + const userType = Number(storeIsCompanyUser !== undefined ? storeIsCompanyUser : (cachedIsCompanyUser !== undefined ? cachedIsCompanyUser : 1)); + + let targetPath = '/pages/mine/mine'; // 默认求职者页面 + + if (userType === 0) { + // 企业用户,跳转到企业我的页面 + targetPath = '/pages/mine/company-mine'; + } else { + // 求职者或其他用户类型,跳转到普通我的页面 + targetPath = '/pages/mine/mine'; + } + + // 跳转到对应的页面 + uni.navigateTo({ + url: targetPath, + }); + + currentItem.value = item.id; + return; + } + // 判断是否为 tabBar 页面 const tabBarPages = [ '/pages/index/index', @@ -164,12 +237,12 @@ const switchTab = (item, index) => { ]; if (tabBarPages.includes(item.path)) { - // tabBar 页面使用 switchTab - uni.navigateTo({ + // TabBar 页面使用 redirectTo 避免页面栈溢出 + uni.redirectTo({ url: item.path, }); } else { - // 非 tabBar 页面使用 navigateTo + // 非 TabBar 页面使用 navigateTo uni.navigateTo({ url: item.path, }); diff --git a/components/tabbar/midell-box.vue b/components/tabbar/midell-box.vue index 031ff12..6df2aaa 100644 --- a/components/tabbar/midell-box.vue +++ b/components/tabbar/midell-box.vue @@ -144,7 +144,7 @@ onMounted(() => { }); const changeItem = (item) => { - // 判断是否为 tabBar 页面 + // 判断是否为 TabBar 页面 const tabBarPages = [ '/pages/index/index', '/pages/careerfair/careerfair', @@ -154,12 +154,12 @@ const changeItem = (item) => { ]; if (tabBarPages.includes(item.path)) { - // tabBar 页面使用 switchTab - uni.switchTab({ + // TabBar 页面使用 redirectTo 避免页面栈溢出 + uni.redirectTo({ url: item.path, }); } else { - // 非 tabBar 页面使用 navigateTo + // 非 TabBar 页面使用 navigateTo uni.navigateTo({ url: item.path, }); diff --git a/packageA/pages/addWorkExperience/addWorkExperience.vue b/packageA/pages/addWorkExperience/addWorkExperience.vue index 2129178..a0090af 100644 --- a/packageA/pages/addWorkExperience/addWorkExperience.vue +++ b/packageA/pages/addWorkExperience/addWorkExperience.vue @@ -1,16 +1,5 @@