Authored by 姜枫

fix 1353

@@ -78,7 +78,6 @@ const shop = { @@ -78,7 +78,6 @@ const shop = {
78 queryParams: req.query 78 queryParams: req.query
79 }; 79 };
80 data.products = DataHelper.handleProductList(ret.productList); 80 data.products = DataHelper.handleProductList(ret.productList);
81 - console.log(data);  
82 res.display('shop-index', data); 81 res.display('shop-index', data);
83 } else { 82 } else {
84 shop.list(req, res, next); 83 shop.list(req, res, next);
@@ -100,7 +99,7 @@ const shop = { @@ -100,7 +99,7 @@ const shop = {
100 let uid = req.user.uid; 99 let uid = req.user.uid;
101 let shopId = req.query.shopId; 100 let shopId = req.query.shopId;
102 let q = req.query; 101 let q = req.query;
103 - let hasBrand = !!q.brand; 102 + // let hasBrand = !!q.brand;
104 103
105 q.order = q.order || 's_n_desc'; 104 q.order = q.order || 's_n_desc';
106 q.page = parseInt(q.page || 1, 10); 105 q.page = parseInt(q.page || 1, 10);
@@ -135,15 +134,14 @@ const shop = { @@ -135,15 +134,14 @@ const shop = {
135 let ret = camelCase(result.data); 134 let ret = camelCase(result.data);
136 135
137 if (ret.filter) { 136 if (ret.filter) {
138 - if (!hasBrand) {  
139 - delete q.brand;  
140 - }  
141 ret.filter.standard = ret.standard; 137 ret.filter.standard = ret.standard;
142 ret.filter.groupSort = DataHelper.sortConvert(allSort.data.sort); 138 ret.filter.groupSort = DataHelper.sortConvert(allSort.data.sort);
  139 + ret.filter.singleBrand = true;
143 data.filter = DataHelper.filterHandle(ret.filter, q); 140 data.filter = DataHelper.filterHandle(ret.filter, q);
144 data.filter.showPrice = ret.total > 10; 141 data.filter.showPrice = ret.total > 10;
145 data.filter.showInfo = (data.filter.style && data.filter.style.length > 0) 142 data.filter.showInfo = (data.filter.style && data.filter.style.length > 0)
146 || (ret.standard && ret.standard.length > 0); //eslint-disable-line 143 || (ret.standard && ret.standard.length > 0); //eslint-disable-line
  144 +
147 } 145 }
148 146
149 data.paginationData = { 147 data.paginationData = {
@@ -344,14 +344,19 @@ const helpers = { @@ -344,14 +344,19 @@ const helpers = {
344 } 344 }
345 345
346 if (q.brand) { 346 if (q.brand) {
347 - let brandNames = brands.filter(b => { 347 + let checkedBrands = brands.filter(b => {
348 return (',' + q.brand + ',').indexOf(',' + b.id + ',') >= 0; 348 return (',' + q.brand + ',').indexOf(',' + b.id + ',') >= 0;
349 - }).map(b => { 349 + });
  350 + let brandNames = checkedBrands.map(b => {
350 b.checked = true; 351 b.checked = true;
351 return b.brandNameEn || b.brandName; 352 return b.brandNameEn || b.brandName;
352 }).join('、'); 353 }).join('、');
353 354
354 - if (brandNames) { 355 + if (filter.singleBrand) {
  356 + brands = checkedBrands;
  357 + }
  358 +
  359 + if (brandNames && !filter.singleBrand) {
355 brandNames = brandNames.length > 10 ? brandNames.substr(0, 10) + '...' : brandNames; 360 brandNames = brandNames.length > 10 ? brandNames.substr(0, 10) + '...' : brandNames;
356 filters.push(this.newFilter('brand', q.brand, brandNames)); 361 filters.push(this.newFilter('brand', q.brand, brandNames));
357 } 362 }