Browse Source

器件选型页--增加品牌筛选功能

wangyc 8 years ago
parent
commit
7ffe2a6b4f
3 changed files with 23 additions and 6 deletions
  1. 8 3
      components/product/CategoryProperty.vue
  2. 13 1
      pages/product/kind/_id.vue
  3. 2 2
      store/product.js

+ 8 - 3
components/product/CategoryProperty.vue

@@ -31,8 +31,8 @@
           <tbody>
           <tr class="tr-brand">
             <td class="td-brand" style="vertical-align: middle;">
-              <div class="sl-selected" v-if="selectedBrand.nameCn" @click="selectBrand()">
-                <nuxt-link class="text-num">{{selectedBrand.nameCn}}</nuxt-link>
+              <div class="sl-selected" v-if="selectedBrand.nameCn" @click="delBrand()">
+                <a class="text-num">{{selectedBrand.nameCn}}</a>
                 <span><i class="fa fa-close"></i></span>
               </div>
               <div v-if="!selectedBrand.nameCn">
@@ -108,7 +108,12 @@
     },
     methods: {
       selectBrand (item) {
-        return null
+        this.selectedBrand = item
+        this.$emit('loadCmpGoodsByBrandEvent', item.id)
+      },
+      delBrand () {
+        this.selectedBrand = {}
+        this.$emit('loadCmpGoodsByBrandEvent', null)
       },
       selectProperty (item) {
         return null

+ 13 - 1
pages/product/kind/_id.vue

@@ -1,7 +1,7 @@
 <template>
   <div class="container">
     <categroy-nav></categroy-nav>
-    <category-property></category-property>
+    <category-property  @loadCmpGoodsByBrandEvent="listemBrandFilter"></category-property>
     <component-goods></component-goods>
   </div>
 </template>
@@ -22,6 +22,18 @@
       CategroyNav,
       CategoryProperty,
       ComponentGoods
+    },
+    methods: {
+      loadPage (id) {
+        this.$store.dispatch('product/pageComGoods', {kindid: this.$route.params.id, brandid: id})
+      },
+      listemBrandFilter (brandid) {
+        if (brandid) {
+          this.$store.dispatch('product/pageComGoods', {kindid: this.$route.params.id, brandid: brandid})
+        } else {
+          this.$store.dispatch('product/pageComGoods', {kindid: this.$route.params.id})
+        }
+      }
     }
   }
 </script>

+ 2 - 2
store/product.js

@@ -84,9 +84,9 @@ export const actions = {
         commit('kind/GET_KINDBRANDS_FAILURE', err)
       })
   },
-  pageComGoods ({ commit }, kindid = '', pageParams = { page: 1, count: 10 }) {
+  pageComGoods ({ commit }, kindid = '', brandid = '', pageParams = { page: 1, count: 10 }) {
     let params = {}
-    let filter = {kindid: kindid.kindid}
+    let filter = {kindid: kindid.kindid, brandid: kindid.brandid}
     params.filter = filter
     params.page = pageParams.page
     params.count = pageParams.count