界面调整

This commit is contained in:
zxy
2024-02-19 09:08:07 +08:00
parent cf3f4597a1
commit 41ae03e35d
11 changed files with 469 additions and 33 deletions

View File

@@ -4,19 +4,44 @@
<view class="search-view">
<view class="search-item">
<image src="../../static/img/search.svg" style="width: 32rpx;height: 32rpx;" mode=""></image>
<input type="text" confirm-type="搜索" v-model="keywords" @confirm="getList('search')"
<input type="text" confirm-type="搜索" v-model="keywords" @confirm="getNewList('search')"
placeholder="请输入任务名称或公司名称" />
<view 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 class="close" @click="closeBack">
<!-- <view class="close" @click="closeBack">
取消
</view>
</view> -->
</view>
</view>
<v-tabs :tabs="['推荐任务', '推荐服务', '推荐政策']" height="45px" v-model="activeTab" color="#999" activeColor="#000"
<view v-show="searchResultShow" class="search-result">
<view class="title">搜索结果</view>
<view v-for="(item, index) in searchResultList" class="search-item" @click="toDetail(item)">
<image src="../../static/img/search.svg" style="width: 32rpx;height: 32rpx;margin-right: 10rpx;" mode=""></image>
<view style="flex:1">{{ item.name }}</view>
<view class="type" v-if="item.type == 0">任务</view>
<view class="type" v-else-if="item.type == 1">岗位</view>
<view class="type" v-else-if="item.type == 2">政策</view>
</view>
<view v-if="searchResultList.length == 0" style="text-align: center;font-size: 26rpx;margin-top: 20rpx;">暂无数据</view>
</view>
<view v-show="!searchResultShow" class="search-history">
<view class="title">搜索记录</view>
<view class="clear" @click="clearKeyWords">
<image src="../../static/img/delete.png" style="width: 20rpx;height: 20rpx;" 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">
{{ item.keywords }}
</view>
</view>
<view v-else class="empty">暂无历史记录</view>
</view>
<v-tabs v-show="!searchResultShow" :tabs="['推荐任务', '推荐服务', '推荐政策']" height="45px" v-model="activeTab" color="#999" activeColor="#000"
fontSize="30rpx" activeFontSize="31rpx" @change='changeTab' />
<block v-if="activeTab == 0">
<block v-if="(activeTab == 0)&&!searchResultShow">
<view v-if="companyList.length > 0">
<block v-for="(item, index) in companyList" :key="item.id">
<companyList :companyitem="item"></companyList>
@@ -29,7 +54,7 @@
</view>
</view>
</block>
<block v-if="activeTab == 1">
<block v-if="(activeTab == 1)&&!searchResultShow">
<view v-if="newList.length > 0">
<block v-for="(item, index) in newList" :key="index">
<companyList :companyitem="item"></companyList>
@@ -43,7 +68,7 @@
<block v-if="activeTab == 2">
<block v-if="(activeTab == 2)&&!searchResultShow">
<view v-if="recommendList.length > 0">
<block v-for="(item, index) in recommendList" :key="item.id">
<companyList :companyitem="item"></companyList>
@@ -77,7 +102,7 @@
</template>
<script>
import { newMissionAll } from '@/api/mission.js';
import { newMissionAll, getSearchKeyWordsList, clearSearchKeyWords, getListByKeyWords } from '@/api/mission.js';
import companyList from '@/components/companyList/companyList.vue';
import vTabs from '@/components/v-tabs/v-tabs.vue';
import testData from '@/common/textdata.js';
@@ -97,7 +122,10 @@ export default {
current: 1,
size: 10,
total: 0
}
},
searchHistoryList: [],
searchResultShow: false,
searchResultList: []
};
},
onLoad: function (option) {
@@ -105,12 +133,33 @@ export default {
},
onShow: function () {
this.getList('search');
this.getKeyWordsList()
},
/*页面滚动到底部*/
onReachBottom: function () {
this.upLoad()
},
methods: {
// 新面板搜索
getNewList() {
getListByKeyWords(this.keywords).then(res => {
this.searchResultShow = true
this.searchResultList = res.data.data
// this.searchResultList.forEach((item, index) => {
// item.name = this.getInf(item.name, this.keywords);
// })
})
},
// 获取搜索历史记录
getKeyWordsList() {
getSearchKeyWordsList().then(res => {
let response = res.data
if(response.code == 200) {
this.searchHistoryList = response.data
}
})
},
//最新任务;
getList: function (type) {
//改变搜索条件页码值变为1
@@ -168,10 +217,25 @@ export default {
return str.replace(replaceReg, replaceString);
}
},
toDetail(item) {
const no = item.id
uni.navigateTo({
url: `/pages/projectInfo/projectInfo?missionNo=${encodeURIComponent(no)}&isCan=1`
})
},
changeTab: function (e) {
this.activeTab = e;
},
// 清空搜索历史
clearKeyWords() {
clearSearchKeyWords().then(res => {
if(res.data.code == 200) {
this.getKeyWordsList()
}
})
}
}
};
</script>
@@ -206,7 +270,7 @@ export default {
.headSearch .search-item {
display: flex;
width: 80%;
width: 90%;
padding: 0 24rpx;
height: 60rpx;
line-height: 60rpx;
@@ -251,4 +315,66 @@ export default {
margin-top: 30rpx;
text-align: center;
}
.search-history {
background-color: #fff;
padding: 10rpx 20rpx;
position: relative;
}
.search-history .title {
font-size: 28rpx;
font-weight: bold;
}
.search-history .clear {
position: absolute;
right: 20rpx;
top: 10rpx;
font-size: 20rpx;
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;
}
.search-history .wrapper .item {
font-size: 20rpx;
background-color: #f6f6f6;
padding: 10rpx;
border-radius: 20rpx;
margin-right: 10rpx;
}
.search-result {
padding: 20rpx 30rpx;
}
.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>