Authored by ccbikai

Merge branch 'feature/sale' into develop

@@ -13,6 +13,15 @@ const headerModel = require('../../../doraemon/models/header'); @@ -13,6 +13,15 @@ const headerModel = require('../../../doraemon/models/header');
13 const log = require(`${library}/logger`); 13 const log = require(`${library}/logger`);
14 const saleModel = require(`${mRoot}/sale`); 14 const saleModel = require(`${mRoot}/sale`);
15 15
  16 +// const queryParam = {
  17 +// brand: '0',
  18 +// gender: '1,2,3',
  19 +// sort: '0',
  20 +// size: '0',
  21 +// price: '0',
  22 +// discount: '0.1,0.9'
  23 +// };
  24 +
16 const saleLogger = (err, res) => { 25 const saleLogger = (err, res) => {
17 log.error('sale页面渲染错误:' + JSON.stringify(err)); 26 log.error('sale页面渲染错误:' + JSON.stringify(err));
18 res.send('error'); 27 res.send('error');
@@ -140,12 +149,16 @@ exports.filter = (req, res) => { @@ -140,12 +149,16 @@ exports.filter = (req, res) => {
140 149
141 exports.search = (req, res) => { 150 exports.search = (req, res) => {
142 let params = Object.assign({}, req.query); 151 let params = Object.assign({}, req.query);
  152 + let uid = req.user.uid || 0;
  153 +
  154 + saleModel.getSearchData(params, uid).then((result) => {
  155 + let vipLevel = result[1].curLevel;
143 156
144 - saleModel.getSearchData(params).then((result) => {  
145 res.render('product', { 157 res.render('product', {
146 layout: false, 158 layout: false,
147 params: params, 159 params: params,
148 - goods: result 160 + goods: result[0],
  161 + saleVip: (req.query.saleType === '2' && (!uid || vipLevel === '1'))
149 }); 162 });
150 }); 163 });
151 }; 164 };
@@ -13,6 +13,7 @@ const logger = require(`${library}/logger`); @@ -13,6 +13,7 @@ const logger = require(`${library}/logger`);
13 const helpers = require(`${library}/helpers`); 13 const helpers = require(`${library}/helpers`);
14 const camelCase = require(`${library}/camel-case`); 14 const camelCase = require(`${library}/camel-case`);
15 const resourcesProcess = require(`${utils}/resources-process`); 15 const resourcesProcess = require(`${utils}/resources-process`);
  16 +const productProcess = require(`${utils}/product-process`);
16 const _ = require('lodash'); 17 const _ = require('lodash');
17 const api = new API(); 18 const api = new API();
18 const serviceAPI = new ServiceAPI(); 19 const serviceAPI = new ServiceAPI();
@@ -34,8 +35,9 @@ const timeFormat = { @@ -34,8 +35,9 @@ const timeFormat = {
34 const typeCont = { 35 const typeCont = {
35 price: ['s_p_desc', 's_p_asc'], 36 price: ['s_p_desc', 's_p_asc'],
36 discount: ['p_d_desc', 'p_d_asc'], 37 discount: ['p_d_desc', 'p_d_asc'],
37 - sales: ['s_n_desc', 's_n_asc'],  
38 - newest: ['s_t_desc', 's_t_asc'] 38 + sale: ['s_n_desc', 's_n_asc'],
  39 + newest: ['s_t_desc', 's_t_asc'],
  40 + stock: ['s_s_desc', 's_s_asc']
39 }; 41 };
40 42
41 /** 43 /**
@@ -129,141 +131,6 @@ const special = (params) => { @@ -129,141 +131,6 @@ const special = (params) => {
129 }; 131 };
130 132
131 /** 133 /**
132 - * 根据性别来决定 默认图片获取字段 如果是 2、3  
133 - *  
134 - * 则优先从cover2 --》 cover1 -- 》 images_url  
135 - * 否则优先从cover1 --》 cover2 -- 》 images_url  
136 - *  
137 - */  
138 -const procProductImg = (product, gender) => {  
139 - if (gender === '2,3') {  
140 - return product.cover2 || product.cover1 || product.imagesUrl || '';  
141 - }  
142 -  
143 - return product.cover1 || product.cover2 || product.imagesUrl || '';  
144 -};  
145 -  
146 -  
147 -/**  
148 - * 商品搜索商品数据处理  
149 - */  
150 -const processProductList = (list, options) => {  
151 - const pruductList = [];  
152 -  
153 - options = Object.assign({  
154 - showTags: true,  
155 - showNew: true,  
156 - showSale: true,  
157 - width: 290,  
158 - height: 388,  
159 - isApp: false,  
160 - showPoint: true,  
161 - gender: '2,3'  
162 - }, options);  
163 - list = camelCase(list);  
164 -  
165 - _.forEach(list, (product) => {  
166 - // 商品信息有问题,则不显示  
167 - if (!product.productId || !product.goodsList.length) {  
168 - return;  
169 - }  
170 -  
171 - // 市场价和售价一样,则不显示市场价  
172 - if (product.marketPrice === product.salesPrice) {  
173 - product.marketPrice = false;  
174 - }  
175 -  
176 - // 判别默认的商品是否将默认的图片URL赋值到skn  
177 - let flag = false;  
178 -  
179 - // 如果设置了默认图片,就取默认的图片  
180 - _.forEach(product.goodsList, (goods) => {  
181 - if (flag) {  
182 - return;  
183 - }  
184 - if (goods.isDefault === 'Y') {  
185 - product.defaultImages = procProductImg(goods);  
186 - flag = true;  
187 - }  
188 - });  
189 -  
190 - // 如果还未赋值,则取第一个skc产品的默认图片  
191 - if (!flag) {  
192 - product.defaultImages = procProductImg(product.goodsList[0]);  
193 - }  
194 -  
195 - // product = Object.assign(product, {  
196 - // id: product.productSkn,  
197 - // thumb: product.defaultImages  
198 - // });  
199 -  
200 - if (options.showPoint) {  
201 - product.price += '.00';  
202 - product.salePrice += '.00';  
203 - }  
204 -  
205 - product.isSoonSoldOut = product.isSoonSoldOut === 'Y';  
206 - product.url = helpers.urlFormat(`/product/pro_${product.productId}_${product.goodsList[0].goodsId}/${product.cnAlphabet}.html`); // eslint-disable-line  
207 -  
208 - // APP访问需要加附加的参数  
209 - // 备注:如果以后APP的接口太多,可以把这边参数提取出来,变成一个公共的方法来生成,便于以后管理维护  
210 - if (options.isApp) {  
211 - product.url += `?openby:yohobuy={"action":"go.productDetail","params":{"product_skn":'${product.productId}'}}`; // eslint-disable-line  
212 - }  
213 -  
214 - if (options.showTags) {  
215 - product.tags = {};  
216 -  
217 - product.tags.isNew = options.showNew && product.isNew === 'Y'; // 新品  
218 - product.tags.isDiscount = options.showSale && product.isDiscount === 'Y'; // 在售  
219 - product.tags.isLimited = product.isLimited === 'Y'; // 限量  
220 - product.tags.isYohood = product.isYohood === 'Y'; // YOHOOD  
221 - product.tags.midYear = product.midYear === 'Y'; // 年中  
222 - product.tags.yearEnd = product.yearEnd === 'Y'; // 年末  
223 - product.tags.isAdvance = product.isAdvance === 'Y'; // 再到着  
224 -  
225 - // 打折与即将售完组合显示打折  
226 - if (product.isSoonSoldOut && product.tags.isDiscount) {  
227 - product.tags.isNew = false;  
228 - } else if (product.tags.isDiscount &&  
229 - (product.tags.isNew || product.tags.isLimited || product.tags.isYohood || product.tags.isAdvance)) {  
230 - // 打折与其它组合则隐藏打折  
231 - product.tags.isDiscount = false;  
232 - } else if (product.tags.isYohood && product.tags.isNew) {  
233 - // YOHOOD和新品组合显示YOHOOD  
234 - product.tags.isNew = false;  
235 - }  
236 - }  
237 -  
238 - pruductList.push(product);  
239 - });  
240 - return pruductList;  
241 -};  
242 -  
243 -/**  
244 - * 处理筛选数据  
245 - * @param list  
246 - * @param string | options  
247 - * @return array 处理之后的筛选数据  
248 - */  
249 -const processFilter = (list, options) => {  
250 - const filters = {  
251 - classify: {}  
252 - };  
253 -  
254 - options = Object.assign({  
255 - gender: '1,2,3', // 默认选择的性别,默认1,2,3表示所有  
256 - exclude: null // 需要排除的字段  
257 - }, options);  
258 - list = camelCase(list);  
259 -  
260 - _.forEach(list, (item, key) => {  
261 - console.log(key);  
262 - });  
263 - return filters;  
264 -};  
265 -  
266 -/**  
267 * 断码区分类数据处理 134 * 断码区分类数据处理
268 */ 135 */
269 const processBreakingSort = (list) => { 136 const processBreakingSort = (list) => {
@@ -293,12 +160,13 @@ const processBreakingSort = (list) => { @@ -293,12 +160,13 @@ const processBreakingSort = (list) => {
293 */ 160 */
294 const searchSales = (params) => { 161 const searchSales = (params) => {
295 params = Object.assign({ 162 params = Object.assign({
296 - limit: '20' 163 + limit: '50'
297 }, params); 164 }, params);
298 165
299 if (typeCont[params.type]) { 166 if (typeCont[params.type]) {
300 params.order = typeCont[params.type][params.order]; 167 params.order = typeCont[params.type][params.order];
301 } 168 }
  169 +
302 return api.get('', sign.apiSign(Object.assign({ 170 return api.get('', sign.apiSign(Object.assign({
303 method: 'app.search.sales' 171 method: 'app.search.sales'
304 }, params)), true); 172 }, params)), true);
@@ -310,7 +178,10 @@ const searchSales = (params) => { @@ -310,7 +178,10 @@ const searchSales = (params) => {
310 exports.getFilterData = (params) => { 178 exports.getFilterData = (params) => {
311 return searchSales(params).then((result) => { 179 return searchSales(params).then((result) => {
312 if (result && result.code === 200) { 180 if (result && result.code === 200) {
313 - return processFilter(result.data.filter || []); 181 + return productProcess.processFilter(result.data.filter || [], {
  182 + hideSize: params.saleType === '1',
  183 + hideSort: params.saleType === '1'
  184 + });
314 } else { 185 } else {
315 logger.error('SALE 商品搜索返回 code 不是 200'); 186 logger.error('SALE 商品搜索返回 code 不是 200');
316 return []; 187 return [];
@@ -318,18 +189,41 @@ exports.getFilterData = (params) => { @@ -318,18 +189,41 @@ exports.getFilterData = (params) => {
318 }); 189 });
319 }; 190 };
320 191
  192 +const getUserProfile = (uid) => {
  193 + if (!uid) {
  194 + return Promise.resolve({
  195 + code: 200,
  196 + data: {}
  197 + });
  198 + }
  199 + return api.get('', sign.apiSign({
  200 + method: 'app.passport.profile',
  201 + uid: uid
  202 + }), true);
  203 +};
  204 +
321 /** 205 /**
322 * 获取商品数据 206 * 获取商品数据
323 */ 207 */
324 -exports.getSearchData = (params) => {  
325 - return searchSales(params).then((result) => {  
326 - if (result && result.code === 200) {  
327 - return processProductList(result.data.product_list || []);  
328 - } else {  
329 - logger.error('SALE 商品搜索返回 code 不是 200');  
330 - return {};  
331 - }  
332 - }); 208 +exports.getSearchData = (params, uid) => {
  209 + return Promise.all([
  210 + searchSales(params).then((result) => {
  211 + if (result && result.code === 200) {
  212 + return productProcess.processProductList(result.data.product_list || []);
  213 + } else {
  214 + logger.error('SALE 商品搜索返回 code 不是 200');
  215 + return [];
  216 + }
  217 + }),
  218 + getUserProfile(uid).then((result) => {
  219 + if (result && result.code === 200) {
  220 + return result.data.vip_info ? camelCase(result.data.vip_info) : {};
  221 + } else {
  222 + logger.error('获取用户信息返回 code 不是 200');
  223 + return {};
  224 + }
  225 + })
  226 + ]);
333 }; 227 };
334 228
335 /** 229 /**
@@ -16,7 +16,6 @@ @@ -16,7 +16,6 @@
16 <li class="new active"> 16 <li class="new active">
17 <a href="javascript:void(0);"> 17 <a href="javascript:void(0);">
18 <span class="span-test">最新</span> 18 <span class="span-test">最新</span>
19 - <span class="iconfont cur">&#xe616;</span>  
20 </a> 19 </a>
21 </li> 20 </li>
22 <li class="price"> 21 <li class="price">
@@ -45,19 +44,5 @@ @@ -45,19 +44,5 @@
45 </li> 44 </li>
46 </ul> 45 </ul>
47 46
48 - <div id="goods-container" class="goods-container">  
49 - <div class="new-goods container clearfix">  
50 - {{# goods}}  
51 - {{> common/goods}}  
52 - {{/ goods}}  
53 - </div>  
54 - <div class="price-goods container hide clearfix"></div>  
55 - <div class="discount-goods container hide clearfix"></div>  
56 -  
57 - {{> common/filter}}  
58 - </div>  
59 -  
60 - {{> common/query-param}}  
61 -  
62 - {{> common/suspend-cart}} 47 + {{> product/sale-common}}
63 </div> 48 </div>
1 <div class="sale-channel-page discount-page yoho-page"> 1 <div class="sale-channel-page discount-page yoho-page">
  2 + {{> product/sale-banner}}
  3 + <ul id="list-nav" class="list-nav clearfix">
  4 + <li class="all active">
  5 + <a href="javascript:void(0);">
  6 + <span class="span-test">全部</span>
  7 + </a>
  8 + </li>
  9 + <li class="price">
  10 + <a href="javascript:void(0);">
  11 + <span class="span-test">价格</span>
  12 + <span class="icon">
  13 + <i class="iconfont up cur">&#xe615;</i>
  14 + <i class="iconfont down">&#xe616;</i>
  15 + </span>
  16 + </a>
  17 + </li>
  18 + <li class="discount">
  19 + <a href="javascript:void(0);">
  20 + <span class="span-test">折扣</span>
  21 + <span class="icon">
  22 + <i class="iconfont up cur">&#xe615;</i>
  23 + <i class="iconfont down">&#xe616;</i>
  24 + </span>
  25 + </a>
  26 + </li>
  27 + <li class="filter">
  28 + <a href="javascript:void(0);">
  29 + <span class="span-test">筛选</span>
  30 + <span class="iconfont cur">&#xe613;</span>
  31 + </a>
  32 + </li>
  33 + </ul>
2 {{> product/sale-common}} 34 {{> product/sale-common}}
3 </div> 35 </div>
1 <div class="sale-vip-page discount-page yoho-page"> 1 <div class="sale-vip-page discount-page yoho-page">
  2 +
  3 + {{> product/sale-banner}}
  4 + <ul id="list-nav" class="list-nav clearfix">
  5 + <li class="new active">
  6 + <a href="javascript:void(0);">
  7 + <span class="span-test">最新</span>
  8 + </a>
  9 + </li>
  10 + <li class="price">
  11 + <a href="javascript:void(0);">
  12 + <span class="span-test">价格</span>
  13 + <span class="icon">
  14 + <i class="iconfont up cur">&#xe615;</i>
  15 + <i class="iconfont down">&#xe616;</i>
  16 + </span>
  17 + </a>
  18 + </li>
  19 + <li class="sale">
  20 + <a href="javascript:void(0);">
  21 + <span class="span-test">销量</span>
  22 + </a>
  23 + </li>
  24 + <li class="filter">
  25 + <a href="javascript:void(0);">
  26 + <span class="span-test">筛选</span>
  27 + <span class="iconfont cur">&#xe613;</span>
  28 + </a>
  29 + </li>
  30 + </ul>
2 {{> product/sale-common}} 31 {{> product/sale-common}}
3 </div> 32 </div>
  1 +<div class="banner">
  2 + {{#content}}
  3 + {{! 头部banner}}
  4 + {{#if focus}}
  5 + {{> resources/banner-top}}
  6 + {{/if}}
  7 + {{/content}}
  8 + {{# activity}}
  9 + <img src="{{image coverUrl 640 250}}"/>
  10 + <p class="activity-time" data-time-ms="{{leftTime}}"><i class="iconfont time-ico">&#xe603;</i><span>{{time}}</span></p>
  11 + {{/ activity}}
  12 +</div>
1 -<div class="banner">  
2 - {{#content}}  
3 - {{! 头部banner}}  
4 - {{#if focus}}  
5 - {{> resources/banner-top}}  
6 - {{/if}}  
7 - {{/content}}  
8 - {{# activity}}  
9 - <img src="{{image coverUrl 640 250}}"/>  
10 - <p class="activity-time" data-time-ms="{{leftTime}}"><i class="iconfont time-ico">&#xe603;</i><span>{{time}}</span></p>  
11 - {{/ activity}}  
12 -</div>  
13 -<ul id="list-nav" class="list-nav clearfix">  
14 - <li class="new active">  
15 - <a href="javascript:void(0);">  
16 - <span class="span-test">最新</span>  
17 - <span class="iconfont cur">&#xe616;</span>  
18 - </a>  
19 - </li>  
20 - <li class="price">  
21 - <a href="javascript:void(0);">  
22 - <span class="span-test">价格</span>  
23 - <span class="icon">  
24 - <i class="iconfont up cur">&#xe615;</i>  
25 - <i class="iconfont down">&#xe616;</i>  
26 - </span>  
27 - </a>  
28 - </li>  
29 - <li class="discount">  
30 - <a href="javascript:void(0);">  
31 - <span class="span-test">折扣</span>  
32 - <span class="icon">  
33 - <i class="iconfont up cur">&#xe615;</i>  
34 - <i class="iconfont down">&#xe616;</i>  
35 - </span>  
36 - </a>  
37 - </li>  
38 - <li class="filter">  
39 - <a href="javascript:void(0);">  
40 - <span class="span-test">筛选</span>  
41 - <span class="iconfont cur">&#xe613;</span>  
42 - </a>  
43 - </li>  
44 -</ul>  
45 -  
46 <div id="goods-container" class="goods-container"> 1 <div id="goods-container" class="goods-container">
47 <div class="new-goods container clearfix"> 2 <div class="new-goods container clearfix">
48 {{# goods}} 3 {{# goods}}
@@ -51,6 +6,8 @@ @@ -51,6 +6,8 @@
51 </div> 6 </div>
52 <div class="price-goods container hide clearfix"></div> 7 <div class="price-goods container hide clearfix"></div>
53 <div class="discount-goods container hide clearfix"></div> 8 <div class="discount-goods container hide clearfix"></div>
  9 + <div class="all-goods container hide clearfix"></div>
  10 + <div class="sale-goods container hide clearfix"></div>
54 11
55 {{> common/filter}} 12 {{> common/filter}}
56 </div> 13 </div>
@@ -13,7 +13,7 @@ module.exports = { @@ -13,7 +13,7 @@ module.exports = {
13 port: 6001, 13 port: 6001,
14 siteUrl: 'http://m.yohobuy.com', 14 siteUrl: 'http://m.yohobuy.com',
15 domains: { 15 domains: {
16 - api: 'http://testapi.yoho.cn:28078/', 16 + api: 'http://api.open.yohobuy.com/', // http://192.168.102.205:8080/gateway http://testapi.yoho.cn:28078/
17 service: 'http://testservice.yoho.cn:28077/' 17 service: 'http://testservice.yoho.cn:28077/'
18 }, 18 },
19 useOneapm: false, 19 useOneapm: false,
1 -{{#if .}} {{!-- 剔除值为false的项 --}} 1 +{{#if this}} {{!-- 剔除值为false的项 --}}
2 <div class="good-info" data-id="{{productSkn}}" data-bp-id="guang_goodList_{{productName}}_false"> 2 <div class="good-info" data-id="{{productSkn}}" data-bp-id="guang_goodList_{{productName}}_false">
3 <div class="tag-container clearfix"> 3 <div class="tag-container clearfix">
4 {{# tags}} 4 {{# tags}}
@@ -12,7 +12,7 @@ @@ -12,7 +12,7 @@
12 <p class="good-tag sale-tag">SALE</p> 12 <p class="good-tag sale-tag">SALE</p>
13 {{/ isDiscount}} 13 {{/ isDiscount}}
14 {{# isYohoood}} 14 {{# isYohoood}}
15 - <p class="good-tag running-man-tag">跑男同款</p> 15 + <p class="good-tag running-man-tag">跑男同款</p>
16 {{/ isYohoood}} 16 {{/ isYohoood}}
17 {{# isLimited}} 17 {{# isLimited}}
18 <p class="good-tag limit-tag">限量商品</p> 18 <p class="good-tag limit-tag">限量商品</p>
@@ -20,7 +20,7 @@ @@ -20,7 +20,7 @@
20 {{/ tags}} 20 {{/ tags}}
21 </div> 21 </div>
22 <div class="good-detail-img"> 22 <div class="good-detail-img">
23 - <a class="good-thumb" href="{{url}}" data-img={{defaultImages}}> 23 + <a class="good-thumb" href="{{url}}">
24 <img class="lazy" data-original="{{image defaultImages 235 314}}"> 24 <img class="lazy" data-original="{{image defaultImages 235 314}}">
25 </a> 25 </a>
26 {{# isSoonSoldOut}} 26 {{# isSoonSoldOut}}
@@ -40,11 +40,11 @@ @@ -40,11 +40,11 @@
40 <span class="market-price">¥{{.}}</span> 40 <span class="market-price">¥{{.}}</span>
41 {{/marketPrice}} 41 {{/marketPrice}}
42 </div> 42 </div>
43 - {{#if saleVip}} 43 + {{#if @root.saleVip}}
44 <div class="vip-info"> 44 <div class="vip-info">
45 <i class="vip-icon"></i>更优惠 45 <i class="vip-icon"></i>更优惠
46 </div> 46 </div>
47 {{/if}} 47 {{/if}}
48 </div> 48 </div>
49 </div> 49 </div>
50 -{{/if}}  
  50 +{{/if}}
@@ -13,7 +13,9 @@ let camelCase, @@ -13,7 +13,9 @@ let camelCase,
13 camelCaseObject = (obj) => { 13 camelCaseObject = (obj) => {
14 _.forEach(Object.keys(obj), (k) => { 14 _.forEach(Object.keys(obj), (k) => {
15 obj[k] = camelCase(obj[k]); 15 obj[k] = camelCase(obj[k]);
16 - obj[_.camelCase(k)] = obj[k]; 16 + if (/[_-]/.test(k)) {
  17 + obj[_.camelCase(k)] = obj[k];
  18 + }
17 }); 19 });
18 return obj; 20 return obj;
19 }; 21 };
@@ -107,6 +107,10 @@ function subClassifyTapEvt($this) { @@ -107,6 +107,10 @@ function subClassifyTapEvt($this) {
107 }); 107 });
108 } 108 }
109 109
  110 + if (hCbFn) {
  111 + hCbFn();
  112 + }
  113 +
110 hideFilter(); 114 hideFilter();
111 } 115 }
112 116
@@ -25,34 +25,32 @@ var winH = $(window).height(), @@ -25,34 +25,32 @@ var winH = $(window).height(),
25 // 默认筛选条件 25 // 默认筛选条件
26 var defaultOpt = require('./query-param'); 26 var defaultOpt = require('./query-param');
27 27
  28 +var storeOpt = $.extend({}, defaultOpt);
  29 +
28 var $listNav = $('#list-nav'), 30 var $listNav = $('#list-nav'),
29 $swiperSize = $('.swiper-size'), 31 $swiperSize = $('.swiper-size'),
30 32
31 // 导航数据信息 33 // 导航数据信息
32 navInfo = { 34 navInfo = {
33 coat: { 35 coat: {
34 - order: 1,  
35 reload: true, 36 reload: true,
36 page: 0, 37 page: 0,
37 end: false, 38 end: false,
38 saleType: 1 39 saleType: 1
39 }, 40 },
40 trouser: { 41 trouser: {
41 - order: 1,  
42 reload: true, 42 reload: true,
43 page: 0, 43 page: 0,
44 end: false, 44 end: false,
45 saleType: 1 45 saleType: 1
46 }, 46 },
47 shoes: { 47 shoes: {
48 - order: 1,  
49 reload: true, 48 reload: true,
50 page: 0, 49 page: 0,
51 end: false, 50 end: false,
52 saleType: 1 51 saleType: 1
53 }, 52 },
54 other: { 53 other: {
55 - order: 1,  
56 reload: true, 54 reload: true,
57 page: 0, 55 page: 0,
58 end: false, 56 end: false,
@@ -72,6 +70,18 @@ ellipsis.init(); @@ -72,6 +70,18 @@ ellipsis.init();
72 70
73 lazyLoad($('img.lazy')); 71 lazyLoad($('img.lazy'));
74 72
  73 +if ($('.banner-swiper .swiper-slide').length > 1) {
  74 + new Swiper('.swiper-container', {
  75 + lazyLoading: true,
  76 + lazyLoadingInPrevNext: true,
  77 + loop: true,
  78 + autoplay: 3000,
  79 + autoplayDisableOnInteraction: true,
  80 + paginationClickable: true,
  81 + pagination: '.banner-top .pagination-inner'
  82 + });
  83 +}
  84 +
75 $.each($swiperSize, function(key) { 85 $.each($swiperSize, function(key) {
76 swipers[key] = new Swiper('#size-swiper-' + key, { 86 swipers[key] = new Swiper('#size-swiper-' + key, {
77 slidesPerView: 'auto' 87 slidesPerView: 'auto'
@@ -82,6 +92,23 @@ $.each($listNav.find('li'), function(key, item) { @@ -82,6 +92,23 @@ $.each($listNav.find('li'), function(key, item) {
82 $(item).addClass(goodsType[key]); 92 $(item).addClass(goodsType[key]);
83 }); 93 });
84 94
  95 +// 判断导航类型
  96 +function judgeType(dom) {
  97 + var navType;
  98 +
  99 + if (dom.hasClass('coat')) {
  100 + navType = 'coat';
  101 + } else if (dom.hasClass('trouser')) {
  102 + navType = 'trouser';
  103 + } else if (dom.hasClass('shoes')) {
  104 + navType = 'shoes';
  105 + } else {
  106 + navType = 'other';
  107 + }
  108 +
  109 + return navType;
  110 +}
  111 +
85 /** 112 /**
86 * 筛选注册的回调,筛选子项点击后逻辑 113 * 筛选注册的回调,筛选子项点击后逻辑
87 * 需要执行search的场景:1.点选筛选项;2.relaod为true时切换导航;3.下拉加载 114 * 需要执行search的场景:1.点选筛选项;2.relaod为true时切换导航;3.下拉加载
@@ -89,16 +116,22 @@ $.each($listNav.find('li'), function(key, item) { @@ -89,16 +116,22 @@ $.each($listNav.find('li'), function(key, item) {
89 */ 116 */
90 function search(opt) { 117 function search(opt) {
91 var setting = {}, 118 var setting = {},
92 - ext = [], 119 + ext = {},
93 att, 120 att,
94 nav, navType, 121 nav, navType,
95 page, 122 page,
96 i; 123 i;
97 124
  125 + delete defaultOpt.size;
  126 +
98 if (searching) { 127 if (searching) {
99 return; 128 return;
100 } 129 }
101 130
  131 + if ($.type(opt) === 'object') {
  132 + opt = [opt];
  133 + }
  134 +
102 if (opt) { 135 if (opt) {
103 136
104 // 筛选项变更则重置reload为true 137 // 筛选项变更则重置reload为true
@@ -150,21 +183,10 @@ function search(opt) { @@ -150,21 +183,10 @@ function search(opt) {
150 } 183 }
151 184
152 $.extend(defaultOpt, ext); // 扩展筛选项 185 $.extend(defaultOpt, ext); // 扩展筛选项
153 -  
154 - console.log(defaultOpt);  
155 } 186 }
156 187
157 -  
158 // 导航类别 188 // 导航类别
159 - if ($pre.hasClass('coat')) {  
160 - navType = 'coat';  
161 - } else if ($pre.hasClass('trouser')) {  
162 - navType = 'trouser';  
163 - } else if ($pre.hasClass('shoes')) {  
164 - navType = 'shoes';  
165 - } else {  
166 - navType = 'other';  
167 - } 189 + navType = judgeType($pre);
168 190
169 nav = navInfo[navType]; 191 nav = navInfo[navType];
170 page = nav.page + 1; 192 page = nav.page + 1;
@@ -177,8 +199,8 @@ function search(opt) { @@ -177,8 +199,8 @@ function search(opt) {
177 } 199 }
178 200
179 $.extend(setting, defaultOpt, { 201 $.extend(setting, defaultOpt, {
180 - type: navType,  
181 - order: nav.order, 202 + type: 'stock',
  203 + order: 0,
182 page: page 204 page: page
183 }); 205 });
184 206
@@ -208,7 +230,12 @@ function search(opt) { @@ -208,7 +230,12 @@ function search(opt) {
208 break; 230 break;
209 } 231 }
210 232
211 - if (data === ' ') { 233 + if ($container.hasClass('hide')) {
  234 + $container.siblings().addClass('hide');
  235 + $container.removeClass('hide');
  236 + }
  237 +
  238 + if (data === '') {
212 nav.end = true; 239 nav.end = true;
213 240
214 if (nav.reload) { 241 if (nav.reload) {
@@ -254,7 +281,9 @@ function search(opt) { @@ -254,7 +281,9 @@ function search(opt) {
254 $.ajax({ 281 $.ajax({
255 type: 'GET', 282 type: 'GET',
256 url: '/product/sale/filter', 283 url: '/product/sale/filter',
257 - data: defaultOpt, 284 + data: $.extend(defaultOpt, {
  285 + saleType: '1'
  286 + }),
258 success: function(data) { 287 success: function(data) {
259 $goodsContainer.append(data); 288 $goodsContainer.append(data);
260 289
@@ -266,6 +295,8 @@ $.ajax({ @@ -266,6 +295,8 @@ $.ajax({
266 // 切换active状态到$pre上 295 // 切换active状态到$pre上
267 $pre.addClass('active'); 296 $pre.addClass('active');
268 $pre.siblings('.filter').removeClass('active'); 297 $pre.siblings('.filter').removeClass('active');
  298 +
  299 + $('#size-swiper-' + $pre.index()).show();
269 }, 300 },
270 missStatus: true 301 missStatus: true
271 }); 302 });
@@ -282,11 +313,6 @@ $listNav.on('touchend touchcancel', function(e) { @@ -282,11 +313,6 @@ $listNav.on('touchend touchcancel', function(e) {
282 nav, sortId, navType, $active; 313 nav, sortId, navType, $active;
283 314
284 e.preventDefault(); 315 e.preventDefault();
285 -  
286 - if (typeof $this === 'undefined' || $this.length === 0) {  
287 - return;  
288 - }  
289 -  
290 if ($this.hasClass('filter')) { 316 if ($this.hasClass('filter')) {
291 317
292 // 筛选面板切换状态 318 // 筛选面板切换状态
@@ -298,30 +324,20 @@ $listNav.on('touchend touchcancel', function(e) { @@ -298,30 +324,20 @@ $listNav.on('touchend touchcancel', function(e) {
298 $this.removeClass('active'); 324 $this.removeClass('active');
299 } else { 325 } else {
300 $pre = $this.siblings('.active'); 326 $pre = $this.siblings('.active');
301 - 327 + $swiperSize.hide();
302 $pre.removeClass('active'); 328 $pre.removeClass('active');
303 $this.addClass('active'); 329 $this.addClass('active');
304 - $swiperSize.hide();  
305 -  
306 filter.showFilter(); 330 filter.showFilter();
307 } 331 }
308 } else { 332 } else {
309 - if ($this.hasClass('coat')) {  
310 - navType = 'coat';  
311 - } else if ($this.hasClass('trouser')) {  
312 - navType = 'trouser';  
313 - } else if ($this.hasClass('shoes')) {  
314 - navType = 'shoes';  
315 - } else {  
316 - navType = 'other';  
317 - } 333 +
  334 + // 导航类别
  335 + navType = judgeType($this);
318 336
319 nav = navInfo[navType]; 337 nav = navInfo[navType];
320 338
321 - if ($this.hasClass('active')) {  
322 - nav.reload = true;  
323 - return;  
324 - } else { 339 + if (!($this.hasClass('active'))) {
  340 +
325 $active = $this.siblings('.active'); 341 $active = $this.siblings('.active');
326 342
327 $pre = $this; // $pre为除筛选导航的其他导航项,若当前active的为筛选,则把$pre置为当前点击项 343 $pre = $this; // $pre为除筛选导航的其他导航项,若当前active的为筛选,则把$pre置为当前点击项
@@ -347,10 +363,16 @@ $listNav.on('touchend touchcancel', function(e) { @@ -347,10 +363,16 @@ $listNav.on('touchend touchcancel', function(e) {
347 case 'shoes': 363 case 'shoes':
348 $shoesgc.removeClass('hide'); 364 $shoesgc.removeClass('hide');
349 break; 365 break;
350 - default: 366 + case 'other':
351 $othergc.removeClass('hide'); 367 $othergc.removeClass('hide');
352 break; 368 break;
  369 + default:
  370 + break;
353 } 371 }
  372 +
  373 + // 重置筛选项
  374 + filter.resetFilter();
  375 + defaultOpt = $.extend({}, storeOpt);
354 } 376 }
355 377
356 $active.removeClass('active'); 378 $active.removeClass('active');
@@ -383,26 +405,17 @@ $swiperSize.on('touchend touchcancel', function(e) { @@ -383,26 +405,17 @@ $swiperSize.on('touchend touchcancel', function(e) {
383 return; 405 return;
384 } 406 }
385 407
386 - if ($parentType.hasClass('coat')) {  
387 - navType = 'coat';  
388 - } else if ($parentType.hasClass('trouser')) {  
389 - navType = 'trouser';  
390 - } else if ($parentType.hasClass('shoes')) {  
391 - navType = 'shoes';  
392 - } else {  
393 - navType = 'other';  
394 - } 408 + // 导航类别
  409 + navType = judgeType($parentType);
395 410
396 nav = navInfo[navType]; 411 nav = navInfo[navType];
397 412
398 if ($this.hasClass('active')) { 413 if ($this.hasClass('active')) {
399 - nav.reload = true;  
400 return; 414 return;
401 } else { 415 } else {
  416 + nav.reload = true;
402 $active = $this.siblings('.active'); 417 $active = $this.siblings('.active');
403 -  
404 - $pre = $this; // $pre为除筛选导航的其他导航项,若当前active的为筛选,则把$pre置为当前点击项  
405 - 418 + $pre = $parentType; // $pre为除筛选导航的其他导航项,若当前active的为筛选,则把$pre置为当前点击项
406 $active.removeClass('active'); 419 $active.removeClass('active');
407 $this.addClass('active'); 420 $this.addClass('active');
408 sortId = $parentType.data('id'); 421 sortId = $parentType.data('id');
@@ -11,10 +11,11 @@ var $ = require('yoho-jquery'), @@ -11,10 +11,11 @@ var $ = require('yoho-jquery'),
11 loading = require('../plugin/loading'); 11 loading = require('../plugin/loading');
12 12
13 var $goodsContainer = $('#goods-container'), 13 var $goodsContainer = $('#goods-container'),
14 - $goodsChildren = $goodsContainer.children(),  
15 - $ngc = $($goodsChildren.get(0)),  
16 - $pgc = $($goodsChildren.get(1)),  
17 - $dgc = $($goodsChildren.get(2)); 14 + $ngc = $($goodsContainer.find('.new-goods')),
  15 + $dgc = $($goodsContainer.find('.discount-goods')),
  16 + $pgc = $($goodsContainer.find('.price-goods')),
  17 + $agc = $($goodsContainer.find('.all-goods')),
  18 + $sgc = $($goodsContainer.find('.sale-goods'));
18 19
19 var winH = $(window).height(), 20 var winH = $(window).height(),
20 noResult = '<p class="no-result">未找到相关搜索结果</p>'; 21 noResult = '<p class="no-result">未找到相关搜索结果</p>';
@@ -26,6 +27,12 @@ var $listNav = $('#list-nav'), @@ -26,6 +27,12 @@ var $listNav = $('#list-nav'),
26 27
27 // 导航数据信息 28 // 导航数据信息
28 navInfo = { 29 navInfo = {
  30 + all: {
  31 + order: 1,
  32 + reload: true,
  33 + page: 0,
  34 + end: false
  35 + },
29 newest: { 36 newest: {
30 order: 1, 37 order: 1,
31 reload: true, 38 reload: true,
@@ -39,7 +46,13 @@ var $listNav = $('#list-nav'), @@ -39,7 +46,13 @@ var $listNav = $('#list-nav'),
39 end: false 46 end: false
40 }, 47 },
41 discount: { 48 discount: {
42 - order: 1, 49 + order: 0,
  50 + reload: true,
  51 + page: 0,
  52 + end: false
  53 + },
  54 + sale: {
  55 + order: 0,
43 reload: true, 56 reload: true,
44 page: 0, 57 page: 0,
45 end: false 58 end: false
@@ -55,6 +68,26 @@ ellipsis.init(); @@ -55,6 +68,26 @@ ellipsis.init();
55 68
56 lazyLoad($('img.lazy')); 69 lazyLoad($('img.lazy'));
57 70
  71 +
  72 +// 判断导航类型
  73 +function judgeType(dom) {
  74 + var navType;
  75 +
  76 + if (dom.hasClass('new')) {
  77 + navType = 'newest';
  78 + } else if (dom.hasClass('price')) {
  79 + navType = 'price';
  80 + } else if (dom.hasClass('discount')) {
  81 + navType = 'discount';
  82 + } else if (dom.hasClass('sale')) {
  83 + navType = 'sale';
  84 + } else if (dom.hasClass('all')) {
  85 + navType = 'all';
  86 + }
  87 +
  88 + return navType;
  89 +}
  90 +
58 /** 91 /**
59 * 筛选注册的回调,筛选子项点击后逻辑 92 * 筛选注册的回调,筛选子项点击后逻辑
60 * 需要执行search的场景:1.点选筛选项;2.relaod为true时切换导航;3.下拉加载 93 * 需要执行search的场景:1.点选筛选项;2.relaod为true时切换导航;3.下拉加载
@@ -127,15 +160,8 @@ function search(opt) { @@ -127,15 +160,8 @@ function search(opt) {
127 $.extend(defaultOpt, ext); // 扩展筛选项 160 $.extend(defaultOpt, ext); // 扩展筛选项
128 } 161 }
129 162
130 -  
131 // 导航类别 163 // 导航类别
132 - if ($pre.hasClass('new')) {  
133 - navType = 'newest';  
134 - } else if ($pre.hasClass('price')) {  
135 - navType = 'price';  
136 - } else if ($pre.hasClass('discount')) {  
137 - navType = 'discount';  
138 - } 164 + navType = judgeType($pre);
139 165
140 nav = navInfo[navType]; 166 nav = navInfo[navType];
141 page = nav.page + 1; 167 page = nav.page + 1;
@@ -180,11 +206,22 @@ function search(opt) { @@ -180,11 +206,22 @@ function search(opt) {
180 case 'discount': 206 case 'discount':
181 $container = $dgc; 207 $container = $dgc;
182 break; 208 break;
  209 + case 'sale':
  210 + $container = $sgc;
  211 + break;
  212 + case 'all':
  213 + $container = $agc;
  214 + break;
183 default: 215 default:
184 break; 216 break;
185 } 217 }
186 218
187 - if (data === ' ') { 219 + if ($container.hasClass('hide')) {
  220 + $container.siblings().addClass('hide');
  221 + $container.removeClass('hide');
  222 + }
  223 +
  224 + if (data === '') {
188 nav.end = true; 225 nav.end = true;
189 226
190 if (nav.reload) { 227 if (nav.reload) {
@@ -290,20 +327,15 @@ $listNav.on('touchend touchcancel', function(e) { @@ -290,20 +327,15 @@ $listNav.on('touchend touchcancel', function(e) {
290 } 327 }
291 } else { 328 } else {
292 329
293 - if ($this.hasClass('new')) {  
294 - navType = 'newest';  
295 - } else if ($this.hasClass('price')) {  
296 - navType = 'price';  
297 - } else if ($this.hasClass('discount')) {  
298 - navType = 'discount';  
299 - } 330 + // 导航类别
  331 + navType = judgeType($this);
300 332
301 nav = navInfo[navType]; 333 nav = navInfo[navType];
302 334
303 if ($this.hasClass('active')) { 335 if ($this.hasClass('active')) {
304 336
305 // 最新无排序切换 337 // 最新无排序切换
306 - if ($this.hasClass('new')) { 338 + if ($this.hasClass('new') || $this.hasClass('sale') || $this.hasClass('all')) {
307 return; 339 return;
308 } 340 }
309 341
@@ -341,6 +373,14 @@ $listNav.on('touchend touchcancel', function(e) { @@ -341,6 +373,14 @@ $listNav.on('touchend touchcancel', function(e) {
341 case 'discount': 373 case 'discount':
342 $dgc.removeClass('hide'); 374 $dgc.removeClass('hide');
343 break; 375 break;
  376 +
  377 + case 'sale':
  378 + $sgc.removeClass('hide');
  379 + break;
  380 +
  381 + case 'all':
  382 + $agc.removeClass('hide');
  383 + break;
344 default: 384 default:
345 break; 385 break;
346 } 386 }
@@ -32,20 +32,22 @@ function getRTime() { @@ -32,20 +32,22 @@ function getRTime() {
32 h = Math.floor(endTime / anHour % 24); 32 h = Math.floor(endTime / anHour % 24);
33 m = Math.floor(endTime / aMinute % 60); 33 m = Math.floor(endTime / aMinute % 60);
34 s = Math.floor(endTime / aSecond % 60); 34 s = Math.floor(endTime / aSecond % 60);
35 - }  
36 35
37 - showTime += d > 0 ? d + '天' : '';  
38 - showTime += h > 0 ? h + '小时' : '';  
39 - showTime += m > 0 ? m + '分钟' : '';  
40 - showTime += s > 0 ? s + '秒' : ''; 36 + showTime += d > 0 ? d + '天' : '';
  37 + showTime += h > 0 ? h + '小时' : '';
  38 + showTime += m > 0 ? m + '分钟' : '';
  39 + showTime += s > 0 ? s + '秒' : '';
41 40
42 - if (showTime.length !== '') {  
43 - showTime = '剩' + showTime;  
44 - } 41 + if (showTime.length !== '') {
  42 + showTime = '剩' + showTime;
  43 + }
45 44
46 - $activityTime.find('span').html(showTime); 45 + $activityTime.find('span').html(showTime);
47 46
48 - $activityTime.attr('data-time-ms', endTime); 47 + $activityTime.attr('data-time-ms', endTime);
  48 + } else {
  49 + $activityTime.hide();
  50 + }
49 } 51 }
50 52
51 setInterval(getRTime, 1000); 53 setInterval(getRTime, 1000);
@@ -48,9 +48,10 @@ @@ -48,9 +48,10 @@
48 width: 20%; 48 width: 20%;
49 font-size: 28px; 49 font-size: 28px;
50 50
51 - &.active a {  
52 - border-bottom: 4px solid #000;  
53 - } 51 + /* &.active a {
  52 + border-bottom: 4px solid #000;
  53 + }
  54 + */
54 55
55 a { 56 a {
56 width: 106px; 57 width: 106px;
@@ -3,13 +3,17 @@ @@ -3,13 +3,17 @@
3 3
4 .swiper-container { 4 .swiper-container {
5 width: 100%; 5 width: 100%;
6 - height: 310px; 6 + height: 240px;
7 7
8 img { 8 img {
9 height: 100%; 9 height: 100%;
10 width: 100%; 10 width: 100%;
11 } 11 }
12 12
  13 + ul {
  14 + height: 240px;
  15 + }
  16 +
13 .swiper-pagination { 17 .swiper-pagination {
14 bottom: 0; 18 bottom: 0;
15 left: 0; 19 left: 0;
1 -.filter-mask, .filter-body { 1 +.filter-mask,
  2 +.filter-body {
2 position: absolute; 3 position: absolute;
3 left: 0; 4 left: 0;
4 right: 0; 5 right: 0;
@@ -7,7 +8,7 @@ @@ -7,7 +8,7 @@
7 8
8 .filter-mask { 9 .filter-mask {
9 height: 100%; 10 height: 100%;
10 - background: rgba(0,0,0,0.1); 11 + background: rgba(0, 0, 0, 0.1);
11 } 12 }
12 13
13 .filter-body { 14 .filter-body {
@@ -70,7 +71,7 @@ @@ -70,7 +71,7 @@
70 -webkit-overflow-scrolling: touch; 71 -webkit-overflow-scrolling: touch;
71 72
72 > li { 73 > li {
73 - height: 160px; 74 + height: 120px;
74 line-height: 120px; 75 line-height: 120px;
75 padding-left: 30px; 76 padding-left: 30px;
76 border-bottom: 1px solid #e6e6e6; 77 border-bottom: 1px solid #e6e6e6;
@@ -31,3 +31,9 @@ @@ -31,3 +31,9 @@
31 } 31 }
32 } 32 }
33 } 33 }
  34 +
  35 +.sale-vip-page {
  36 + .good-info {
  37 + height: 570px;
  38 + }
  39 +}
  1 +'use strict';
  2 +const _ = require('lodash');
  3 +const camelCase = require('../library/camel-case');
  4 +const helpers = require('../library/helpers');
  5 +
  6 +/**
  7 + * 根据性别来决定 默认图片获取字段 如果是 2、3
  8 + *
  9 + * 则优先从cover2 --》 cover1 -- 》 images_url
  10 + * 否则优先从cover1 --》 cover2 -- 》 images_url
  11 + *
  12 + */
  13 +const procProductImg = (product, gender) => {
  14 + if (gender === '2,3') {
  15 + return product.cover2 || product.cover1 || product.imagesUrl || '';
  16 + }
  17 +
  18 + return product.cover1 || product.cover2 || product.imagesUrl || '';
  19 +};
  20 +
  21 +
  22 +/**
  23 + * 商品搜索商品数据处理
  24 + */
  25 +exports.processProductList = (list, options) => {
  26 + const pruductList = [];
  27 +
  28 + options = Object.assign({
  29 + showTags: true,
  30 + showNew: true,
  31 + showSale: true,
  32 + width: 290,
  33 + height: 388,
  34 + isApp: false,
  35 + showPoint: true,
  36 + gender: '2,3'
  37 + }, options);
  38 + list = camelCase(list);
  39 +
  40 + _.forEach(list, (product) => {
  41 + // 商品信息有问题,则不显示
  42 + if (!product.productId || !product.goodsList.length) {
  43 + return;
  44 + }
  45 +
  46 + // 市场价和售价一样,则不显示市场价
  47 + if (product.marketPrice === product.salesPrice) {
  48 + product.marketPrice = false;
  49 + }
  50 +
  51 + // 判别默认的商品是否将默认的图片URL赋值到skn
  52 + let flag = false;
  53 +
  54 + // 如果设置了默认图片,就取默认的图片
  55 + _.forEach(product.goodsList, (goods) => {
  56 + if (flag) {
  57 + return;
  58 + }
  59 + if (goods.isDefault === 'Y') {
  60 + product.defaultImages = procProductImg(goods);
  61 + flag = true;
  62 + }
  63 + });
  64 +
  65 + // 如果还未赋值,则取第一个skc产品的默认图片
  66 + if (!flag) {
  67 + product.defaultImages = procProductImg(product.goodsList[0]);
  68 + }
  69 +
  70 + // product = Object.assign(product, {
  71 + // id: product.productSkn,
  72 + // thumb: product.defaultImages
  73 + // });
  74 +
  75 + if (options.showPoint) {
  76 + product.price += '.00';
  77 + product.salePrice += '.00';
  78 + }
  79 +
  80 + product.isSoonSoldOut = product.isSoonSoldOut === 'Y';
  81 + product.url = helpers.urlFormat(`/product/pro_${product.productId}_${product.goodsList[0].goodsId}/${product.cnAlphabet}.html`); // eslint-disable-line
  82 +
  83 + // APP访问需要加附加的参数
  84 + // 备注:如果以后APP的接口太多,可以把这边参数提取出来,变成一个公共的方法来生成,便于以后管理维护
  85 + if (options.isApp) {
  86 + product.url += `?openby:yohobuy={"action":"go.productDetail","params":{"product_skn":'${product.productId}'}}`; // eslint-disable-line
  87 + }
  88 +
  89 + if (options.showTags) {
  90 + product.tags = {};
  91 +
  92 + product.tags.isNew = options.showNew && product.isNew === 'Y'; // 新品
  93 + product.tags.isDiscount = options.showSale && product.isDiscount === 'Y'; // 在售
  94 + product.tags.isLimited = product.isLimited === 'Y'; // 限量
  95 + product.tags.isYohood = product.isYohood === 'Y'; // YOHOOD
  96 + product.tags.midYear = product.midYear === 'Y'; // 年中
  97 + product.tags.yearEnd = product.yearEnd === 'Y'; // 年末
  98 + product.tags.isAdvance = product.isAdvance === 'Y'; // 再到着
  99 +
  100 + // 打折与即将售完组合显示打折
  101 + if (product.isSoonSoldOut && product.tags.isDiscount) {
  102 + product.tags.isNew = false;
  103 + } else if (product.tags.isDiscount &&
  104 + (product.tags.isNew || product.tags.isLimited || product.tags.isYohood || product.tags.isAdvance)) {
  105 + // 打折与其它组合则隐藏打折
  106 + product.tags.isDiscount = false;
  107 + } else if (product.tags.isYohood && product.tags.isNew) {
  108 + // YOHOOD和新品组合显示YOHOOD
  109 + product.tags.isNew = false;
  110 + }
  111 + }
  112 +
  113 + pruductList.push(product);
  114 + });
  115 + return pruductList;
  116 +};
  117 +
  118 +
  119 +/**
  120 + * 处理筛选数据
  121 + * @param list
  122 + * @param string | options
  123 + * @return array 处理之后的筛选数据
  124 + */
  125 +exports.processFilter = (list, options) => {
  126 + const filters = {
  127 + classify: []
  128 + };
  129 +
  130 + const filtersType = {
  131 + brand: {
  132 + name: '所有品牌',
  133 + title: '品牌',
  134 + dataId: 'id',
  135 + subsName: 'brandName',
  136 + firstSub: 0,
  137 + dataType: 'brand'
  138 + },
  139 + color: {
  140 + name: '所有颜色',
  141 + title: '颜色',
  142 + dataId: 'colorId',
  143 + subsName: 'colorName',
  144 + firstSub: 0,
  145 + dataType: 'color'
  146 + },
  147 + discount: {
  148 + name: '所有商品',
  149 + title: '折扣',
  150 + dataId: 'key',
  151 + subsName: 'name',
  152 + firstSub: '0.1,0.9',
  153 + dataType: 'discount'
  154 + },
  155 + gender: {
  156 + name: '所有性别',
  157 + title: '性别',
  158 + dataId: 'key',
  159 + subsName: 'flag',
  160 + firstSub: '1,2,3',
  161 + dataType: 'gender'
  162 + },
  163 + groupSort: {
  164 + name: '所有品类',
  165 + title: '品类',
  166 + dataId: 'relationParameter',
  167 + subsName: 'categoryName',
  168 + firstSub: 0,
  169 + dataType: 'sort'
  170 + },
  171 + priceRange: {
  172 + name: '所有价格',
  173 + title: '价格',
  174 + dataId: 'key',
  175 + subsName: 'flag',
  176 + firstSub: 0,
  177 + dataType: 'price'
  178 + },
  179 + size: {
  180 + name: '所有尺码',
  181 + title: '尺码',
  182 + dataId: 'sizeId',
  183 + subsName: 'sizeName',
  184 + firstSub: 0,
  185 + dataType: 'size'
  186 + }
  187 + };
  188 +
  189 + options = Object.assign({
  190 + gender: '1,2,3', // 默认选择的性别,默认1,2,3表示所有
  191 + exclude: null // 需要排除的字段
  192 + }, options);
  193 + list = camelCase(list);
  194 +
  195 + _.forEach(list, (item, key) => {
  196 + let classify = {
  197 + subs: []
  198 + };
  199 +
  200 + if (key === 'group_sort') {
  201 + return;
  202 + }
  203 +
  204 + if ((options.hideSize && key === 'size') || (options.hideSort && key === 'groupSort')) {
  205 + return;
  206 + }
  207 +
  208 + classify.dataType = filtersType[key].dataType;
  209 + classify.name = filtersType[key].name;
  210 + classify.title = filtersType[key].title;
  211 +
  212 + classify.subs.push({
  213 + chosed: true,
  214 + dataId: filtersType[key].firstSub,
  215 + name: filtersType[key].name
  216 + });
  217 +
  218 + _.forEach(item, (sub, index) => {
  219 + let subs = {};
  220 +
  221 + if (filtersType[key].dataId === 'key') {
  222 + subs.dataId = index;
  223 + } else if (filtersType[key].dataId === 'relationParameter') {
  224 + subs.dataId = sub.relationParameter['sort']; // eslint-disable-line
  225 + } else {
  226 + subs.dataId = sub[filtersType[key].dataId];
  227 + }
  228 +
  229 + if (filtersType[key].subsName === 'flag') {
  230 + subs.name = sub;
  231 + } else {
  232 + subs.name = sub[filtersType[key].subsName];
  233 +
  234 + if (key === 'discount') {
  235 + subs.name = subs.name + '折商品';
  236 + }
  237 + }
  238 + classify.subs.push(subs);
  239 + });
  240 +
  241 + filters.classify.push(classify);
  242 + });
  243 +
  244 + return filters;
  245 +};