Files
jobslink-user-clent/pages/seach/seach.vue

373 lines
12 KiB
Vue
Raw Normal View History

2024-04-14 14:32:17 +08:00
<template>
<view class="mainWrapper">
2024-10-09 10:14:51 +08:00
<view class="headSearch">
2024-04-14 14:32:17 +08:00
<view class="search-view">
<view class="search-item">
<image src="../../static/img/search.svg" style="width: 32rpx;height: 32rpx;" mode=""></image>
2024-10-09 10:14:51 +08:00
<input type="text" confirm-type="搜索" v-model="keywords" @confirm="getList"
2024-04-23 22:51:27 +08:00
placeholder="搜零工岗位/搜全职岗位/搜政策" />
2024-10-09 10:14:51 +08:00
<view @click="getList"
2024-04-14 14:32:17 +08:00
style="width: 80rpx;height: 50rpx;color:#fff;background-color: #0091ff;font-size:24rpx;text-align: center;line-height: 50rpx;border-radius: 25rpx;;">
搜索</view>
</view>
</view>
</view>
2024-10-09 10:14:51 +08:00
<view class="search-history">
2024-04-14 14:32:17 +08:00
<view class="title">搜索记录</view>
<view class="clear" @click="clearKeyWords">
<image src="../../static/img/delete.png" style="width: 24rpx;height: 24rpx;" mode=""></image>
<view style="margin-left: 5rpx;">清空</view>
</view>
<view class="wrapper" v-if="searchHistoryList.length > 0">
<view class="item" v-for="(item, index) in searchHistoryList" @click="keyWordsClick(item.keywords)">
{{ item.keywords }}
</view>
</view>
<view v-else class="empty">暂无历史记录</view>
2024-10-09 10:14:51 +08:00
<v-tabs :tabs="tabList" height="45px" v-model="activeTab" color="#999" activeColor="#000" fontSize="30rpx"
activeFontSize="31rpx" @change='changeTab' />
2024-04-14 14:32:17 +08:00
2024-10-09 10:14:51 +08:00
</view>
<block v-if="activeTab === 0">
<view v-if="companyList.length ">
2024-04-14 14:32:17 +08:00
<block v-for="(item, index) in companyList" :key="item.id">
2024-10-09 10:14:51 +08:00
<companyList :companyitem="item" :location="userLocation"></companyList>
2024-04-14 14:32:17 +08:00
</block>
</view>
<view v-else>
<image src="../../static/img/pic_notask.svg" mode="" class="nothing"></image>
<view class="nothingContnt">
暂无信息
</view>
</view>
</block>
2024-10-09 10:14:51 +08:00
<block v-if="activeTab === 1">
<view v-if="newList.length">
2024-05-08 11:26:38 +08:00
<block v-for="(item, index) in newList" :key="item.id">
2024-10-09 10:14:51 +08:00
<workList :companyitem="item" :near="activeTab === 0" :location="userLocation"></workList>
2024-04-14 14:32:17 +08:00
</block>
</view>
<view v-else>
<image src="../../static/img/pic_notask.svg" class="nothing" mode=""></image>
<view class="nothingContnt">暂无信息</view>
</view>
</block>
2024-10-09 10:14:51 +08:00
<block v-if="activeTab == 2">
<view v-if="recommendList.length">
2024-05-08 11:26:38 +08:00
<!-- <block v-for="(item, index) in recommendList" :key="item.id">
2024-04-14 14:32:17 +08:00
<companyList :companyitem="item"></companyList>
2024-05-08 11:26:38 +08:00
</block> -->
<view v-for="(item, index) in recommendList" :key="index"
style="width: 90%;height: 100rpx;background-color: #fff;border-radius: 10rpx;margin:20rpx 5% 20rpx 5%;display: flex;align-items: center"
@click="goPolicyInfo(item.id)">
<image :src="item.headPic" style="width: 60rpx;height: 60rpx;margin: 0 20rpx;"></image>
<view style="font-size: 26rpx;">{{ item.articleTitle }}</view>
</view>
2024-04-14 14:32:17 +08:00
</view>
2024-05-08 11:26:38 +08:00
2024-04-14 14:32:17 +08:00
<view v-else>
<image src="../../static/img/pic_notask.svg" mode="" class="nothing"></image>
<view class="nothingContnt">
2024-10-09 10:14:51 +08:00
暂无信息
2024-04-14 14:32:17 +08:00
</view>
<!-- <view class="btn" @click="goResume">
2024-10-09 10:14:51 +08:00
完善技能
</view> -->
2024-04-14 14:32:17 +08:00
</view>
</block>
2024-10-09 10:14:51 +08:00
<block v-if="activeTab == -1">
<view>
<image src="../../static/img/pic_notask.svg" mode="" class="nothing"></image>
<view class="nothingContnt">
没有更多数据
</view>
</view>
</block>
2024-04-14 14:32:17 +08:00
</view>
</template>
<script>
2024-10-09 10:14:51 +08:00
import {
cloneDeep
} from 'lodash';
2024-04-14 14:32:17 +08:00
import {
newMissionAll,
getSearchKeyWordsList,
clearSearchKeyWords,
2024-05-08 11:26:38 +08:00
getListByKeyWords,
nearMission,
2024-10-09 10:14:51 +08:00
getPolicyContentList,
userWorkSearchListAll
2024-04-14 14:32:17 +08:00
} from '@/api/mission.js';
2024-10-09 10:14:51 +08:00
import {
mapGetters
} from 'vuex'
2024-04-14 14:32:17 +08:00
import companyList from '@/components/companyList/companyList.vue';
2024-05-08 11:26:38 +08:00
import workList from '@/components/companyList/workList.vue'
2024-10-09 10:14:51 +08:00
const titleStatus = {
'mission': {
title: '零工岗位',
val: 0,
},
'work': {
title: '全职岗位',
val: 1,
},
'policy': {
title: '政策',
val: 2,
},
}
2024-04-14 14:32:17 +08:00
export default {
components: {
companyList,
2024-05-08 11:26:38 +08:00
workList
2024-04-14 14:32:17 +08:00
},
data() {
return {
activeTab: 0,
keywords: '',
searchHistoryList: [],
2024-10-09 10:14:51 +08:00
companyList: [],
newList: [],
recommendList: [],
tabList: ['零工岗位', '全职岗位', '政策']
}
2024-04-14 14:32:17 +08:00
},
2024-10-09 10:14:51 +08:00
computed: {
...mapGetters(['userLocation']),
2024-04-14 14:32:17 +08:00
},
onShow: function() {
this.getKeyWordsList()
},
methods: {
2024-10-09 10:14:51 +08:00
goPolicyInfo(data) {
if (data) {
uni.navigateTo({
url: `/pages/user/policyContent?id=${data}`
})
}
2024-04-14 14:32:17 +08:00
},
// 获取搜索历史记录
getKeyWordsList() {
getSearchKeyWordsList().then(res => {
let response = res.data
if (response.code == 200) {
this.searchHistoryList = response.data
}
})
},
keyWordsClick(keyWords) {
// console.log(keyWords)
this.searchResultShow = true;
this.keywords = keyWords;
},
2024-10-09 10:14:51 +08:00
// 清空搜索历史
clearKeyWords() {
clearSearchKeyWords().then(res => {
if (res.data.code == 200) {
this.getKeyWordsList()
2024-04-14 14:32:17 +08:00
}
2024-05-08 11:26:38 +08:00
})
},
2024-10-09 10:14:51 +08:00
changeTab: function(e) {
this.activeTab = e;
// const tab = cloneDeep(this.tabList[e])
// Object.keys(titleStatus).map((key) => {
// if (titleStatus[key].title === tab) {
// this.activeTab = titleStatus[key].val;
// }
// })
2024-04-14 14:32:17 +08:00
},
2024-10-09 10:14:51 +08:00
async getList() {
const params = {
keywords: this.keywords
2024-05-08 11:26:38 +08:00
}
2024-10-09 10:14:51 +08:00
let resData = await userWorkSearchListAll(params)
if (resData.data.code === 200) {
const {
mission,
policy,
work
} = resData.data.data
const tabVal = []
Object.keys(titleStatus).map((key) => {
if (resData.data.data[key].length) {
tabVal.push(titleStatus[key].title)
}
2024-05-08 11:26:38 +08:00
})
2024-10-09 10:14:51 +08:00
if (tabVal.length) {
let count = 0
Object.keys(titleStatus).map((key) => {
if (!count && titleStatus[key].title === tabVal[0]) {
this.activeTab = titleStatus[key].val;
count++
}
})
2024-05-08 11:26:38 +08:00
}
2024-10-09 10:14:51 +08:00
this.companyList = mission
this.recommendList = policy
this.newList = work
2024-04-14 14:32:17 +08:00
}
}
}
2024-10-09 10:14:51 +08:00
}
2024-04-14 14:32:17 +08:00
</script>
<style scoped>
.mainWrapper {
background-color: #f3f4f8;
2024-10-09 10:14:51 +08:00
min-height: calc(100vh - var(--window-top) - var(--status-bar-height) - var(--window-bottom));
2024-04-14 14:32:17 +08:00
}
.baddd {
background-color: #f6f6f6;
height: 20rpx;
}
.close {
position: absolute;
right: 24rpx;
top: 6rpx;
height: 60rpx;
padding: 5rpx 0;
line-height: 60rpx;
font-family: PingFangSC-Regular;
font-size: 32rpx;
color: #333333;
}
.headSearch .search-view {
border-bottom: 1rpx solid #dddddd;
padding: 14rpx 32rpx;
background: rgba(255, 255, 255, 1);
}
.headSearch .search-item {
display: flex;
padding: 0 10rpx;
height: 60rpx;
line-height: 60rpx;
background: rgba(249, 249, 249, 1);
border-radius: 200px;
align-items: center;
border: 1px solid #0091ff;
}
.headSearch .search-item input {
padding: 0 24rpx;
height: 80rpx;
font-weight: 400;
flex: 1;
text-align: start;
font-size: 28rpx;
font-family: PingFang-SC-Bold, PingFang-SC;
color: rgba(51, 51, 51, 1);
}
.headSearch .search-item .placeholderClass {
color: #CCCCCC;
}
.headSearch .search-item image {
height: 32rpx;
width: 32rpx;
}
.nothing {
width: 400rpx;
height: 200rpx;
display: block;
margin: 0 auto;
margin-top: 50%;
}
.nothingContnt {
font-family: PingFangSC-Regular;
font-size: 28rpx;
color: #333333;
margin-top: 30rpx;
text-align: center;
}
.search-history {
background-color: #fff;
padding: 10rpx 40rpx;
position: relative;
}
.search-history .title {
font-size: 28rpx;
font-weight: bold;
}
.search-history .clear {
position: absolute;
right: 40rpx;
top: 10rpx;
font-size: 24rpx;
display: flex;
align-items: center;
color: #707070;
}
.search-history .empty {
font-size: 24rpx;
text-align: center;
color: #707070;
}
.search-history .wrapper {
display: flex;
flex-wrap: wrap;
margin-top: 10rpx;
}
.search-history .wrapper .item {
font-size: 24rpx;
background-color: #f6f6f6;
padding: 8rpx 12rpx;
border-radius: 20rpx;
margin-right: 10rpx;
2024-10-09 10:14:51 +08:00
position: relative;
2024-04-14 14:32:17 +08:00
}
.search-result {
padding: 20rpx 30rpx;
background-color: #fff;
height: 100vh;
}
.search-result .title {
font-size: 26rpx;
font-weight: bold;
border-bottom: 1rpx solid #ddd;
height: 60rpx;
line-height: 60rpx;
}
.search-result .search-item {
display: flex;
align-items: center;
font-size: 26rpx;
border-bottom: 1rpx solid #ddd;
height: 80rpx;
line-height: 80rpx;
}
.search-result .search-item .type {
font-size: 20rpx;
color: #707070;
background-color: #dddddd;
border-radius: 15rpx;
height: 30rpx;
line-height: 30rpx;
padding: 0 20rpx;
}
</style>