Browse Source

商品列表搜索

skyblued 3 years ago
parent
commit
e3ad4a084d

+ 1 - 0
src/components/col-search/index.tsx

@@ -75,6 +75,7 @@ export default defineComponent({
           onSearch={(val: string) => {
           onSearch={(val: string) => {
             this.onSearch(val)
             this.onSearch(val)
           }}
           }}
+          onClear={() => this.onSearch()}
           v-slots={{
           v-slots={{
             left: () => this.$slots.left && this.$slots.left(),
             left: () => this.$slots.left && this.$slots.left(),
             'left-icon': () => <Icon name={iconSearch} size={16} />,
             'left-icon': () => <Icon name={iconSearch} size={16} />,

+ 6 - 0
src/views/shop-mall/components/tab-list/index.tsx

@@ -27,6 +27,10 @@ export default defineComponent({
     sort: {
     sort: {
       type: Number,
       type: Number,
       defalut: 0
       defalut: 0
+    },
+    keyword: {
+      type: String as any,
+      defalut: ''
     }
     }
   },
   },
   data() {
   data() {
@@ -40,6 +44,7 @@ export default defineComponent({
         productAttributeCategoryId: null as any,
         productAttributeCategoryId: null as any,
         brandId: null as any,
         brandId: null as any,
         sort: null as any, // 1->按新品;2->按销量;3->价格从低到高;4->价格从高到低
         sort: null as any, // 1->按新品;2->按销量;3->价格从低到高;4->价格从高到低
+        keyword: '',
         pageNum: 1,
         pageNum: 1,
         pageSize: 20
         pageSize: 20
       },
       },
@@ -71,6 +76,7 @@ export default defineComponent({
           : undefined
           : undefined
         params.brandId = this.brandId ? this.brandId : undefined
         params.brandId = this.brandId ? this.brandId : undefined
         params.sort = this.sort ? this.sort : undefined
         params.sort = this.sort ? this.sort : undefined
+        params.keyword = this.keyword ? this.keyword : undefined
         const res = await request.post('/api-mall-portal/product/search', {
         const res = await request.post('/api-mall-portal/product/search', {
           data: {
           data: {
             ...params
             ...params

+ 10 - 2
src/views/shop-mall/goods-list/index.tsx

@@ -23,7 +23,8 @@ export default defineComponent({
       brand: {
       brand: {
         name: '',
         name: '',
         id: 0
         id: 0
-      }
+      },
+      keyword: '' as any
     }
     }
   },
   },
   methods: {
   methods: {
@@ -68,13 +69,19 @@ export default defineComponent({
     onSearch() {
     onSearch() {
       let tabList = this.$refs.tabList as any
       let tabList = this.$refs.tabList as any
       tabList.onSearch()
       tabList.onSearch()
+    },
+    searchBtn(keyword?: string){
+      this.keyword = keyword
+      this.$nextTick(() => {
+        this.onSearch()
+      })
     }
     }
   },
   },
   render() {
   render() {
     return (
     return (
       <div>
       <div>
         <Sticky>
         <Sticky>
-          <ColSearch />
+          <ColSearch modelValue={this.keyword} onSearch={this.searchBtn} />
           <Row class={styles['filter-top']} align="center">
           <Row class={styles['filter-top']} align="center">
             <Col
             <Col
               span={6}
               span={6}
@@ -168,6 +175,7 @@ export default defineComponent({
           productAttributeCategoryId={this.productAttributeCategory.id}
           productAttributeCategoryId={this.productAttributeCategory.id}
           brandId={this.brand.id}
           brandId={this.brand.id}
           sort={this.filterActive}
           sort={this.filterActive}
+          keyword={this.keyword}
         />
         />
 
 
         <Popup
         <Popup