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

255 lines
5.8 KiB
Vue
Raw Normal View History

2024-02-02 14:44:30 +08:00
<template>
2024-02-17 18:22:11 +08:00
<view class="mainWrapper">
2024-02-02 14:44:30 +08:00
<view class="headSearch">
<view class="search-view">
<view class="search-item">
<image src="../../static/img/search.svg" style="width: 32rpx;height: 32rpx;" mode=""></image>
2024-02-17 18:22:11 +08:00
<input type="text" confirm-type="搜索" v-model="keywords" @confirm="getList('search')"
placeholder="请输入任务名称或公司名称" />
2024-02-02 14:44:30 +08:00
</view>
<view class="close" @click="closeBack">
取消
</view>
</view>
</view>
2024-02-17 18:22:11 +08:00
<v-tabs :tabs="['推荐任务', '推荐服务', '推荐政策']" height="45px" v-model="activeTab" color="#999" activeColor="#000"
fontSize="30rpx" activeFontSize="31rpx" @change='changeTab' />
<block v-if="activeTab == 0">
<view v-if="companyList.length > 0">
<block v-for="(item, index) in companyList" :key="item.id">
<companyList :companyitem="item"></companyList>
</block>
</view>
<view v-else>
<image src="../../static/img/pic_notask.svg" mode="" class="nothing"></image>
<view class="nothingContnt">
暂无信息
</view>
</view>
</block>
<block v-if="activeTab == 1">
<view v-if="newList.length > 0">
<block v-for="(item, index) in newList" :key="index">
<companyList :companyitem="item"></companyList>
</block>
</view>
<view v-else>
<image src="../../static/img/pic_notask.svg" class="nothing" mode=""></image>
<view class="nothingContnt">暂无信息</view>
</view>
</block>
<block v-if="activeTab == 2">
<view v-if="recommendList.length > 0">
<block v-for="(item, index) in recommendList" :key="item.id">
<companyList :companyitem="item"></companyList>
</block>
</view>
<view v-else>
<image src="../../static/img/pic_notask.svg" mode="" class="nothing"></image>
<view class="nothingContnt">
完善技能获取精推荐
</view>
<!-- <view class="btn" @click="goResume">
完善技能
</view> -->
</view>
</block>
<!-- <view v-if="companyList.length > 0">
2024-02-02 14:44:30 +08:00
<block v-for="(item, index) in companyList" :key="item.id">
<companyList :companyitem="item"></companyList>
<view class="baddd"></view>
</block>
</view>
<view v-else>
<image src="../../static/img/pic_notask.svg" mode="" class="nothing"></image>
<view class="nothingContnt">
暂无任务信息
</view>
2024-02-17 18:22:11 +08:00
</view> -->
2024-02-02 14:44:30 +08:00
</view>
</template>
<script>
2024-02-17 18:22:11 +08:00
import { newMissionAll } from '@/api/mission.js';
2024-02-02 14:44:30 +08:00
import companyList from '@/components/companyList/companyList.vue';
2024-02-17 18:22:11 +08:00
import vTabs from '@/components/v-tabs/v-tabs.vue';
2024-02-02 14:44:30 +08:00
import testData from '@/common/textdata.js';
export default {
components: {
2024-02-17 18:22:11 +08:00
companyList,
vTabs,
2024-02-02 14:44:30 +08:00
},
data() {
return {
2024-02-17 18:22:11 +08:00
activeTab: 0,
2024-02-02 14:44:30 +08:00
companyList: [],
2024-02-17 18:22:11 +08:00
recommendList: [],
newList: [],
keywords: '',
page: {
current: 1,
size: 10,
total: 0
2024-02-02 14:44:30 +08:00
}
};
},
2024-02-17 18:22:11 +08:00
onLoad: function (option) {
this.keywords = option.keywords ? option.keywords : ''
2024-02-02 14:44:30 +08:00
},
2024-02-17 18:22:11 +08:00
onShow: function () {
2024-02-02 14:44:30 +08:00
this.getList('search');
},
/*页面滚动到底部*/
2024-02-17 18:22:11 +08:00
onReachBottom: function () {
2024-02-02 14:44:30 +08:00
this.upLoad()
},
methods: {
//最新任务;
2024-02-17 18:22:11 +08:00
getList: function (type) {
2024-02-02 14:44:30 +08:00
//改变搜索条件页码值变为1
2024-02-17 18:22:11 +08:00
if (type === 'search') {
2024-02-02 14:44:30 +08:00
this.page.current = 1;
};
2024-02-17 18:22:11 +08:00
// if (this.keywords) {
newMissionAll(this.page.current, this.page.size, this.keywords).then(res => {
if (this.page.current === 1) {
this.companyList = [];
}
this.page.current += 1;
this.page.total = res.data.data.total;
if (res.data.data && res.data.data.records.length) {
this.companyList = this.companyList.concat(res.data.data.records);
}
//搜索关键词高亮
// if (this.companyList.length) {
// this.companyList.forEach((item, index) => {
// item.missionTitle = this.getInf(item.missionTitle, this.keywords);
// });
// }
console.log(this.companyList, '----------');
})
// }
2024-02-02 14:44:30 +08:00
},
2024-02-17 18:22:11 +08:00
2024-02-02 14:44:30 +08:00
//上拉加载
2024-02-17 18:22:11 +08:00
upLoad: function () {
if (this.page.current <= Math.ceil(this.page.total / this.page.size)) {
2024-02-02 14:44:30 +08:00
this.getList();
2024-02-17 18:22:11 +08:00
} else {
2024-02-02 14:44:30 +08:00
uni.showToast({
icon: "none",
title: '已经是最后一页',
})
2024-02-17 18:22:11 +08:00
return
2024-02-02 14:44:30 +08:00
}
},
2024-02-17 18:22:11 +08:00
closeBack() {
2024-02-02 14:44:30 +08:00
uni.navigateBack({
2024-02-17 18:22:11 +08:00
delta: 1
2024-02-02 14:44:30 +08:00
})
},
/**
* 指定关键字高亮
* @param {*} str 字符串
* @param {*} key 关键字
*/
getInf(str, key) {
if (str && key) {
let replaceReg = new RegExp(key, 'g')// 匹配关键字正则
let replaceString = "<span style='color: #1b66ff;'>" + key + "</span>" // 高亮替换
return str.replace(replaceReg, replaceString);
}
2024-02-17 18:22:11 +08:00
},
changeTab: function (e) {
this.activeTab = e;
},
2024-02-02 14:44:30 +08:00
}
};
</script>
2024-02-17 18:22:11 +08:00
<style scoped>
.mainWrapper{
background-color: #f3f4f8;
min-height: 95vh;
}
.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: 10rpx 32rpx;
background: rgba(255, 255, 255, 1);
}
.headSearch .search-item {
display: flex;
width: 80%;
padding: 0 24rpx;
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;
}
2024-02-02 14:44:30 +08:00
</style>