发布职位网格员模糊查询企业开发

This commit is contained in:
冯辉
2025-10-23 18:30:40 +08:00
parent 4450aa21bc
commit 0b339ee061
4 changed files with 280 additions and 129 deletions

View File

@@ -88,16 +88,10 @@ const generateTabbarList = () => {
// 优先从store获取如果为空则直接从缓存获取
const cachedUserInfo = uni.getStorageSync('userInfo') || {};
console.log('完整userInfo对象:', userInfo.value);
console.log('缓存中的userInfo:', cachedUserInfo);
// 获取isCompanyUser字段
const storeIsCompanyUser = userInfo.value?.isCompanyUser;
const cachedIsCompanyUser = cachedUserInfo.isCompanyUser;
console.log('store中的isCompanyUser:', storeIsCompanyUser);
console.log('缓存中的isCompanyUser:', cachedIsCompanyUser);
// 获取用户类型的逻辑:
// 1. 优先使用store中的isCompanyUser
// 2. 如果store中没有使用缓存中的isCompanyUser
@@ -140,18 +134,11 @@ const forceRefresh = () => {
// 触发响应式更新
const cachedUserInfo = uni.getStorageSync('userInfo') || {};
const currentUserType = userInfo.value?.isCompanyUser !== undefined ? userInfo.value.isCompanyUser : (cachedUserInfo.isCompanyUser !== undefined ? cachedUserInfo.isCompanyUser : 1);
console.log('强制刷新tabbar当前用户类型:', currentUserType);
};
// 监听用户类型变化只监听isCompanyUser字段
watch(() => userInfo.value?.isCompanyUser, (newIsCompanyUser, oldIsCompanyUser) => {
console.log('用户类型变化监听:', {
newIsCompanyUser,
oldIsCompanyUser,
userInfo: userInfo.value
});
if (newIsCompanyUser !== oldIsCompanyUser) {
console.log('用户类型发生变化重新生成tabbar:', newIsCompanyUser);
// 强制触发computed重新计算
forceRefresh();
}
@@ -159,9 +146,7 @@ watch(() => userInfo.value?.isCompanyUser, (newIsCompanyUser, oldIsCompanyUser)
// 监听用户信息变化(包括登录状态)
watch(() => userInfo.value, (newUserInfo, oldUserInfo) => {
console.log('用户信息变化监听:', { newUserInfo, oldUserInfo });
if (newUserInfo !== oldUserInfo) {
console.log('用户信息发生变化重新生成tabbar');
// 强制触发computed重新计算
forceRefresh();
}
@@ -196,8 +181,6 @@ const switchTab = (item, index) => {
onMounted(() => {
currentItem.value = props.currentPage;
// 调试信息显示当前用户状态和tabbar配置
console.log('CustomTabBar mounted, 用户信息:', userInfo.value);
console.log('当前tabbar配置:', tabbarList.value);
forceRefresh();
});
</script>

View File

@@ -720,10 +720,12 @@ defineExpose({
font-size: 28rpx
color: #333
text-align: right
line-height: 1.4
&::placeholder
color: #999
font-size: 26rpx
font-size: 28rpx
line-height: 1.4
.input-con
flex: 1
@@ -733,10 +735,12 @@ defineExpose({
background: transparent
border: none
outline: none
line-height: 1.4
&::placeholder
color: #999
font-size: 26rpx
font-size: 28rpx
line-height: 1.4
.input-content
flex: 1
@@ -752,7 +756,8 @@ defineExpose({
&.placeholder
color: #999
font-size: 26rpx
font-size: 28rpx
line-height: 1.4
&.intro-text
max-height: 80rpx

View File

@@ -3,7 +3,7 @@
<!-- 头部导航 -->
<view class="header">
<view class="header-left" @click="goBack">
<image src="@/static/icon/back.png" class="back-icon"></image>
<view class="back-arrow"><uni-icons type="search" size="32" color="#FFFFFF"></uni-icons></view>
</view>
<view class="header-title">选择企业</view>
<view class="header-right"></view>
@@ -13,12 +13,11 @@
<view class="search-container">
<view class="search-box">
<view class="search-icon">🔍</view>
<input
<input
class="search-input"
placeholder="请输入企业名称进行搜索"
v-model="searchKeyword"
@input="onSearchInput"
@confirm="onSearchConfirm"
/>
<view class="clear-btn" v-if="searchKeyword" @click="clearSearch">
<view class="clear-icon"></view>
@@ -28,47 +27,53 @@
<!-- 搜索结果 -->
<scroll-view class="content" scroll-y="true" :style="{ height: scrollViewHeight }">
<!-- 加载状态 -->
<!-- 搜索提示 -->
<view class="search-tip" v-if="!searchKeyword">
<text class="tip-text">请输入企业名称进行搜索</text>
</view>
<!-- 加载中 -->
<view class="loading-container" v-if="loading">
<view class="loading-text">搜索中...</view>
</view>
<!-- 搜索结果列表 -->
<view class="result-list" v-else-if="searchResults.length > 0">
<view class="result-list" v-if="searchResults.length > 0">
<view
class="result-item"
v-for="(company, index) in searchResults"
:key="company.id || index"
:key="company.companyId"
@click="selectCompany(company)"
>
<view class="company-info">
<view class="company-name">{{ company.name }}</view>
<view class="company-detail" v-if="company.address">
<text class="detail-label">地址</text>
<text class="detail-value">{{ company.address }}</text>
<view class="company-location" v-if="company.location">
<text class="location-icon">📍</text>
<text class="location-text">{{ company.location }}</text>
</view>
<view class="company-detail" v-if="company.contact">
<text class="detail-label">联系人</text>
<text class="detail-value">{{ company.contact }}</text>
<view class="company-scale" v-if="company.scale">
<text class="scale-label">规模</text>
<text class="scale-text">{{ getScaleText(company.scale) }}</text>
</view>
<view class="company-nature" v-if="company.nature">
<text class="nature-label">性质</text>
<text class="nature-text">{{ getNatureText(company.nature) }}</text>
</view>
<view class="company-description" v-if="company.description">
<text class="desc-text">{{ company.description }}</text>
</view>
</view>
<view class="select-icon">
<view class="arrow-icon">></view>
<view class="arrow-icon"></view>
</view>
</view>
</view>
<!-- 空状态 -->
<view class="empty-container" v-else-if="searchKeyword && !loading">
<view class="empty-icon">🔍</view>
<view class="empty-text">未找到相关企业</view>
<view class="empty-tip">请尝试其他关键词</view>
</view>
<!-- 初始状态 -->
<view class="initial-container" v-else-if="!searchKeyword">
<view class="initial-icon">🔍</view>
<view class="initial-text">请输入企业名称进行搜索</view>
<!-- 无结果提示 -->
<view class="no-result" v-if="searchKeyword && !loading && searchResults.length === 0">
<view class="empty-icon">📭</view>
<view class="no-result-text">未找到相关企业</view>
<view class="no-result-tip">请尝试其他关键词</view>
</view>
<!-- 底部安全区域 -->
@@ -78,24 +83,27 @@
</template>
<script setup>
import { ref, reactive, onMounted } from 'vue';
import { ref, onMounted } from 'vue';
import { createRequest } from '@/utils/request';
// 搜索相关状态
// 搜索关键词
const searchKeyword = ref('');
// 搜索结果
const searchResults = ref([]);
// 加载状态
const loading = ref(false);
const scrollViewHeight = ref('calc(100vh - 200rpx)');
// 防抖定时器
let debounceTimer = null;
// 滚动视图高度
const scrollViewHeight = ref('calc(100vh - 200rpx)');
// 计算滚动视图高度
const calculateScrollViewHeight = () => {
const systemInfo = uni.getSystemInfoSync();
const windowHeight = systemInfo.windowHeight;
const headerHeight = 100; // 头部高度
const searchHeight = 100; // 搜索框高度
const searchHeight = 120; // 搜索框高度
const scrollHeight = windowHeight - headerHeight - searchHeight;
scrollViewHeight.value = `${scrollHeight}px`;
};
@@ -112,21 +120,14 @@ const onSearchInput = () => {
clearTimeout(debounceTimer);
}
// 设置新的定时器500ms后执行搜索
// 设置新的定时器
debounceTimer = setTimeout(() => {
if (searchKeyword.value.trim()) {
searchCompanies();
} else {
searchResults.value = [];
}
}, 500);
};
// 搜索确认
const onSearchConfirm = () => {
if (searchKeyword.value.trim()) {
searchCompanies();
}
}, 500); // 500ms 防抖延迟
};
// 搜索企业
@@ -141,10 +142,10 @@ const searchCompanies = async () => {
const response = await createRequest('/app/company/likeList', {
name: searchKeyword.value.trim()
}, 'GET', false);
}, 'get', false);
if (response.code === 200) {
searchResults.value = response.data || [];
searchResults.value = response.rows || [];
} else {
uni.showToast({
title: response.msg || '搜索失败',
@@ -152,7 +153,6 @@ const searchCompanies = async () => {
});
searchResults.value = [];
}
} catch (error) {
console.error('搜索企业失败:', error);
uni.showToast({
@@ -165,18 +165,6 @@ const searchCompanies = async () => {
}
};
// 选择企业
const selectCompany = (company) => {
// 返回上一页并传递选中的企业信息
uni.navigateBack({
success: () => {
// 通过事件总线或全局数据传递选中的企业信息
getApp().globalData = getApp().globalData || {};
getApp().globalData.selectedCompany = company;
}
});
};
// 清除搜索
const clearSearch = () => {
searchKeyword.value = '';
@@ -186,6 +174,48 @@ const clearSearch = () => {
}
};
// 获取企业规模文本
const getScaleText = (scale) => {
const scaleMap = {
'1': '1-20人',
'2': '21-50人',
'3': '51-100人',
'4': '101-200人',
'5': '201-500人',
'6': '500人以上'
};
return scaleMap[scale] || '未知';
};
// 获取企业性质文本
const getNatureText = (nature) => {
const natureMap = {
'1': '有限责任公司',
'2': '股份有限公司',
'3': '个人独资企业',
'4': '合伙企业',
'5': '外商投资企业',
'6': '其他'
};
return natureMap[nature] || '未知';
};
// 选择企业
const selectCompany = (company) => {
// 返回上一页并传递选中的企业信息
uni.navigateBack({
delta: 1,
success: () => {
// 通过事件总线或全局状态传递数据
uni.$emit('companySelected', {
id: company.companyId,
name: company.name,
address: company.location
});
}
});
};
// 返回上一页
const goBack = () => {
uni.navigateBack();
@@ -217,9 +247,10 @@ const goBack = () => {
align-items: center;
justify-content: center;
.back-icon {
width: 40rpx;
height: 40rpx;
.back-arrow {
font-size: 40rpx;
color: #333;
font-weight: bold;
}
}
@@ -242,33 +273,38 @@ const goBack = () => {
.search-box {
display: flex;
align-items: center;
background: #f8f8f8;
background: #f5f5f5;
border-radius: 12rpx;
padding: 0 20rpx;
height: 80rpx;
.search-icon {
font-size: 32rpx;
color: #999;
margin-right: 20rpx;
color: #999;
}
.search-input {
flex: 1;
height: 80rpx;
height: 100%;
background: transparent;
border: none;
font-size: 28rpx;
color: #333;
line-height: 1.4;
display: flex;
align-items: center;
&::placeholder {
color: #999;
font-size: 28rpx;
line-height: 1.4;
}
}
.clear-btn {
width: 40rpx;
height: 40rpx;
width: 32rpx;
height: 32rpx;
display: flex;
align-items: center;
justify-content: center;
@@ -288,6 +324,18 @@ const goBack = () => {
overflow: hidden;
}
.search-tip {
display: flex;
justify-content: center;
align-items: center;
height: 400rpx;
.tip-text {
font-size: 28rpx;
color: #999;
}
}
.loading-container {
display: flex;
justify-content: center;
@@ -296,7 +344,7 @@ const goBack = () => {
.loading-text {
font-size: 28rpx;
color: #999;
color: #666;
}
}
@@ -306,6 +354,7 @@ const goBack = () => {
.result-item {
display: flex;
align-items: center;
justify-content: space-between;
padding: 30rpx;
border-bottom: 1rpx solid #f0f0f0;
@@ -321,27 +370,60 @@ const goBack = () => {
flex: 1;
.company-name {
font-size: 32rpx;
font-weight: 600;
font-size: 30rpx;
color: #333;
margin-bottom: 10rpx;
font-weight: 500;
margin-bottom: 15rpx;
line-height: 1.4;
}
.company-detail {
font-size: 24rpx;
color: #666;
margin-bottom: 5rpx;
.company-location {
display: flex;
align-items: center;
margin-bottom: 10rpx;
&:last-child {
margin-bottom: 0;
.location-icon {
font-size: 20rpx;
margin-right: 8rpx;
}
.detail-label {
color: #999;
}
.detail-value {
.location-text {
font-size: 24rpx;
color: #666;
flex: 1;
}
}
.company-scale, .company-nature {
display: flex;
align-items: center;
margin-bottom: 8rpx;
.scale-label, .nature-label {
font-size: 22rpx;
color: #999;
margin-right: 8rpx;
}
.scale-text, .nature-text {
font-size: 22rpx;
color: #666;
}
}
.company-description {
margin-top: 10rpx;
.desc-text {
font-size: 22rpx;
color: #888;
line-height: 1.4;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
line-clamp: 2;
overflow: hidden;
text-overflow: ellipsis;
}
}
}
@@ -361,7 +443,7 @@ const goBack = () => {
}
}
.empty-container {
.no-result {
display: flex;
flex-direction: column;
align-items: center;
@@ -370,41 +452,21 @@ const goBack = () => {
.empty-icon {
font-size: 120rpx;
color: #ccc;
margin-bottom: 30rpx;
}
.empty-text {
font-size: 32rpx;
color: #333;
.no-result-text {
font-size: 28rpx;
color: #666;
margin-bottom: 10rpx;
}
.empty-tip {
.no-result-tip {
font-size: 24rpx;
color: #999;
}
}
.initial-container {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 400rpx;
.initial-icon {
font-size: 120rpx;
color: #ccc;
margin-bottom: 30rpx;
}
.initial-text {
font-size: 28rpx;
color: #999;
}
}
.bottom-safe-area {
height: 120rpx;
background: transparent;

View File

@@ -21,13 +21,36 @@
v-model="formData.jobTitle"
/>
</view>
<view class="form-group">
<view class="label">招聘公司</view>
<view class="form-group" v-if="userType === 0">
<view class="label">招聘公司</view>
<input
class="input"
placeholder="请输入招聘公司"
v-model="formData.companyName"
/>
</view>
<view class="form-group" v-if="userType === 2">
<view class="label">招聘公司</view>
<!-- 企业用户直接输入 -->
<input
v-if="userType === 1"
class="input"
placeholder="请输入公司名称"
v-model="formData.companyName"
/>
<!-- 网格员点击跳转搜索 -->
<view
v-else
class="company-selector"
@click="goToCompanySearch"
>
<view class="selector-text" :class="{ 'placeholder': !formData.companyName }">
{{ formData.companyName || '请选择企业' }}
</view>
<view class="selector-arrow">
<view class="arrow-icon"></view>
</view>
</view>
</view>
<view class="form-group">
<view class="label">最小薪资 (/)</view>
@@ -201,11 +224,13 @@
</template>
<script setup>
import { ref, reactive, onMounted } from 'vue';
import { ref, reactive, onMounted, onUnmounted } from 'vue';
import { storeToRefs } from 'pinia';
import { createRequest } from '@/utils/request';
import useDictStore from '@/stores/useDictStore';
import useUserStore from '@/stores/useUserStore';
const userStore = useUserStore();
const cachedUserInfo = uni.getStorageSync('userInfo') || {};
// 表单数据
const formData = reactive({
jobTitle: '',
@@ -233,7 +258,6 @@ const formData = reactive({
// 字典存储
const dictStore = useDictStore();
const userStore = useUserStore();
// 选择器数据
const educationLevels = ref([]);
@@ -261,11 +285,23 @@ const calculateScrollViewHeight = () => {
const scrollHeight = windowHeight - headerHeight - footerHeight;
scrollViewHeight.value = `${scrollHeight}px`;
};
const userType = ref(Number(userStore.userInfo.isCompanyUser));
console.log('完整userInfo对象:---223--', userType.value);
// 页面加载时计算高度和初始化数据
onMounted(async () => {
console.log('完整userInfo对象:-----', );
console.log('缓存中的userInfo:----', cachedUserInfo);
calculateScrollViewHeight();
await initFormData();
// 监听企业选择事件
uni.$on('companySelected', handleCompanySelected);
});
// 页面卸载时移除事件监听
onUnmounted(() => {
uni.$off('companySelected', handleCompanySelected);
});
// 初始化表单数据
@@ -368,6 +404,19 @@ const removeContact = (index) => {
}
};
// 跳转到企业搜索页面
const goToCompanySearch = () => {
uni.navigateTo({
url: '/pages/job/companySearch'
});
};
// 处理企业选择
const handleCompanySelected = (company) => {
formData.companyName = company.name;
formData.companyId = company.id;
};
// 返回上一页
const goBack = () => {
uni.navigateBack();
@@ -596,10 +645,14 @@ const validateForm = () => {
position: relative;
z-index: 1;
box-sizing: border-box;
line-height: 1.4;
display: flex;
align-items: center;
&::placeholder {
color: #999;
font-size: 24rpx;
font-size: 28rpx;
line-height: 1.4;
}
&:focus {
@@ -621,10 +674,12 @@ const validateForm = () => {
position: relative;
z-index: 1;
box-sizing: border-box;
line-height: 1.4;
&::placeholder {
color: #999;
font-size: 24rpx;
font-size: 28rpx;
line-height: 1.4;
}
&:focus {
@@ -668,6 +723,46 @@ const validateForm = () => {
}
}
// 企业选择器样式
.company-selector {
display: flex;
align-items: center;
justify-content: space-between;
height: 80rpx;
background: #fff;
border: none;
border-radius: 0;
padding: 0 0 20rpx 0;
box-sizing: border-box;
.selector-text {
font-size: 28rpx;
color: #333;
&.placeholder {
color: #999;
font-size: 24rpx;
}
}
.selector-arrow {
width: 40rpx;
height: 40rpx;
display: flex;
align-items: center;
justify-content: center;
.arrow-icon {
font-size: 24rpx;
color: #999;
}
}
&:active {
background: #f8f8f8;
}
}
// 联系人管理样式
.contacts-container {
.contact-item {
@@ -728,6 +823,12 @@ const validateForm = () => {
.input {
font-size: 26rpx;
padding-bottom: 15rpx;
line-height: 1.4;
&::placeholder {
font-size: 26rpx;
line-height: 1.4;
}
}
}
}