发布职位网格员模糊查询企业开发
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user