Explorar o código

分类搜索增加全部按钮

zhengjinyi %!s(int64=3) %!d(string=hai) anos
pai
achega
ec6503b26a

+ 22 - 6
src/main/resources/static/js/product/list.js

@@ -44,7 +44,8 @@ var productList = new Vue({
         isProductScreen:false,
         isActiviChecked:false,
         isNewsChecked:false,
-        isShowAllBrands:false
+        isShowAllBrands:false,
+        isAllcheckedBrand:false
     },
     filters: {
         NumFormat:function(value) {
@@ -169,16 +170,30 @@ var productList = new Vue({
                                     '&bpn=' + brand.id + '&pro=' + this.params.promotionFlag +
                                     '&newg='+ this.params.newFlag;
         },
+        choiceBrandAllHref:function(){// PC全部品牌跳转链接
+            window.location.href =  '/product/list.html?keyword=' + encodeURIComponent(this.params.keyword) +
+                '&bpn=&pro=' + this.params.promotionFlag +
+                '&newg='+ this.params.newFlag;
+        },
         choiceBrand:function(brand,index){// 选择品牌
             var _self = this;
-            brand.isChecked = !brand.isChecked
+            brand.isChecked = !brand.isChecked;
             if (brand.isChecked) {
-                _self.checkedBrandList.push(brand.id)
+                _self.checkedBrandList.push(brand.id);
             } else {
-                _self.checkedBrandList.splice(index, 1)
+                _self.checkedBrandList.splice(index, 1);
             }
-            _self.checkedBrandLength = _self.checkedBrandList.length
-            _self.params.brandIds = this.checkedBrandList.join(',')
+            _self.isAllcheckedBrand = false;
+            _self.checkedBrandLength = _self.checkedBrandList.length;
+            _self.params.brandIds = this.checkedBrandList.join(',');
+        },
+        choiceBrandAll:function(){
+            // 点击选择全部品牌
+            this.isAllcheckedBrand = true;
+            this.params.brandIds = '';
+            this.brandLists.forEach(function(el){
+                el.isChecked = false;
+            });
         },
         showMoreItem:function(){// 点击更多品牌
             this.isShowAllBrands = !this.isShowAllBrands;
@@ -266,6 +281,7 @@ var productList = new Vue({
             if(this.hrefBrandId){
                 this.params.brandIds = this.hrefBrandId +',';
             }
+            console.log('hrefBrandId',this.hrefBrandId)
             if(this.params.promotionFlag == 1){
                 this.isActiviChecked = true;
             }else{

+ 19 - 6
src/main/resources/static/js/product/produce-list.js

@@ -40,7 +40,8 @@ var productList = new Vue({
         isProductScreen:false,
         isActiviChecked:false,
         isNewsChecked:false,
-        isShowAllBrands:false
+        isShowAllBrands:false,
+        isAllcheckedBrand:false
     },
      filters:{
          NumFormat:function(value) {//处理金额
@@ -146,16 +147,28 @@ var productList = new Vue({
             var url = '/product/classify-'+this.typeSort+'-'+this.bigTypeId+'-'+this.smallTypeId+'-'+this.tinyTypeId+'-1-'+this.params.pageSize+'-'+this.params.sortField+'-'+this.params.sortType+'.html?bpn=' + brand.id + '&pro=' + this.params.promotionFlag +'&newg='+ this.params.newFlag;
             window.location.href =  url;
         },
+        choiceBrandAllHref:function(){// PC全部品牌跳转链接
+            var url = '/product/classify-'+this.typeSort+'-'+this.bigTypeId+'-'+this.smallTypeId+'-'+this.tinyTypeId+'-1-'+this.params.pageSize+'-'+this.params.sortField+'-'+this.params.sortType+'.html?bpn=&pro=' + this.params.promotionFlag +'&newg='+ this.params.newFlag;
+            window.location.href =  url;
+        },
         choiceBrand:function(brand,index){// 选择品牌
             var _self = this;
-            brand.isChecked = !brand.isChecked
+            brand.isChecked = !brand.isChecked;
             if (brand.isChecked) {
-                _self.checkedBrandList.push(brand.id)
+                _self.checkedBrandList.push(brand.id);
             } else {
-                _self.checkedBrandList.splice(index, 1)
+                _self.checkedBrandList.splice(index, 1);
             }
-            _self.checkedBrandLength = _self.checkedBrandList.length
-            _self.params.brandIds = this.checkedBrandList.join(',')
+            _self.isAllcheckedBrand = false;
+            _self.checkedBrandLength = _self.checkedBrandList.length;
+            _self.params.brandIds = this.checkedBrandList.join(',');
+        },
+        choiceBrandAll:function(){ // 点击选择全部品牌
+            this.isAllcheckedBrand = true
+            this.params.brandIds = ''
+            this.brandLists.forEach(function(el){
+                el.isChecked = false
+            });
         },
         showMoreItem:function(){// 点击更多品牌
             this.isShowAllBrands = !this.isShowAllBrands;

+ 2 - 0
src/main/resources/templates/product/instruelist.html

@@ -63,6 +63,7 @@
                     <p v-if="!isPC" class="num">已选中<span>{{ checkedBrandLength }}</span>个品牌</p>
                 </div>
                 <div class="product-brand-list" :class="isShowAllBrands ? 'show' : ''">
+                    <div class="brand-list" @click="choiceBrandAll" :class="hrefBrandId ? '' : 'checked'"><a href="javascript:void(0)">全部</a></div>
                     <div class="brand-list" v-for="(brand,index) in brandLists" :key="index"
                          @click="choiceBrandHref(brand, index)" :class="brand.isChecked ? 'checked' : ''">
                         <a href="javascript:void(0)" :title="brand.name" v-html="brand.name"></a>
@@ -90,6 +91,7 @@
                         <p v-if="!isPC" class="num">已选中<span>{{ checkedBrandLength }}</span>个品牌</p>
                     </div>
                     <div class="product-brand-list" :class="isShowAllBrands ? 'show' : ''">
+                        <div class="brand-list" @click="choiceBrandAll" :class="isAllcheckedBrand ? 'checked' : ''"><a href="javascript:void(0)">全部</a></div>
                         <div class="brand-list" v-for="(brand,index) in brandLists" :key="index"
                              @click="choiceBrand(brand, index)" :class="brand.isChecked ? 'checked' : ''">
                             <a href="javascript:void(0)" :title="brand.name" v-html="brand.name"></a>

+ 2 - 0
src/main/resources/templates/product/list.html

@@ -86,6 +86,7 @@
                     <p v-if="!isPC" class="num">已选中<span>{{ checkedBrandLength }}</span>个品牌</p>
                 </div>
                 <div class="product-brand-list" :class="isShowAllBrands ? 'show' : ''">
+                    <div class="brand-list" @click="choiceBrandAllHref" :class="hrefBrandId ? '' : 'checked'"><a href="javascript:void(0)">全部</a></div>
                     <div class="brand-list" @click="choiceBrandHref(brand, index)" v-for="(brand,index) in brandLists"
                          :key="index" :class="brand.isChecked ? 'checked' : ''">
                         <a href="javascript:void(0)" :title="brand.name" v-html="brand.name"></a>
@@ -114,6 +115,7 @@
                         <p v-if="!isPC" class="num">已选中<span>{{ checkedBrandLength }}</span>个品牌</p>
                     </div>
                     <div class="product-brand-list" :class="isShowAllBrands ? 'show' : ''">
+                        <div class="brand-list" @click="choiceBrandAll" :class="isAllcheckedBrand ? 'checked' : ''"><a href="javascript:void(0)">全部</a></div>
                         <div class="brand-list" v-for="(brand,index) in brandLists" :key="index"
                              @click="choiceBrand(brand, index)" :class="brand.isChecked ? 'checked' : ''">
                             <a href="javascript:void(0)" :title="brand.name" v-html="brand.name"></a>