搜索组件优化 排序逻辑优化

This commit is contained in:
BAKEYi 2026-05-28 13:13:45 +08:00
parent dda0f4d7d6
commit 1184d73a75
3 changed files with 17 additions and 15 deletions

View File

@ -109,7 +109,7 @@ export default {
selectedSecondIds: [], // ID
//
orderType: 1,
orderType: 0,
//
iconGreyUp: 'https://mrrplus.oss-cn-beijing.aliyuncs.com/photo/system/e00ab2ac-bccf-42d8-820c-65727327e279.png',

View File

@ -91,7 +91,7 @@ export default {
navHeight: 0,
//
orderType: 1, // 1:, 2:, 3:, 4: (1)
orderType: 0, // 1:, 2:, 3:, 4: (0)
linkType: '', // '':, 1:, 2:
filterVisible: false,

View File

@ -23,7 +23,7 @@
<view class="result-container">
<view class="sort-bar" v-if="['brand', 'skill', 'collection_brand', 'collection_course'].includes(searchType)">
<view class="sort-bar" v-if="hasSearched && ['brand', 'skill', 'collection_brand', 'collection_course'].includes(searchType)">
<view class="sort-item" @tap="toggleSort('time')">
<text class="sort-text" :class="{ active: orderType === 1 || orderType === 2 }">发布时间</text>
<view class="arrows">
@ -114,8 +114,8 @@ export default {
limit: 10,
hasMore: true,
// 1/2 3/4
orderType: 1,
// 0()1/23/4
orderType: 0,
//
iconGreyUp: 'https://mrrplus.oss-cn-beijing.aliyuncs.com/photo/system/e00ab2ac-bccf-42d8-820c-65727327e279.png',
@ -162,6 +162,7 @@ export default {
this.hasSearched = false;
this.page = 1;
this.hasMore = true;
this.orderType = 0; //
},
//
@ -172,7 +173,7 @@ export default {
this.orderType = this.orderType === 3 ? 4 : 3;
}
//
//
if (this.hasSearched) {
this.page = 1;
this.hasMore = true;
@ -184,6 +185,9 @@ export default {
if (!this.keyword.trim()) {
return uni.showToast({ title: '请输入搜索内容', icon: 'none' });
}
//
this.orderType = 0;
this.hasSearched = true;
this.page = 1;
this.hasMore = true;
@ -197,9 +201,11 @@ export default {
let apiUrl = '';
let params = { page: this.page, limit: this.limit };
//
// orderType !== 0 order_type
if (['brand', 'skill', 'collection_brand', 'collection_course'].includes(this.searchType)) {
params.order_type = this.orderType;
if (this.orderType !== 0) {
params.order_type = this.orderType;
}
}
switch (this.searchType) {
@ -231,7 +237,6 @@ export default {
if (res.code === 200 && res.data) {
const list = res.data.list || [];
// count total
const totalCount = res.data.count || 0;
let formattedList = list;
@ -267,7 +272,6 @@ export default {
this.resultList = [...this.resultList, ...formattedList];
}
// count
this.hasMore = this.resultList.length < totalCount;
} else {
@ -300,7 +304,7 @@ export default {
<style lang="scss" scoped>
.search-page {
min-height: 100vh;
background: #F5F5F5;
background: #fff;
}
.search-header {
@ -308,7 +312,7 @@ export default {
top: 0;
left: 0;
right: 0;
background-color: #Fff;
background-color: #fff;
z-index: 999;
.header-content {
@ -364,11 +368,10 @@ export default {
padding: 24rpx;
}
/* ================= 排序栏新增样式 ================= */
.sort-bar {
display: flex;
align-items: center;
padding: 10rpx 0 24rpx; /* 根据结果页面适当微调顶部间距 */
padding: 10rpx 0 24rpx;
gap: 60rpx;
.sort-item {
@ -402,7 +405,6 @@ export default {
}
}
}
/* ============================================== */
.loading-tips {
text-align: center;