Authored by ccbikai

Merge branch 'feature/sale' into release/4.8

@@ -7,7 +7,7 @@ @@ -7,7 +7,7 @@
7 7
8 {{# activity}} 8 {{# activity}}
9 <img src="{{image coverUrl 640 200}}"/> 9 <img src="{{image coverUrl 640 200}}"/>
10 - <p class="activity-time" data-time-ms="{{leftTime}}"><i class="iconfont time-ico">&#xe603;</i><span></span></p> 10 + <p class="activity-time" data-time-s="{{leftTime}}"><i class="iconfont time-ico">&#xe603;</i><span></span></p>
11 {{/ activity}} 11 {{/ activity}}
12 12
13 </div> 13 </div>
@@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
5 <ul class="discount-list"> 5 <ul class="discount-list">
6 {{#list}} 6 {{#list}}
7 <li> 7 <li>
8 - <a href="/product/sale/discount/detail?id={{id}}"> 8 + <a href="/product/sale/discount/detail?id={{id}}&channel={{@root.channel}}">
9 <img class="lazy" data-original="{{image coverUrl 640 250}}" /> 9 <img class="lazy" data-original="{{image coverUrl 640 250}}" />
10 <p class="discount-cont"> 10 <p class="discount-cont">
11 <span class="discount-title">{{title}}</span> 11 <span class="discount-title">{{title}}</span>
@@ -2,6 +2,5 @@ @@ -2,6 +2,5 @@
2 {{> common/floor-header-more}} 2 {{> common/floor-header-more}}
3 {{> resources/banner-top}} 3 {{> resources/banner-top}}
4 {{/data}} 4 {{/data}}
5 -<div class="vip-floor clearfix">  
6 - 5 +<div class="vip-floor clearfix" data-id={{data.title.productPoolId}}>
7 </div> 6 </div>
@@ -7,7 +7,7 @@ @@ -7,7 +7,7 @@
7 var $ = require('yoho-jquery'); 7 var $ = require('yoho-jquery');
8 8
9 var $activityTime = $('.activity-time'), 9 var $activityTime = $('.activity-time'),
10 - endTime = $activityTime ? $activityTime.data('time-ms') : ''; 10 + endTime = $activityTime ? $activityTime.data('time-s') : '';
11 11
12 var params = { 12 var params = {
13 anHour: 3600, // 1小时=?秒 13 anHour: 3600, // 1小时=?秒
@@ -14,5 +14,3 @@ search.start(); @@ -14,5 +14,3 @@ search.start();
14 lazyLoad($('img.lazy')); 14 lazyLoad($('img.lazy'));
15 15
16 countDown(); 16 countDown();
17 -  
18 -  
@@ -52,7 +52,7 @@ $(function() { @@ -52,7 +52,7 @@ $(function() {
52 data: { 52 data: {
53 yh_channel: window.queryString.channel || 'boys', 53 yh_channel: window.queryString.channel || 'boys',
54 saleType: '2', 54 saleType: '2',
55 - type: 'newest', 55 + productPool: $vipFloor.data('id'),
56 order: '0', 56 order: '0',
57 limit: '4' 57 limit: '4'
58 } 58 }
1 'use strict'; 1 'use strict';
  2 +require('../app');
2 const _ = require('lodash'); 3 const _ = require('lodash');
3 const camelCase = global.yoho.camelCase; 4 const camelCase = global.yoho.camelCase;
4 const helpers = global.yoho.helpers; 5 const helpers = global.yoho.helpers;
@@ -10,7 +11,7 @@ const helpers = global.yoho.helpers; @@ -10,7 +11,7 @@ const helpers = global.yoho.helpers;
10 * 否则优先从cover1 --》 cover2 -- 》 images_url 11 * 否则优先从cover1 --》 cover2 -- 》 images_url
11 * 12 *
12 */ 13 */
13 -const procProductImg = (product, gender, yhChannel) => { 14 +const _procProductImg = (product, gender, yhChannel) => {
14 if (gender === '2,3' || gender === '2' || gender === '3' && yhChannel === '2') { 15 if (gender === '2,3' || gender === '2' || gender === '3' && yhChannel === '2') {
15 return product.cover2 || product.imagesUrl || product.cover1 || ''; 16 return product.cover2 || product.imagesUrl || product.cover1 || '';
16 } 17 }
@@ -18,6 +19,23 @@ const procProductImg = (product, gender, yhChannel) => { @@ -18,6 +19,23 @@ const procProductImg = (product, gender, yhChannel) => {
18 return product.cover1 || product.imagesUrl || product.cover2 || ''; 19 return product.cover1 || product.imagesUrl || product.cover2 || '';
19 }; 20 };
20 21
  22 +/**
  23 + * 按照数组中指定字段排序二维数组
  24 + *
  25 + * @param array list 需要排序的数组
  26 + * @param string key 字段名称
  27 + * @param boolean 有 desc 时候降序排列,默认为false
  28 + */
  29 +const _sortListByField = (list, key, desc) => {
  30 + list = _.toArray(list);
  31 + list = list.sort((a, b) => {
  32 + if (a[key] && b[key]) {
  33 + return (desc ? a[key] > b[key] : a[key] < b[key]) ? -1 : 1;
  34 + }
  35 + return (desc ? a > b : a < b) ? -1 : 1;
  36 + });
  37 + return list;
  38 +};
21 39
22 /** 40 /**
23 * 商品搜索商品数据处理 41 * 商品搜索商品数据处理
@@ -70,7 +88,7 @@ exports.processProductList = (list, options) => { @@ -70,7 +88,7 @@ exports.processProductList = (list, options) => {
70 88
71 // 如果还未赋值,则取第一个skc产品的默认图片 89 // 如果还未赋值,则取第一个skc产品的默认图片
72 if (!flag) { 90 if (!flag) {
73 - product.defaultImages = procProductImg(product.goodsList[0], product.gender, options.yh_channel); 91 + product.defaultImages = _procProductImg(product.goodsList[0], product.gender, options.yh_channel);
74 } 92 }
75 93
76 product.isSoonSoldOut = product.isSoonSoldOut === 'Y'; 94 product.isSoonSoldOut = product.isSoonSoldOut === 'Y';
@@ -228,6 +246,11 @@ exports.processFilter = (list, options) => { @@ -228,6 +246,11 @@ exports.processFilter = (list, options) => {
228 name: filtersType[key].name 246 name: filtersType[key].name
229 }); 247 });
230 248
  249 + // 折扣,价格区间,需要排序
  250 + if (key === 'discount' || key === 'priceRange') {
  251 + item = _sortListByField(item, 'name');
  252 + }
  253 +
231 _.forEach(item, (sub, index) => { 254 _.forEach(item, (sub, index) => {
232 let subs = {}; 255 let subs = {};
233 256
@@ -253,6 +276,5 @@ exports.processFilter = (list, options) => { @@ -253,6 +276,5 @@ exports.processFilter = (list, options) => {
253 276
254 filters.classify[filtersType[key].sortNum] = classify; 277 filters.classify[filtersType[key].sortNum] = classify;
255 }); 278 });
256 -  
257 return filters; 279 return filters;
258 }; 280 };
@@ -13,7 +13,6 @@ module.exports = (list) => { @@ -13,7 +13,6 @@ module.exports = (list) => {
13 list = list || []; 13 list = list || [];
14 list = camelCase(list); 14 list = camelCase(list);
15 15
16 -  
17 _.forEach(list, (floor) => { 16 _.forEach(list, (floor) => {
18 floor[_.camelCase(floor.templateName)] = true; 17 floor[_.camelCase(floor.templateName)] = true;
19 18
@@ -21,7 +21,7 @@ const anHour = 3600; @@ -21,7 +21,7 @@ const anHour = 3600;
21 const aDay = anHour * 24; 21 const aDay = anHour * 24;
22 22
23 /** 23 /**
24 - * 折扣专场专题列表过期时间处理 24 + * 折扣专场专题列表过期时间处理 单位:s
25 * @param {[string]} time 25 * @param {[string]} time
26 * @return {[object]} 26 * @return {[object]}
27 */ 27 */