You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
103 lines
2.1 KiB
103 lines
2.1 KiB
<!--
|
|
* @Author: ch
|
|
* @Date: 2022-03-23 16:37:30
|
|
* @LastEditors: ch
|
|
* @LastEditTime: 2022-05-05 10:45:51
|
|
* @Description: file content
|
|
-->
|
|
<template>
|
|
<view class="sort">
|
|
<view class="sort--item" :class="item.value == active.value && 'sort--item__active'"
|
|
v-for="item in sortData" :key="item.value" @click="change(item)">
|
|
<text class="sort--label">{{item.label}}</text>
|
|
<view v-if="item.sort">
|
|
<view class="sort--icon sort--icon__up" :class="{'sort--icon__active' : item.sort === 'asc' && item.value === active.value}"></view>
|
|
<view class="sort--icon sort--icon__down" :class="{'sort--icon__active' : item.sort === 'desc' && item.value === active.value}"></view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
<script>
|
|
export default {
|
|
data(){
|
|
return {
|
|
sortData : [
|
|
{
|
|
value : '',
|
|
label : '综合'
|
|
},
|
|
{
|
|
value : 'starting_price',
|
|
label : '价格',
|
|
sort : 'asc'
|
|
},
|
|
// {
|
|
// value : 'sales',
|
|
// label : '销量'
|
|
// },
|
|
{
|
|
value : 'create_time',
|
|
label : '上新'
|
|
}
|
|
],
|
|
active: {
|
|
value : '',
|
|
label : '综合'
|
|
}
|
|
}
|
|
},
|
|
methods:{
|
|
change(item){
|
|
if(item.sort){
|
|
item.sort === 'asc' ? item.sort = 'desc' : item.sort = 'asc';
|
|
}
|
|
if(item.value + item.sort === this.active.value + this.active.sort){
|
|
return false;
|
|
}
|
|
this.active = {...item};
|
|
this.$emit('change',this.active)
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
<style lang="scss" scoped>
|
|
.sort{
|
|
height: 88rpx;
|
|
padding: 0 40rpx;
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
background: $color-grey0;
|
|
&--item{
|
|
display: flex;
|
|
align-items: center;
|
|
color: $color-grey5;
|
|
&__active text{
|
|
color: $color-yellow4;
|
|
}
|
|
}
|
|
&--label{
|
|
font-size: $font-size-base;
|
|
margin-right: 16rpx;
|
|
}
|
|
&--icon{
|
|
border: 8rpx solid $color-grey4;
|
|
border-left-color: transparent;
|
|
border-right-color: transparent;
|
|
&__up{
|
|
border-top-color: transparent;
|
|
margin-bottom: 6rpx;
|
|
|
|
&.sort--icon__active{
|
|
border-bottom-color: $color-yellow2;
|
|
}
|
|
}
|
|
&__down{
|
|
border-bottom-color: transparent;
|
|
&.sort--icon__active{
|
|
border-top-color: $color-yellow2;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</style> |