|
|
@@ -27,11 +27,10 @@
|
|
|
>
|
|
|
<van-tab
|
|
|
:title="item.label"
|
|
|
- :name="
|
|
|
- item.type === 'select' ? (sort === item.value[0] ? item.value[1] : item.value[0]) : item.value
|
|
|
- "
|
|
|
- :title-class="item.type === 'select' && sort === item.value[0] ? '' : 'asc'"
|
|
|
+ :name="item.value"
|
|
|
+ :title-class="item.type === 'select' && sortDes ? sortDes : ''"
|
|
|
:key="index"
|
|
|
+ :lazy-render="false"
|
|
|
v-for="(item, index) in selectOptions"
|
|
|
>
|
|
|
<template v-if="item.type === 'select'" #title>
|
|
|
@@ -105,6 +104,7 @@ export default {
|
|
|
url: '/collection/all',
|
|
|
scrollTop: 0,
|
|
|
sort: 'id,desc',
|
|
|
+ sortDes: '',
|
|
|
title: '',
|
|
|
selectOptions: [
|
|
|
{
|
|
|
@@ -121,7 +121,7 @@ export default {
|
|
|
},
|
|
|
{
|
|
|
label: '价格',
|
|
|
- value: ['price,desc', 'price,asc'],
|
|
|
+ value: 'price',
|
|
|
type: 'select'
|
|
|
}
|
|
|
],
|
|
|
@@ -148,12 +148,19 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
- changeTab() {
|
|
|
+ changeTab(info) {
|
|
|
this.$nextTick(() => {
|
|
|
+ if (info.name === 'price') {
|
|
|
+ this.sortDes = this.sortDes == 'desc' ? 'asc' : 'desc';
|
|
|
+ }
|
|
|
this.getData(true);
|
|
|
});
|
|
|
},
|
|
|
beforeData() {
|
|
|
+ let sort = this.sort;
|
|
|
+ if (sort == 'price') {
|
|
|
+ sort = 'price,' + this.sortDes;
|
|
|
+ }
|
|
|
return {
|
|
|
query: {
|
|
|
onShelf: true,
|
|
|
@@ -164,7 +171,7 @@ export default {
|
|
|
salable: this.salable || ''
|
|
|
},
|
|
|
search: this.search,
|
|
|
- sort: this.sort === 'id,desc' ? this.sortOptions[this.title] || this.sort : this.sort
|
|
|
+ sort: this.sort === 'id,desc' ? this.sortOptions[this.title] || sort : sort
|
|
|
};
|
|
|
}
|
|
|
},
|
|
|
@@ -172,9 +179,9 @@ export default {
|
|
|
this.$nextTick(() => {
|
|
|
this.changeScroll(this.scrollTop);
|
|
|
|
|
|
- setTimeout(() => {
|
|
|
- this.sort = this.beforeSort;
|
|
|
- }, 1000);
|
|
|
+ // setTimeout(() => {
|
|
|
+ // this.sort = this.beforeSort;
|
|
|
+ // }, 1000);
|
|
|
});
|
|
|
},
|
|
|
beforeRouteLeave(to, from, next) {
|