|
@@ -11,19 +11,66 @@ export default defineComponent({
|
|
|
return {
|
|
|
typeId: 0,
|
|
|
filterActive: 0,
|
|
|
- filterListShow: false
|
|
|
+ filterListShow: false,
|
|
|
+ productCategory: {
|
|
|
+ name: '',
|
|
|
+ id: 0
|
|
|
+ },
|
|
|
+ productAttributeCategory: {
|
|
|
+ name: '',
|
|
|
+ id: 0
|
|
|
+ },
|
|
|
+ brand: {
|
|
|
+ name: '',
|
|
|
+ id: 0
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
onFilter(n: number) {
|
|
|
+ if (this.filterActive === 3 && n === 3) n = 4
|
|
|
+ if (this.filterActive === 4 && n === 3) n = 3
|
|
|
+ if (this.filterActive === n) return
|
|
|
this.filterActive = n
|
|
|
+ this.onSearch()
|
|
|
},
|
|
|
- onFilterClick(params: any) {
|
|
|
- console.log(params)
|
|
|
+ setFilter({ productCategory, productAttributeCategory, brand }) {
|
|
|
+ this.productCategory = productCategory
|
|
|
+ ? productCategory
|
|
|
+ : { id: 0, name: '' }
|
|
|
+ this.productAttributeCategory = productAttributeCategory
|
|
|
+ ? productAttributeCategory
|
|
|
+ : { id: 0, name: '' }
|
|
|
+ this.brand = brand ? brand : { id: 0, name: '' }
|
|
|
+ // console.log(
|
|
|
+ // this.productCategory,
|
|
|
+ // this.productAttributeCategory,
|
|
|
+ // this.brand
|
|
|
+ // )
|
|
|
+ this.onSearch()
|
|
|
+ this.filterListShow = false
|
|
|
+ },
|
|
|
+
|
|
|
+ onClearTag(key: string) {
|
|
|
+ this[key] = { id: 0, name: '' }
|
|
|
+ let goodsFilter = this.$refs.goodsFilter as any
|
|
|
+ if (key === 'productCategory') {
|
|
|
+ goodsFilter.setParams('productCategorySmallVoList')
|
|
|
+ } else if (key === 'productAttributeCategory') {
|
|
|
+ goodsFilter.setParams('productAttributeCategoryList')
|
|
|
+ } else {
|
|
|
+ goodsFilter.setParams('brandList')
|
|
|
+ }
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.onSearch()
|
|
|
+ })
|
|
|
+ },
|
|
|
+ onSearch() {
|
|
|
+ let tabList = this.$refs.tabList as any
|
|
|
+ tabList.onSearch()
|
|
|
}
|
|
|
},
|
|
|
render() {
|
|
|
- const typeId = this.typeId
|
|
|
return (
|
|
|
<div>
|
|
|
<Sticky>
|
|
@@ -31,21 +78,39 @@ export default defineComponent({
|
|
|
<Row class={styles['filter-top']} align="center">
|
|
|
<Col
|
|
|
span={6}
|
|
|
- class={this.filterActive == 0 ? styles.active : ''}
|
|
|
+ class={this.filterActive === 0 ? styles.active : ''}
|
|
|
onClick={() => this.onFilter(0)}
|
|
|
>
|
|
|
综合排序
|
|
|
</Col>
|
|
|
<Col
|
|
|
span={6}
|
|
|
- class={this.filterActive == 1 ? styles.active : ''}
|
|
|
- onClick={() => this.onFilter(1)}
|
|
|
+ class={
|
|
|
+ this.filterActive === 3 || this.filterActive === 4
|
|
|
+ ? styles.active
|
|
|
+ : ''
|
|
|
+ }
|
|
|
+ onClick={() => this.onFilter(3)}
|
|
|
>
|
|
|
价格
|
|
|
+ <div class={styles.filterSort}>
|
|
|
+ <Icon
|
|
|
+ class={this.filterActive === 3 ? styles['icon-active'] : ''}
|
|
|
+ style={{ transform: 'rotate(-90deg)' }}
|
|
|
+ name="play"
|
|
|
+ size={4}
|
|
|
+ />
|
|
|
+ <Icon
|
|
|
+ class={this.filterActive === 4 ? styles['icon-active'] : ''}
|
|
|
+ style={{ transform: 'rotate(90deg)', marginTop: '-5px' }}
|
|
|
+ name="play"
|
|
|
+ size={4}
|
|
|
+ />
|
|
|
+ </div>
|
|
|
</Col>
|
|
|
<Col
|
|
|
span={6}
|
|
|
- class={this.filterActive == 2 ? styles.active : ''}
|
|
|
+ class={this.filterActive === 2 ? styles.active : ''}
|
|
|
onClick={() => this.onFilter(2)}
|
|
|
>
|
|
|
销量
|
|
@@ -62,14 +127,48 @@ export default defineComponent({
|
|
|
</Sticky>
|
|
|
|
|
|
<div class={styles.filterTagWrap}>
|
|
|
- {[1, 2, 3].map(item => (
|
|
|
- <Tag class={styles.filterTag} closeable={true}>
|
|
|
- 铜管乐器{item}
|
|
|
+ {this.productCategory.id ? (
|
|
|
+ <Tag
|
|
|
+ class={styles.filterTag}
|
|
|
+ closeable={true}
|
|
|
+ onClose={() => this.onClearTag('productCategory')}
|
|
|
+ >
|
|
|
+ {this.productCategory.name}
|
|
|
+ </Tag>
|
|
|
+ ) : (
|
|
|
+ ''
|
|
|
+ )}
|
|
|
+ {this.productAttributeCategory.id ? (
|
|
|
+ <Tag
|
|
|
+ class={styles.filterTag}
|
|
|
+ closeable={true}
|
|
|
+ onClose={() => this.onClearTag('productAttributeCategory')}
|
|
|
+ >
|
|
|
+ {this.productAttributeCategory.name}
|
|
|
+ </Tag>
|
|
|
+ ) : (
|
|
|
+ ''
|
|
|
+ )}
|
|
|
+ {this.brand.id ? (
|
|
|
+ <Tag
|
|
|
+ class={styles.filterTag}
|
|
|
+ closeable={true}
|
|
|
+ onClose={() => this.onClearTag('brand')}
|
|
|
+ >
|
|
|
+ {this.brand.name}
|
|
|
</Tag>
|
|
|
- ))}
|
|
|
+ ) : (
|
|
|
+ ''
|
|
|
+ )}
|
|
|
</div>
|
|
|
|
|
|
- <TabList typeId={typeId} />
|
|
|
+ <TabList
|
|
|
+ ref="tabList"
|
|
|
+ typeId={this.productCategory.id}
|
|
|
+ productAttributeCategoryId={this.productAttributeCategory.id}
|
|
|
+ brandId={this.brand.id}
|
|
|
+ sort={this.filterActive}
|
|
|
+ />
|
|
|
|
|
|
<Popup
|
|
|
show={this.filterListShow}
|
|
@@ -80,7 +179,7 @@ export default defineComponent({
|
|
|
this.filterListShow = false
|
|
|
}}
|
|
|
>
|
|
|
- <GoodsFilterList onFilterClick={this.onFilterClick} />
|
|
|
+ <GoodsFilterList ref="goodsFilter" setFilter={this.setFilter} />
|
|
|
</Popup>
|
|
|
</div>
|
|
|
)
|