Showing
3 changed files
with
73 additions
and
24 deletions
@@ -18,9 +18,9 @@ module.exports = { | @@ -18,9 +18,9 @@ module.exports = { | ||
18 | app_type: 1 | 18 | app_type: 1 |
19 | }, | 19 | }, |
20 | domains: { | 20 | domains: { |
21 | - api: 'http://api-test3.yohops.com:9999/', | ||
22 | - service: 'http://service-test3.yohops.com:9999/', | ||
23 | - singleApi: 'http://api-test3.yohops.com:9999/', | 21 | + // api: 'http://api-test3.yohops.com:9999/', |
22 | + // service: 'http://service-test3.yohops.com:9999/', | ||
23 | + // singleApi: 'http://api-test3.yohops.com:9999/', | ||
24 | 24 | ||
25 | // api: 'http://api-test3.yohops.com:9999/', | 25 | // api: 'http://api-test3.yohops.com:9999/', |
26 | // service: 'http://service-test3.yohops.com:9999/', | 26 | // service: 'http://service-test3.yohops.com:9999/', |
@@ -29,9 +29,9 @@ module.exports = { | @@ -29,9 +29,9 @@ module.exports = { | ||
29 | // api: 'http://dev-api.yohops.com:9999/', | 29 | // api: 'http://dev-api.yohops.com:9999/', |
30 | // service: 'http://dev-service.yohops.com:9999/', | 30 | // service: 'http://dev-service.yohops.com:9999/', |
31 | 31 | ||
32 | - // api: 'http://api.yoho.cn/', | ||
33 | - // service: 'http://service.yoho.cn/', | ||
34 | - // singleApi: 'http://single.yoho.cn/' | 32 | + api: 'http://api.yoho.cn/', |
33 | + service: 'http://service.yoho.cn/', | ||
34 | + singleApi: 'http://single.yoho.cn/' | ||
35 | }, | 35 | }, |
36 | subDomains: { | 36 | subDomains: { |
37 | host: '.m.yohoblk.com', | 37 | host: '.m.yohoblk.com', |
@@ -24,7 +24,9 @@ const typeMap = { | @@ -24,7 +24,9 @@ const typeMap = { | ||
24 | 品牌: 'brand', | 24 | 品牌: 'brand', |
25 | 品类: 'group_sort', | 25 | 品类: 'group_sort', |
26 | 颜色: 'color', | 26 | 颜色: 'color', |
27 | - 尺寸: 'size' | 27 | + 尺寸: 'size', |
28 | + 价格: 'price', | ||
29 | + 折扣: 'discount' | ||
28 | }; | 30 | }; |
29 | 31 | ||
30 | module.exports = { | 32 | module.exports = { |
@@ -66,7 +68,7 @@ module.exports = { | @@ -66,7 +68,7 @@ module.exports = { | ||
66 | newChoice.isChosen && (this.chosen[index] = newChoice); | 68 | newChoice.isChosen && (this.chosen[index] = newChoice); |
67 | 69 | ||
68 | this.calcChosenVal(); | 70 | this.calcChosenVal(); |
69 | - bus.$emit('choice.change', this.name, this.chosen); | 71 | + bus.$emit('subChosen.change', typeMap[this.name], this.chosen); |
70 | }, | 72 | }, |
71 | calcChosenVal(){ | 73 | calcChosenVal(){ |
72 | let name; | 74 | let name; |
@@ -100,10 +102,10 @@ module.exports = { | @@ -100,10 +102,10 @@ module.exports = { | ||
100 | }, | 102 | }, |
101 | clearChosenVal(){ | 103 | clearChosenVal(){ |
102 | this.show = false; | 104 | this.show = false; |
103 | - this.chosen = []; | 105 | + this.chosen = {}; |
104 | this.chosenVal = ''; | 106 | this.chosenVal = ''; |
105 | this.allChoices = this.initialChoices.slice(); | 107 | this.allChoices = this.initialChoices.slice(); |
106 | - bus.$emit('choice.change', this.name, this.chosen); | 108 | + bus.$emit('subChosen.change', this.name, this.chosen); |
107 | }, | 109 | }, |
108 | searchChosenVal(){ | 110 | searchChosenVal(){ |
109 | this.show = false; | 111 | this.show = false; |
@@ -116,8 +118,26 @@ module.exports = { | @@ -116,8 +118,26 @@ module.exports = { | ||
116 | let names = []; | 118 | let names = []; |
117 | 119 | ||
118 | if (sub.value && sub.value.length) { | 120 | if (sub.value && sub.value.length) { |
121 | + this.allChoices = this.initialChoices.slice(); | ||
122 | + | ||
119 | _.each(sub.value, item => { | 123 | _.each(sub.value, item => { |
120 | names.push(item.name); | 124 | names.push(item.name); |
125 | + _.each(this.allChoices, (choice, index) => { | ||
126 | + const isSort = this.name === '品类'; | ||
127 | + const id = isSort ? choice.category_id : choice.id; | ||
128 | + | ||
129 | + if (item.id === id) { | ||
130 | + let newChoice = { | ||
131 | + id: choice.id, | ||
132 | + name: choice.name, | ||
133 | + isChosen: !choice.isChosen, | ||
134 | + category_name: choice.category_name, | ||
135 | + relation_parameter: choice.relation_parameter | ||
136 | + }; | ||
137 | + this.chosen[index] = newChoice; | ||
138 | + this.allChoices.$set(index, newChoice); | ||
139 | + } | ||
140 | + }); | ||
121 | }); | 141 | }); |
122 | this.show = false; | 142 | this.show = false; |
123 | this.chosenVal = names.join(','); | 143 | this.chosenVal = names.join(','); |
@@ -41,6 +41,15 @@ const keyMap = { | @@ -41,6 +41,15 @@ const keyMap = { | ||
41 | 折扣: 'discount' | 41 | 折扣: 'discount' |
42 | }; | 42 | }; |
43 | 43 | ||
44 | +const convertMap = { | ||
45 | + brand: 'brand', | ||
46 | + group_sort: 'sort', | ||
47 | + color: 'color', | ||
48 | + size: 'size', | ||
49 | + price: 'price', | ||
50 | + discount: 'discount', | ||
51 | +}; | ||
52 | + | ||
44 | module.exports = { | 53 | module.exports = { |
45 | props: { | 54 | props: { |
46 | val: String, | 55 | val: String, |
@@ -166,10 +175,11 @@ module.exports = { | @@ -166,10 +175,11 @@ module.exports = { | ||
166 | 175 | ||
167 | _.each(this.chosen, (val, key) => { | 176 | _.each(this.chosen, (val, key) => { |
168 | ids = []; | 177 | ids = []; |
178 | + key = convertMap[key]; | ||
169 | keys = Object.keys(val); | 179 | keys = Object.keys(val); |
170 | 180 | ||
171 | _.each(keys, v => { | 181 | _.each(keys, v => { |
172 | - if (key !== '品类') { | 182 | + if (key !== 'sort') { |
173 | ids.push(val[v].id); | 183 | ids.push(val[v].id); |
174 | } else { | 184 | } else { |
175 | ids.push(val[v].relation_parameter.sort); | 185 | ids.push(val[v].relation_parameter.sort); |
@@ -177,9 +187,9 @@ module.exports = { | @@ -177,9 +187,9 @@ module.exports = { | ||
177 | }); | 187 | }); |
178 | 188 | ||
179 | if (ids.length) { | 189 | if (ids.length) { |
180 | - filter[keyMap[key]] = ids.join(','); | 190 | + filter[key] = ids.join(','); |
181 | } else { | 191 | } else { |
182 | - delete filter[keyMap[key]]; | 192 | + delete filter[key]; |
183 | } | 193 | } |
184 | }); | 194 | }); |
185 | 195 | ||
@@ -208,10 +218,39 @@ module.exports = { | @@ -208,10 +218,39 @@ module.exports = { | ||
208 | }, | 218 | }, |
209 | expandSub(type){ | 219 | expandSub(type){ |
210 | this.subType = type; | 220 | this.subType = type; |
221 | + this.valueData = this.values && this.values[type]; | ||
222 | + this.subFilterData = this.filter ? this.filter[type] : {}; | ||
211 | this.$refs.filterSub.isVisible = true; | 223 | this.$refs.filterSub.isVisible = true; |
212 | }, | 224 | }, |
213 | subFilterChange(sub){ | 225 | subFilterChange(sub){ |
214 | bus.$emit('subFilter.change', sub); | 226 | bus.$emit('subFilter.change', sub); |
227 | + }, | ||
228 | + subChosenChange(name, chosen) { | ||
229 | + let keyArr = Object.keys(chosen); | ||
230 | + | ||
231 | + if (keyArr.length) { | ||
232 | + let id, nm; | ||
233 | + | ||
234 | + this.values[name] = []; | ||
235 | + _.each(keyArr, key => { | ||
236 | + id = name !== 'group_sort' ? | ||
237 | + chosen[key].id : | ||
238 | + chosen[key].relation_parameter.sort; | ||
239 | + | ||
240 | + nm = name !== 'group_sort' ? | ||
241 | + chosen[key].name : | ||
242 | + chosen[key].category_name; | ||
243 | + | ||
244 | + this.values[name].push({ | ||
245 | + id, | ||
246 | + name: nm | ||
247 | + }); | ||
248 | + }); | ||
249 | + this.chosen[name] = chosen; | ||
250 | + } else { | ||
251 | + this.values[name] = []; | ||
252 | + delete this.chosen[name]; | ||
253 | + } | ||
215 | } | 254 | } |
216 | }, | 255 | }, |
217 | watch: { | 256 | watch: { |
@@ -230,10 +269,6 @@ module.exports = { | @@ -230,10 +269,6 @@ module.exports = { | ||
230 | } | 269 | } |
231 | 270 | ||
232 | this.showLay(); | 271 | this.showLay(); |
233 | - }, | ||
234 | - subType(type){ | ||
235 | - this.valueData = this.values && this.values[type]; | ||
236 | - this.subFilterData = this.filter ? this.filter[type] : {}; | ||
237 | } | 272 | } |
238 | }, | 273 | }, |
239 | components: { | 274 | components: { |
@@ -253,13 +288,7 @@ module.exports = { | @@ -253,13 +288,7 @@ module.exports = { | ||
253 | this.filterItems[4].choices = this.filter.priceRange; | 288 | this.filterItems[4].choices = this.filter.priceRange; |
254 | this.filterItems[5].choices = this.filter.discount; | 289 | this.filterItems[5].choices = this.filter.discount; |
255 | 290 | ||
256 | - bus.$on('choice.change', (name, chosen) => { | ||
257 | - if (!_.isArray(chosen)) { | ||
258 | - this.chosen[name] = chosen; | ||
259 | - } else { | ||
260 | - delete this.chosen[name]; | ||
261 | - } | ||
262 | - }); | 291 | + bus.$on('subChosen.change', this.subChosenChange); |
263 | 292 | ||
264 | bus.$on('expand.choice.only', name => { | 293 | bus.$on('expand.choice.only', name => { |
265 | bus.$emit('fold.choice.except', name); | 294 | bus.$emit('fold.choice.except', name); |
-
Please register or login to post a comment