Files
ks-app-employment-service/pages/search/search.vue

373 lines
10 KiB
Vue
Raw Normal View History

2025-05-13 11:10:38 +08:00
<template>
2025-10-20 11:05:11 +08:00
<view class="container safe-area-top">
2025-06-26 08:56:42 +08:00
<view>
<view class="top">
<image class="btnback button-click" src="@/static/icon/back.png" @click="navBack"></image>
<view class="search-box">
<uni-icons
class="iconsearch"
color="#666666"
type="search"
size="18"
@confirm="searchCollection"
></uni-icons>
<input
class="inputed"
type="text"
focus
v-model="searchValue"
placeholder="搜索职位名称"
placeholder-class="placeholder"
@confirm="searchBtn"
/>
</view>
<view class="search-btn button-click" @click="searchBtn">搜索</view>
</view>
2025-05-13 11:10:38 +08:00
</view>
2025-06-26 08:56:42 +08:00
<scroll-view scroll-y class="Detailscroll-view" v-show="listCom.length" @scrolltolower="choosePosition">
2025-09-29 11:53:10 +08:00
<view class="cards-box">
2025-06-26 08:56:42 +08:00
<renderJobs :list="listCom" :longitude="longitudeVal" :latitude="latitudeVal"></renderJobs>
</view>
2025-05-13 11:10:38 +08:00
</scroll-view>
2025-06-26 08:56:42 +08:00
<view class="main-content" v-show="!listCom.length">
2025-05-13 11:10:38 +08:00
<view class="content-top">
<view class="top-left">历史搜索</view>
<view class="top-right button-click" @click="remove">
<uni-icons type="trash" color="#C1C1C1" size="20"></uni-icons>
</view>
</view>
<view class="content-history">
<view class="history-tag" v-for="(item, index) in historyList" :key="index" @click="searchFn(item)">
{{ item }}
</view>
</view>
</view>
</view>
</template>
<script setup>
2025-06-26 08:56:42 +08:00
import { inject, ref, reactive, nextTick } from 'vue';
2025-05-15 14:17:51 +08:00
import { onLoad, onShow } from '@dcloudio/uni-app';
2025-05-13 11:10:38 +08:00
import SelectJobs from '@/components/selectJobs/selectJobs.vue';
2025-06-26 08:56:42 +08:00
const { $api, navBack, navTo } = inject('globalFunction');
2025-05-13 11:10:38 +08:00
import useLocationStore from '@/stores/useLocationStore';
import { storeToRefs } from 'pinia';
2025-06-26 08:56:42 +08:00
import { useColumnCount } from '@/hook/useColumnCount';
import { usePagination } from '@/hook/usePagination';
import img from '@/static/icon/filter.png';
2025-05-15 14:17:51 +08:00
const { longitudeVal, latitudeVal } = storeToRefs(useLocationStore());
2025-05-13 11:10:38 +08:00
const searchValue = ref('');
const historyList = ref([]);
2025-09-29 11:53:10 +08:00
const searchParams = ref({});
2025-06-26 08:56:42 +08:00
const listCom = ref([]);
2025-05-13 11:10:38 +08:00
const pageState = reactive({
page: 0,
total: 0,
maxPage: 2,
pageSize: 10,
search: {
order: 0,
},
});
2025-06-26 08:56:42 +08:00
// 响应式搜索条件(可以被修改)
async function choosePosition(index) {
2025-09-29 11:53:10 +08:00
getJobList('add');
2025-06-26 08:56:42 +08:00
}
2025-05-13 11:10:38 +08:00
onLoad(() => {
let arr = uni.getStorageSync('searchList');
if (arr) {
historyList.value = uni.getStorageSync('searchList');
}
});
2025-06-26 08:56:42 +08:00
function changeType(type) {
2025-09-29 11:53:10 +08:00
getJobList('refresh');
2025-06-26 08:56:42 +08:00
}
2025-05-13 11:10:38 +08:00
function searchFn(item) {
searchValue.value = item;
searchBtn();
}
function searchBtn() {
if (!searchValue.value) {
return;
}
historyList.value.unshift(searchValue.value);
historyList.value = unique(historyList.value);
uni.setStorageSync('searchList', historyList.value);
2025-06-26 08:56:42 +08:00
searchParams.value = {
jobTitle: searchValue,
};
2025-09-29 11:53:10 +08:00
getJobList('refresh');
2025-05-13 11:10:38 +08:00
}
function searchCollection(e) {
const value = e.detail.value;
pageState.search.jobTitle = value;
getJobList('refresh');
}
function unique(arr) {
for (var i = 0; i < arr.length; i++) {
for (var j = i + 1; j < arr.length; j++) {
if (arr[i] == arr[j]) {
//第一个等同于第二个splice方法删除第二个
arr.splice(j, 1);
j--;
}
}
}
return arr;
}
function remove() {
uni.removeStorage({
key: 'searchList',
});
historyList.value = [];
}
2025-06-26 08:56:42 +08:00
function nextDetail(job) {
// 记录岗位类型,用作数据分析
if (job.jobCategory) {
const recordData = recommedIndexDb.JobParameter(job);
recommedIndexDb.addRecord(recordData);
}
navTo(`/packageA/pages/post/post?jobId=${btoa(job.jobId)}`);
}
function nextVideo(job) {
uni.setStorageSync(`job-Info`, job);
navTo(`/packageA/pages/tiktok/tiktok`);
}
2025-05-13 11:10:38 +08:00
function getJobList(type = 'add') {
if (type === 'add' && pageState.page < pageState.maxPage) {
pageState.page += 1;
}
if (type === 'refresh') {
pageState.page = 1;
pageState.maxPage = 2;
}
let params = {
current: pageState.page,
pageSize: pageState.pageSize,
...pageState.search,
jobTitle: searchValue.value,
};
2025-08-20 13:38:47 +08:00
$api.createRequest('/app/job/list', params, 'GET', true).then((resData) => {
2025-05-13 11:10:38 +08:00
const { rows, total } = resData;
if (type === 'add') {
const str = pageState.pageSize * (pageState.page - 1);
2025-06-26 08:56:42 +08:00
const end = listCom.value.length;
2025-05-13 11:10:38 +08:00
const reslist = rows;
2025-06-26 08:56:42 +08:00
listCom.value.splice(str, end, ...reslist);
2025-05-13 11:10:38 +08:00
} else {
2025-06-26 08:56:42 +08:00
listCom.value = rows;
2025-05-13 11:10:38 +08:00
}
pageState.total = resData.total;
pageState.maxPage = Math.ceil(pageState.total / pageState.pageSize);
if (rows.length < pageState.pageSize) {
// loadmoreRef.value?.change('noMore');
} else {
// loadmoreRef.value?.change('more');
}
});
}
2025-06-26 08:56:42 +08:00
function dataToImg(data) {
return data.map((item) => ({
...item,
// image: item.cover,
image: img,
hide: true,
}));
}
2025-05-13 11:10:38 +08:00
</script>
<style lang="stylus" scoped>
.cards-box{
padding: 0 28rpx 28rpx 28rpx
}
.Detailscroll-view{
flex: 1
overflow: hidden
2025-06-26 08:56:42 +08:00
2025-05-13 11:10:38 +08:00
}
.container{
display: flex
flex-direction: column
background: #F4f4f4
height: calc(100vh - var(--window-top) - var(--status-bar-height) - var(--window-bottom));
2025-06-26 08:56:42 +08:00
.view-top{
display: flex;
justify-content: space-around
background: #FFFFFF;
.top-item{
padding: 6rpx 0 18rpx 0
}
.active{
color: #256BFA;
font-weight: 500;
position: relative;
}
.active::after{
position: absolute;
content: ''
left: calc(50% - 12rpx)
bottom: 10rpx
width: 24rpx
height: 6rpx
background: #256BFA
}
}
2025-05-13 11:10:38 +08:00
.main-content{
background: #FFFFFF
height: 100%
.content-top{
padding: 28rpx
display: flex
justify-content: space-between
align-items: center
.top-left{
font-weight: 600;
font-size: 36rpx;
color: #000000;
line-height: 42rpx;
}
}
.content-history{
padding: 0 28rpx;
display: flex
flex-wrap: wrap
.history-tag{
margin-right: 40rpx
margin-bottom: 20rpx
white-space: nowrap
font-weight: 400;
font-size: 28rpx;
color: #333333;
background: #F5F5F5;
border-radius: 12rpx 12rpx 12rpx 12rpx;
width: fit-content;
padding: 12rpx 20rpx
}
}
}
.top {
display: flex;
align-items: center;
justify-content: space-between
background-color: #fff;
padding: 20rpx 20rpx;
position: sticky;
top: 0
.btnback{
width: 60rpx;
height: 60rpx;
}
.search-box{
flex: 1;
padding: 0 24rpx 0 6rpx;
position: relative
.inputed {
padding-left: 30rpx
width: 100%;
background: #F8F8F8;
font-size: 28rpx;
font-family: PingFang SC;
font-weight: 400;
line-height: 36rpx;
color: #666666;
padding: 0 30rpx 0 80rpx;
box-sizing: border-box;
height: 80rpx;
background: #F5F5F5;
border-radius: 75rpx 75rpx 75rpx 75rpx;
}
.iconsearch{
position: absolute
top: 50%
left: 36rpx
transform: translate(0, -50%)
}
}
.search-btn {
padding-right: 18rpx;
text-align: center;
height: 64rpx;
line-height: 64rpx;
font-size: 32rpx;
font-weight: 500;
color: #256BFA;
}
}
}
2025-06-26 08:56:42 +08:00
.slot-item
// background: #f4f4f4;
background: #FFFFFF;
.job-info{
padding: 10rpx 24rpx 24rpx 24rpx
}
.job-image{
width: 100%;
height: 280rpx;
position: relative;
.cover-image{
width: 100%;
height: 100%;
overflow: hidden;
display: flex;
justify-content: center;
align-items: center;
}
.cover-triangle{
position: absolute;
right: 20rpx;
top: 20rpx
width: 36rpx
height: 36rpx
border-radius: 50%
background: rgba(0,0,0,0.3)
}
.cover-triangle::after {
content: '';
position: absolute;
top: 50%;
left: 50%;
transform: translate(-40%, -50%) rotate(90deg);
width: 0;
height: 0;
border-left: 8rpx solid transparent;
border-right: 8rpx solid transparent;
border-bottom: 12rpx solid #fff;
}
}
.salary
color: #4C6EFB;
font-size: 28rpx
display: flex
align-items: flex-start
justify-content: space-between
.flame
margin-top: 4rpx
margin-right: 4rpx
width: 24rpx
height: 31rpx
.title
font-weight: 500;
font-size: 32rpx;
color: #333333;
margin-top: 6rpx;
white-space: pre-wrap
.desc
font-weight: 400;
font-size: 24rpx;
color: #6C7282;
margin-top: 6rpx;
2025-05-13 11:10:38 +08:00
</style>