Authored by 李奇

sub filter change

@@ -61,7 +61,7 @@ module.exports = { @@ -61,7 +61,7 @@ module.exports = {
61 } 61 }
62 this.$emit('select', { 62 this.$emit('select', {
63 value: this.currentValue, 63 value: this.currentValue,
64 - subType: this.subType 64 + subType: this.type
65 }); 65 });
66 }, 66 },
67 renderData() { 67 renderData() {
@@ -20,6 +20,13 @@ @@ -20,6 +20,13 @@
20 const _ = require('lodash'); 20 const _ = require('lodash');
21 const bus = require('common/vue-bus'); 21 const bus = require('common/vue-bus');
22 22
  23 +const typeMap = {
  24 + 品牌: 'brand',
  25 + 品类: 'group_sort',
  26 + 颜色: 'color',
  27 + 尺寸: 'size'
  28 +};
  29 +
23 module.exports = { 30 module.exports = {
24 props: { 31 props: {
25 name: String, 32 name: String,
@@ -75,21 +82,16 @@ module.exports = { @@ -75,21 +82,16 @@ module.exports = {
75 this.chosenVal = names.join(','); 82 this.chosenVal = names.join(',');
76 }, 83 },
77 expandSub(name){ 84 expandSub(name){
78 - const typeMap = {  
79 - 品牌: 'brand',  
80 - 品类: 'group_sort',  
81 - 颜色: 'color'  
82 - };  
83 -  
84 bus.$emit('expand.subFilter', typeMap[name]); 85 bus.$emit('expand.subFilter', typeMap[name]);
85 }, 86 },
86 setAllChoices(){ 87 setAllChoices(){
87 let isLimited = false; 88 let isLimited = false;
88 const len = this.choices.length; 89 const len = this.choices.length;
  90 + const overCut = ['品牌', '品类', '颜色', '尺寸'];
89 91
90 this.allChoices = this.choices.slice(); 92 this.allChoices = this.choices.slice();
91 this.initialChoices = this.choices.slice(); 93 this.initialChoices = this.choices.slice();
92 - isLimited = ['品牌', '品类', '颜色'].indexOf(this.name) > -1; 94 + isLimited = overCut.indexOf(this.name) > -1;
93 if (len > 11 && isLimited) { 95 if (len > 11 && isLimited) {
94 this.showMore = true; 96 this.showMore = true;
95 this.allChoices = this.choices.slice(0, 11); 97 this.allChoices = this.choices.slice(0, 11);
@@ -108,6 +110,19 @@ module.exports = { @@ -108,6 +110,19 @@ module.exports = {
108 }, 110 },
109 foldExcept(name) { 111 foldExcept(name) {
110 this.show = this.name === name 112 this.show = this.name === name
  113 + },
  114 + subFilterChange(sub){
  115 + if (typeMap[this.name] === sub.subType) {
  116 + let names = [];
  117 +
  118 + if (sub.value && sub.value.length) {
  119 + _.each(sub.value, item => {
  120 + names.push(item.name);
  121 + });
  122 + this.show = false;
  123 + this.chosenVal = names.join(',');
  124 + }
  125 + }
111 } 126 }
112 }, 127 },
113 created(){ 128 created(){
@@ -115,6 +130,7 @@ module.exports = { @@ -115,6 +130,7 @@ module.exports = {
115 bus.$on('chosenVal.clear', this.clearChosenVal); 130 bus.$on('chosenVal.clear', this.clearChosenVal);
116 bus.$on('chosenVal.search', this.searchChosenVal); 131 bus.$on('chosenVal.search', this.searchChosenVal);
117 bus.$on('fold.choice.except', this.foldExcept); 132 bus.$on('fold.choice.except', this.foldExcept);
  133 + bus.$on('subFilter.change', this.subFilterChange);
118 }, 134 },
119 components: {} 135 components: {}
120 }; 136 };
@@ -22,7 +22,7 @@ @@ -22,7 +22,7 @@
22 </div> 22 </div>
23 </div> 23 </div>
24 <filter-sub :value="valueData" :type="subType" 24 <filter-sub :value="valueData" :type="subType"
25 - :data="subFilterData" v-ref:filter-sub @select="subChange"></filter-sub> 25 + :data="subFilterData" v-ref:filter-sub @select="subFilterChange"></filter-sub>
26 </div> 26 </div>
27 </template> 27 </template>
28 <script> 28 <script>
@@ -97,7 +97,10 @@ module.exports = { @@ -97,7 +97,10 @@ module.exports = {
97 group_sort: [], 97 group_sort: [],
98 brand: [], 98 brand: [],
99 color: [], 99 color: [],
100 - } 100 + size: []
  101 + },
  102 + valueData: [],
  103 + subFilterData: []
101 } 104 }
102 }, 105 },
103 computed: { 106 computed: {
@@ -114,12 +117,6 @@ module.exports = { @@ -114,12 +117,6 @@ module.exports = {
114 'icon-sort-up': !this.filterDown, 117 'icon-sort-up': !this.filterDown,
115 'icon-sort-down': this.filterDown 118 'icon-sort-down': this.filterDown
116 } 119 }
117 - },  
118 - subFilterData() {  
119 - return this.filter ? this.filter[this.subType] : {};  
120 - },  
121 - valueData() {  
122 - return this.values && this.values[this.subType];  
123 } 120 }
124 }, 121 },
125 methods: { 122 methods: {
@@ -213,8 +210,8 @@ module.exports = { @@ -213,8 +210,8 @@ module.exports = {
213 this.subType = type; 210 this.subType = type;
214 this.$refs.filterSub.isVisible = true; 211 this.$refs.filterSub.isVisible = true;
215 }, 212 },
216 - subChange(v){  
217 - console.log('subSelected=', v); 213 + subFilterChange(sub){
  214 + bus.$emit('subFilter.change', sub);
218 } 215 }
219 }, 216 },
220 watch: { 217 watch: {
@@ -233,6 +230,10 @@ module.exports = { @@ -233,6 +230,10 @@ module.exports = {
233 } 230 }
234 231
235 this.showLay(); 232 this.showLay();
  233 + },
  234 + subType(type){
  235 + this.valueData = this.values && this.values[type];
  236 + this.subFilterData = this.filter ? this.filter[type] : {};
236 } 237 }
237 }, 238 },
238 components: { 239 components: {
1 <template> 1 <template>
2 <div> 2 <div>
3 <ul class="item-action"> 3 <ul class="item-action">
4 - <li><a href="{{brand && brand.brand_domain | brandUrl}}"><i class="brand icon"></i><span 4 + <li><a href="{{brand && brand.brand_domain | brandUrl}}"><i class="brand icon icon-brand"></i><span
5 class="action-text">{{brand && brand.brand_name 5 class="action-text">{{brand && brand.brand_name
6 }}</span></a></li> 6 }}</span></a></li>
7 <li><i class="icon" 7 <li><i class="icon"
@@ -19,12 +19,9 @@ @@ -19,12 +19,9 @@
19 font-size: 0; 19 font-size: 0;
20 text-align: center; 20 text-align: center;
21 21
22 - .brand {  
23 - display: inline-block;  
24 - width: 36px;  
25 - height: 33px;  
26 - background: resolve('product/brand.png');  
27 - background-size: cover; 22 + .brand.icon {
  23 + font-size: 54px;
  24 + margin-bottom: 10px;
28 } 25 }
29 26
30 li { 27 li {