From b72b7dd7d6ea62dd9b840908889b9c8ae1021ac8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=86=AF=E8=BE=89?= <13935151924@163.com>
Date: Thu, 23 Oct 2025 17:16:16 +0800
Subject: [PATCH] =?UTF-8?q?=E5=B2=97=E4=BD=8D=E5=8F=91=E5=B8=83=E5=BC=80?=
=?UTF-8?q?=E5=8F=91?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
App.vue | 7 +-
components/CustomTabBar/CustomTabBar.vue | 281 +++++++
.../UserTypeSwitcher/UserTypeSwitcher.vue | 4 +-
components/selectPopup/selectPopup.vue | 153 +++-
components/tabbar/midell-box.vue | 64 +-
components/wxAuthLogin/WxAuthLogin.vue | 47 +-
docs/企业搜索功能实现说明.md | 187 +++++
docs/自定义TabBar使用说明.md | 129 ++++
pages.json | 125 ++-
pages/careerfair/careerfair.vue | 9 +-
pages/chat/chat.vue | 5 +
pages/complete-info/company-info.vue | 6 +-
pages/complete-info/complete-info.vue | 358 +++++++--
pages/index/components/index-one.vue | 158 +++-
pages/index/index.vue | 9 +-
pages/job/companySearch.vue | 412 ++++++++++
pages/job/publishJob.vue | 722 +++++++++++++-----
pages/mine/mine.vue | 5 +
pages/msglog/msglog.vue | 6 +
pages/test/company-search-test.vue | 170 +++++
pages/test/homepage-test.vue | 296 +++++++
pages/test/tabbar-test.vue | 293 +++++++
pages/test/tabbar-user-type-test.vue | 232 ++++++
stores/useUserStore.js | 6 +-
utils/tabbarManager.js | 45 ++
25 files changed, 3402 insertions(+), 327 deletions(-)
create mode 100644 components/CustomTabBar/CustomTabBar.vue
create mode 100644 docs/企业搜索功能实现说明.md
create mode 100644 docs/自定义TabBar使用说明.md
create mode 100644 pages/job/companySearch.vue
create mode 100644 pages/test/company-search-test.vue
create mode 100644 pages/test/homepage-test.vue
create mode 100644 pages/test/tabbar-test.vue
create mode 100644 pages/test/tabbar-user-type-test.vue
create mode 100644 utils/tabbarManager.js
diff --git a/App.vue b/App.vue
index dd7a106..e2099f2 100644
--- a/App.vue
+++ b/App.vue
@@ -3,17 +3,20 @@ import { reactive, inject, onMounted } from 'vue';
import { onLaunch, onShow, onHide } from '@dcloudio/uni-app';
import useUserStore from './stores/useUserStore';
import useDictStore from './stores/useDictStore';
+import { tabbarManager } from './utils/tabbarManager';
const { $api, navTo, appendScriptTagElement } = inject('globalFunction');
import config from '@/config.js';
onLaunch((options) => {
useUserStore().initSeesionId(); //更新
useDictStore().getDictData();
- // uni.hideTabBar();
- // 尝试从缓存恢复用户信息
+ // 先尝试从缓存恢复用户信息
const restored = useUserStore().restoreUserInfo();
+ // 用户信息恢复后再初始化自定义tabbar
+ tabbarManager.initTabBar();
+
if (restored) {
// 如果成功恢复用户信息,验证token是否有效
let token = uni.getStorageSync('token') || '';
diff --git a/components/CustomTabBar/CustomTabBar.vue b/components/CustomTabBar/CustomTabBar.vue
new file mode 100644
index 0000000..22ff7e4
--- /dev/null
+++ b/components/CustomTabBar/CustomTabBar.vue
@@ -0,0 +1,281 @@
+
+
+
+
+
+
+ {{ item.badge }}
+
+ {{ item.text }}
+
+
+
+
+
+
+
+
diff --git a/components/UserTypeSwitcher/UserTypeSwitcher.vue b/components/UserTypeSwitcher/UserTypeSwitcher.vue
index cee16dc..d968a7d 100644
--- a/components/UserTypeSwitcher/UserTypeSwitcher.vue
+++ b/components/UserTypeSwitcher/UserTypeSwitcher.vue
@@ -31,13 +31,13 @@ const userTypes = [
{ value: 3, label: '政府人员' }
];
-const currentUserType = computed(() => userInfo.value?.userType || 0);
+const currentUserType = computed(() => userInfo.value?.isCompanyUser !== undefined ? userInfo.value.isCompanyUser : 0);
const switchUserType = (userType) => {
console.log('切换用户类型:', userType);
console.log('切换前 userInfo:', userInfo.value);
- userInfo.value.userType = userType;
+ userInfo.value.isCompanyUser = userType;
console.log('切换后 userInfo:', userInfo.value);
diff --git a/components/selectPopup/selectPopup.vue b/components/selectPopup/selectPopup.vue
index c91a6f7..3a235fa 100644
--- a/components/selectPopup/selectPopup.vue
+++ b/components/selectPopup/selectPopup.vue
@@ -13,7 +13,30 @@
确认
- {{ item.badge }}
+ {{ item.badge }}
{{ item.text }}
@@ -19,7 +19,7 @@
diff --git a/pages/job/publishJob.vue b/pages/job/publishJob.vue
index f159601..0e9ebce 100644
--- a/pages/job/publishJob.vue
+++ b/pages/job/publishJob.vue
@@ -10,12 +10,11 @@
-
-
-
- 岗位基本信息
+
+
+
- 岗位名称 *
+ 岗位名称
- 岗位类型 *
-
- {{ selectedJobType || '请选择岗位类型' }}
-
-
-
- 工作地点 *
+ 招聘会公司
-
-
-
-
- 薪资待遇
-
-
- 最低薪资
-
-
- -
-
- 最高薪资
-
-
+
+ 最小薪资 (元/月)
+
- 薪资单位
-
- {{ selectedSalaryUnit || '请选择薪资单位' }}
-
+ 最大薪资 (元/月)
+
-
-
-
-
- 任职要求
学历要求
- {{ selectedEducation || '请选择学历要求' }}
+ {{ selectedEducation || '请选择学历要求' }}
@@ -99,10 +64,23 @@
- {{ selectedExperience || '请选择工作经验' }}
+ {{ selectedExperience || '请选择工作经验' }}
+
+
+
+ 工作区县
+
+ {{ selectedWorkDistrict || '请选择工作区县' }}
@@ -114,21 +92,49 @@
v-model="formData.recruitCount"
/>
+
+ 工作地点
+
+
+
+ 选择位置
+
+
+
+
+ 岗位分类
+
+ {{ selectedJobCategory || '请选择岗位分类' }}
+
+
-
-
+
+
岗位描述
- 岗位职责
+
+
+
+
+ 任职要求
- 任职要求
-
-
+
+
联系方式
-
- 联系人
-
+
+
+
+
+ 联系人姓名
+
+
+
+ 联系电话
+
+
+
-
- 联系电话
-
-
-
- 联系邮箱
-
+
+ +
+ 添加联系人
-
+
+
+
+
@@ -39,6 +42,7 @@ import { onLoad, onShow } from '@dcloudio/uni-app';
import Tabbar from '@/components/tabbar/midell-box.vue';
import ReadComponent from './read.vue';
import UnreadComponent from './unread.vue';
+import { tabbarManager } from '@/utils/tabbarManager';
const loadedMap = reactive([false, false]);
const swiperRefs = [ref(null), ref(null)];
const components = [ReadComponent, UnreadComponent];
@@ -49,6 +53,8 @@ const { unreadCount } = storeToRefs(useReadMsg());
onShow(() => {
// 获取消息列表
useReadMsg().fetchMessages();
+ // 更新自定义tabbar选中状态
+ tabbarManager.updateSelected(3);
});
const state = reactive({
current: 0,
diff --git a/pages/test/company-search-test.vue b/pages/test/company-search-test.vue
new file mode 100644
index 0000000..5de15c5
--- /dev/null
+++ b/pages/test/company-search-test.vue
@@ -0,0 +1,170 @@
+
+
+
+
+
+ 功能说明
+
+ • 企业用户(isCompanyUser=0):招聘公司输入框为普通输入框
+ • 网格员(isCompanyUser=2):招聘公司输入框为选择器,点击跳转到搜索页面
+ • 搜索页面支持防抖节流,500ms延迟
+ • 搜索接口:/app/company/likeList,参数:name
+
+
+
+
+ 当前用户类型
+
+ 用户类型:
+ {{ getCurrentTypeLabel() }} ({{ currentUserType }})
+
+
+ 是否企业用户:
+ {{ isCompanyUser ? '是' : '否' }}
+
+
+
+
+ 测试操作
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/pages/test/homepage-test.vue b/pages/test/homepage-test.vue
new file mode 100644
index 0000000..dcfde70
--- /dev/null
+++ b/pages/test/homepage-test.vue
@@ -0,0 +1,296 @@
+
+
+
+
+
+
+ 当前用户类型:
+ {{ getCurrentUserTypeLabel() }}
+
+
+
+ 登录状态:
+
+ {{ hasLogin ? '已登录' : '未登录' }}
+
+
+
+
+ 调试信息:
+ userType: {{ userInfo?.userType ?? 'undefined' }}
+ hasLogin: {{ hasLogin }}
+ shouldShowJobSeeker: {{ shouldShowJobSeekerContent }}
+ shouldShowCompany: {{ shouldShowCompanyContent }}
+ 完整userInfo: {{ JSON.stringify(userInfo) }}
+
+
+
+ 首页内容预览:
+
+
+ ✅ 求职者内容
+ • 附近工作卡片
+ • 服务功能网格
+ • 职位筛选器
+
+
+
+ ✅ 企业用户内容
+ • 企业服务标题
+ • 发布岗位按钮
+ • 企业管理功能
+
+
+
+ ❌ 无内容显示
+ 请检查用户类型设置
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/pages/test/tabbar-test.vue b/pages/test/tabbar-test.vue
new file mode 100644
index 0000000..2f86fbe
--- /dev/null
+++ b/pages/test/tabbar-test.vue
@@ -0,0 +1,293 @@
+
+
+
+
+
+
+ 当前用户类型:
+ {{ getCurrentUserTypeLabel() }}
+
+
+
+ 登录状态:
+
+ {{ hasLogin ? '已登录' : '未登录' }}
+
+
+
+
+ 调试信息:
+ userType: {{ userInfo?.userType ?? 'undefined' }}
+ hasLogin: {{ hasLogin }}
+ shouldShowJobSeeker: {{ shouldShowJobSeekerContent }}
+ shouldShowCompany: {{ shouldShowCompanyContent }}
+
+
+
+ 切换用户类型:
+
+
+
+
+
+
+ 功能说明:
+ • 未登录状态:默认显示求职者tabbar(职位 + 招聘会 + AI+ + 消息 + 我的)
+ • 企业用户(userType=0):显示"发布岗位"导航,隐藏"招聘会"
+ • 求职者用户(userType=1,2,3):显示"招聘会"导航
+ • 登录后根据用户角色自动切换对应的tabbar
+ • 系统默认tabbar已被隐藏,使用自定义tabbar
+
+
+
+ 测试功能:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/pages/test/tabbar-user-type-test.vue b/pages/test/tabbar-user-type-test.vue
new file mode 100644
index 0000000..1c8fca4
--- /dev/null
+++ b/pages/test/tabbar-user-type-test.vue
@@ -0,0 +1,232 @@
+
+
+
+
+
+
+ 当前用户类型:
+ {{ getCurrentTypeLabel() }} ({{ currentUserType }})
+
+
+
+ 切换用户类型:
+
+
+
+
+
+
+ TabBar预览:
+
+
+ {{ item.text }}
+
+
+
+
+
+ 功能说明:
+ • 企业用户(userType=0):显示"发布岗位"导航
+ • 求职者(userType=1):显示"招聘会"导航
+ • 网格员(userType=2):显示"招聘会"导航
+ • 政府人员(userType=3):显示"招聘会"导航
+ • 切换用户类型后,底部导航栏会自动更新
+
+
+
+
+
+
+
+
diff --git a/stores/useUserStore.js b/stores/useUserStore.js
index 14160f0..baf025f 100644
--- a/stores/useUserStore.js
+++ b/stores/useUserStore.js
@@ -117,9 +117,9 @@ const useUserStore = defineStore("user", () => {
hasLogin.value = true;
// 模拟添加用户类型字段,实际项目中应该从接口获取
- if (!userInfo.value.userType) {
- userInfo.value.userType = 0; // 默认设置为企业用户
- }
+ // if (!userInfo.value.userType) {
+ // userInfo.value.userType = 1; // 默认设置为求职者用户
+ // }
// 持久化存储用户信息到本地缓存
uni.setStorageSync('userInfo', values.data);
diff --git a/utils/tabbarManager.js b/utils/tabbarManager.js
new file mode 100644
index 0000000..e940491
--- /dev/null
+++ b/utils/tabbarManager.js
@@ -0,0 +1,45 @@
+// 自定义tabbar管理器
+export const tabbarManager = {
+ // 显示tabbar
+ showTabBar() {
+ if (typeof getTabBar === 'function' && getTabBar()) {
+ getTabBar().setData({
+ selected: 0
+ });
+ }
+ },
+
+ // 更新tabbar选中状态
+ updateSelected(index) {
+ if (typeof getTabBar === 'function' && getTabBar()) {
+ getTabBar().setData({
+ selected: index
+ });
+ }
+ },
+
+ // 根据用户类型更新tabbar
+ updateTabBarByUserType() {
+ if (typeof getTabBar === 'function' && getTabBar()) {
+ const userInfo = uni.getStorageSync('userInfo') || {};
+ const userType = userInfo.isCompanyUser !== undefined ? userInfo.isCompanyUser : 1;
+ getTabBar().generateTabbarList(userType);
+ }
+ },
+
+ // 初始化tabbar
+ initTabBar() {
+ // 延迟初始化自定义tabbar
+ setTimeout(() => {
+ this.updateTabBarByUserType();
+ }, 200);
+ },
+
+ // 强制刷新tabbar(登录后调用)
+ refreshTabBar() {
+ // 延迟刷新,确保用户信息已更新
+ setTimeout(() => {
+ this.updateTabBarByUserType();
+ }, 100);
+ }
+};