优化搜索操作

master
hequan_waynaqua 4 years ago
parent 58d069d798
commit 565b4d68be

@ -50,6 +50,8 @@ export default {
isHot: false,
isPrice: false,
isSales: false,
filterNew: false,
filterHot: false,
loading: false,
finished: false,
isSkeletonShow: true
@ -80,7 +82,9 @@ export default {
isNew: this.isNew,
isHot: this.isHot,
isPrice: this.isPrice,
isSales: this.isSales
isSales: this.isSales,
filterNew: this.filterNew,
filterHot: this.filterHot
}).then((res) => {
const data = res.map.goods
this.list = [...this.list, ...data]
@ -102,6 +106,7 @@ export default {
},
changeGoods(val) {
this.reset()
//
if (val['search'] === 'isNew') {
this.isNew = true
} else if (val['search'] === 'isHot') {
@ -115,6 +120,17 @@ export default {
this.isPrice = false
this.orderBy = ''
}
//
if (val['search'] === 'filterNew') {
this.filterNew = true
} else if (val['search'] === 'notFilterNew') {
this.filterNew = false
}
if (val['search'] === 'filterHot') {
this.filterHot = true
} else if (val['search'] === 'notFilterHot') {
this.filterHot = false
}
getSearchList({
pageSize: this.pageSize,
@ -124,7 +140,9 @@ export default {
isHot: this.isHot,
isPrice: this.isPrice,
isSales: this.isSales,
orderBy: this.orderBy
orderBy: this.orderBy,
filterNew: this.filterNew,
filterHot: this.filterHot
}).then((res) => {
const data = res.map.goods
this.list = [...data]

@ -1,6 +1,6 @@
<template>
<div class="search-filter">
<van-dropdown-menu style="flex:1.2">
<van-dropdown-menu style="flex:1">
<van-dropdown-item v-model="value1" :options="option1" @change="change1" />
<!-- <van-dropdown-item v-model="value2" :options="option2" />
<van-dropdown-item v-model="value3" :options="option3" /> -->
@ -16,12 +16,12 @@
<van-dropdown-item ref="item" title="筛选">
<van-cell center title="新品">
<template #right-icon>
<van-switch v-model="switch1" size="24" />
<van-switch v-model="switch1" size="24" @change="filterNew" />
</template>
</van-cell>
<van-cell center title="热品">
<template #right-icon>
<van-switch v-model="switch2" size="24" />
<van-switch v-model="switch2" size="24" @change="filterHot" />
</template>
</van-cell>
</van-dropdown-item>
@ -33,12 +33,12 @@
export default {
data() {
return {
value1: '',
value1: 'isHot',
switch1: false,
switch2: false,
option1: [
{ text: '综合推荐', value: '' },
{ text: '评论数高低', value: 'commentSort' }
{ text: '综合推荐', value: 'isHot' }
// { text: '', value: '' }
// { text: '', value: 'isNew' },
// { text: '', value: 'isHot' }
],
@ -72,8 +72,19 @@ export default {
chageSales() {
this.$emit('changeGoods', { search: 'isSales' })
},
onConfirm() {
filterNew(val) {
if (val) {
this.$emit('changeGoods', { search: 'filterNew' })
} else {
this.$emit('changeGoods', { search: 'notFilterNew' })
}
},
filterHot(val) {
if (val) {
this.$emit('changeGoods', { search: 'filterHot' })
} else {
this.$emit('changeGoods', { search: 'notFilterHot' })
}
}
}

Loading…
Cancel
Save