|
@@ -5,19 +5,24 @@ import styles from './index.module.less'
|
|
import iconFilter from '@/common/images/icon_filter.png'
|
|
import iconFilter from '@/common/images/icon_filter.png'
|
|
import GoodsFilterList from '../modal/goods-filter-list'
|
|
import GoodsFilterList from '../modal/goods-filter-list'
|
|
import ColSearch from '@/components/col-search'
|
|
import ColSearch from '@/components/col-search'
|
|
|
|
+import request from '@/helpers/request'
|
|
export default defineComponent({
|
|
export default defineComponent({
|
|
name: 'goods-list',
|
|
name: 'goods-list',
|
|
data() {
|
|
data() {
|
|
const query = this.$route.query
|
|
const query = this.$route.query
|
|
return {
|
|
return {
|
|
|
|
+ tabListShow: query.id ? false : true,
|
|
typeId: 0,
|
|
typeId: 0,
|
|
filterActive: 0,
|
|
filterActive: 0,
|
|
filterListShow: false,
|
|
filterListShow: false,
|
|
productCategory: {
|
|
productCategory: {
|
|
|
|
+ active: 0,
|
|
name: query.tag || '',
|
|
name: query.tag || '',
|
|
- id: Number(query.id) || 0
|
|
|
|
|
|
+ id: Number(query.id) || 0,
|
|
|
|
+ children: []
|
|
},
|
|
},
|
|
productAttributeCategory: {
|
|
productAttributeCategory: {
|
|
|
|
+ children: [],
|
|
name: '',
|
|
name: '',
|
|
id: 0
|
|
id: 0
|
|
},
|
|
},
|
|
@@ -29,7 +34,18 @@ export default defineComponent({
|
|
autofocus: false
|
|
autofocus: false
|
|
}
|
|
}
|
|
},
|
|
},
|
|
- mounted() {
|
|
|
|
|
|
+ computed: {
|
|
|
|
+ getProductAttributeCategory() {
|
|
|
|
+ if (this.productCategory && this.productCategory.children) {
|
|
|
|
+ let child = (this.productCategory.children[
|
|
|
|
+ this.productCategory.active
|
|
|
|
+ ] || {}) as any
|
|
|
|
+ return child.id || ''
|
|
|
|
+ }
|
|
|
|
+ return this.productCategory.id
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ async mounted() {
|
|
this.$nextTick(() => {
|
|
this.$nextTick(() => {
|
|
if (this.$route.query.input === 'focus') {
|
|
if (this.$route.query.input === 'focus') {
|
|
let input: HTMLInputElement = document.querySelector(
|
|
let input: HTMLInputElement = document.querySelector(
|
|
@@ -38,6 +54,25 @@ export default defineComponent({
|
|
input.focus()
|
|
input.focus()
|
|
}
|
|
}
|
|
})
|
|
})
|
|
|
|
+
|
|
|
|
+ if (this.productCategory.id) {
|
|
|
|
+ try {
|
|
|
|
+ const res = await request.get(
|
|
|
|
+ '/api-mall-portal/product/search/condition'
|
|
|
|
+ )
|
|
|
|
+ if (res.code === 200) {
|
|
|
|
+ this.setFilter({
|
|
|
|
+ productCategory: res.data.productCategorySmallVoList.find(
|
|
|
|
+ (n: any) => n.id === this.productCategory.id
|
|
|
|
+ ),
|
|
|
|
+ productAttributeCategory: undefined,
|
|
|
|
+ brand: undefined
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ } catch (err) {}
|
|
|
|
+ }
|
|
|
|
+ this.tabListShow = true
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
onFilter(n: number) {
|
|
onFilter(n: number) {
|
|
@@ -45,9 +80,15 @@ export default defineComponent({
|
|
if (this.filterActive === 4 && n === 3) n = 3
|
|
if (this.filterActive === 4 && n === 3) n = 3
|
|
if (this.filterActive === n) return
|
|
if (this.filterActive === n) return
|
|
this.filterActive = n
|
|
this.filterActive = n
|
|
- this.onSearch()
|
|
|
|
|
|
+ this.$nextTick(() => {
|
|
|
|
+ this.onSearch()
|
|
|
|
+ })
|
|
},
|
|
},
|
|
setFilter({ productCategory, productAttributeCategory, brand }) {
|
|
setFilter({ productCategory, productAttributeCategory, brand }) {
|
|
|
|
+ // console.log(productCategory.active)
|
|
|
|
+ if (productCategory && productCategory.active === undefined) {
|
|
|
|
+ productCategory.active = 0
|
|
|
|
+ }
|
|
this.productCategory = productCategory
|
|
this.productCategory = productCategory
|
|
? productCategory
|
|
? productCategory
|
|
: { id: 0, name: '' }
|
|
: { id: 0, name: '' }
|
|
@@ -55,13 +96,19 @@ export default defineComponent({
|
|
? productAttributeCategory
|
|
? productAttributeCategory
|
|
: { id: 0, name: '' }
|
|
: { id: 0, name: '' }
|
|
this.brand = brand ? brand : { id: 0, name: '' }
|
|
this.brand = brand ? brand : { id: 0, name: '' }
|
|
- // console.log(
|
|
|
|
- // this.productCategory,
|
|
|
|
- // this.productAttributeCategory,
|
|
|
|
- // this.brand
|
|
|
|
- // )
|
|
|
|
- this.onSearch()
|
|
|
|
- this.filterListShow = false
|
|
|
|
|
|
+ this.$nextTick(() => {
|
|
|
|
+ this.onSearch()
|
|
|
|
+ this.filterListShow = false
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ onToggleTag(i: number) {
|
|
|
|
+ let tabList = this.$refs.tabList as any
|
|
|
|
+ if (tabList.loading) return
|
|
|
|
+ this.productCategory.active = i
|
|
|
|
+ this.$nextTick(() => {
|
|
|
|
+ this.onSearch()
|
|
|
|
+ })
|
|
},
|
|
},
|
|
|
|
|
|
onClearTag(key: string) {
|
|
onClearTag(key: string) {
|
|
@@ -148,10 +195,30 @@ export default defineComponent({
|
|
<Icon name={iconFilter} size={18} />
|
|
<Icon name={iconFilter} size={18} />
|
|
</Col>
|
|
</Col>
|
|
</Row>
|
|
</Row>
|
|
|
|
+ {this.productCategory.id ? (
|
|
|
|
+ <Row class={styles['filter-productCategory']}>
|
|
|
|
+ {/* <Col span={6}>{this.productCategory.name}</Col> */}
|
|
|
|
+ {this.productCategory &&
|
|
|
|
+ this.productCategory.children.map((n: any, i: number) => (
|
|
|
|
+ <Col onClick={() => this.onToggleTag(i)}>
|
|
|
|
+ <div
|
|
|
|
+ class={[
|
|
|
|
+ styles['filter-tag'],
|
|
|
|
+ this.productCategory.active === i
|
|
|
|
+ ? styles['filter-tag-checked']
|
|
|
|
+ : ''
|
|
|
|
+ ]}
|
|
|
|
+ >
|
|
|
|
+ {n.name}
|
|
|
|
+ </div>
|
|
|
|
+ </Col>
|
|
|
|
+ ))}
|
|
|
|
+ </Row>
|
|
|
|
+ ) : null}
|
|
</Sticky>
|
|
</Sticky>
|
|
|
|
|
|
<div class={styles.filterTagWrap}>
|
|
<div class={styles.filterTagWrap}>
|
|
- {this.productCategory.id ? (
|
|
|
|
|
|
+ {/* {this.productCategory.id ? (
|
|
<Tag
|
|
<Tag
|
|
class={styles.filterTag}
|
|
class={styles.filterTag}
|
|
closeable={true}
|
|
closeable={true}
|
|
@@ -161,7 +228,7 @@ export default defineComponent({
|
|
</Tag>
|
|
</Tag>
|
|
) : (
|
|
) : (
|
|
''
|
|
''
|
|
- )}
|
|
|
|
|
|
+ )} */}
|
|
{this.productAttributeCategory.id ? (
|
|
{this.productAttributeCategory.id ? (
|
|
<Tag
|
|
<Tag
|
|
class={styles.filterTag}
|
|
class={styles.filterTag}
|
|
@@ -186,14 +253,16 @@ export default defineComponent({
|
|
)}
|
|
)}
|
|
</div>
|
|
</div>
|
|
|
|
|
|
- <TabList
|
|
|
|
- ref="tabList"
|
|
|
|
- typeId={Number(this.productCategory.id)}
|
|
|
|
- productAttributeCategoryId={this.productAttributeCategory.id}
|
|
|
|
- brandId={this.brand.id}
|
|
|
|
- sort={this.filterActive}
|
|
|
|
- keyword={this.keyword}
|
|
|
|
- />
|
|
|
|
|
|
+ {this.tabListShow ? (
|
|
|
|
+ <TabList
|
|
|
|
+ ref="tabList"
|
|
|
|
+ typeId={Number(this.getProductAttributeCategory)}
|
|
|
|
+ productAttributeCategoryId={this.productAttributeCategory.id}
|
|
|
|
+ brandId={this.brand.id}
|
|
|
|
+ sort={this.filterActive}
|
|
|
|
+ keyword={this.keyword}
|
|
|
|
+ />
|
|
|
|
+ ) : null}
|
|
|
|
|
|
<Popup
|
|
<Popup
|
|
show={this.filterListShow}
|
|
show={this.filterListShow}
|