Authored by ccbikai

Merge branch 'feature/sale' into develop

... ... @@ -13,6 +13,15 @@ const headerModel = require('../../../doraemon/models/header');
const log = require(`${library}/logger`);
const saleModel = require(`${mRoot}/sale`);
// const queryParam = {
// brand: '0',
// gender: '1,2,3',
// sort: '0',
// size: '0',
// price: '0',
// discount: '0.1,0.9'
// };
const saleLogger = (err, res) => {
log.error('sale页面渲染错误:' + JSON.stringify(err));
res.send('error');
... ... @@ -140,12 +149,16 @@ exports.filter = (req, res) => {
exports.search = (req, res) => {
let params = Object.assign({}, req.query);
let uid = req.user.uid || 0;
saleModel.getSearchData(params, uid).then((result) => {
let vipLevel = result[1].curLevel;
saleModel.getSearchData(params).then((result) => {
res.render('product', {
layout: false,
params: params,
goods: result
goods: result[0],
saleVip: (req.query.saleType === '2' && (!uid || vipLevel === '1'))
});
});
};
... ...
... ... @@ -13,6 +13,7 @@ const logger = require(`${library}/logger`);
const helpers = require(`${library}/helpers`);
const camelCase = require(`${library}/camel-case`);
const resourcesProcess = require(`${utils}/resources-process`);
const productProcess = require(`${utils}/product-process`);
const _ = require('lodash');
const api = new API();
const serviceAPI = new ServiceAPI();
... ... @@ -34,8 +35,9 @@ const timeFormat = {
const typeCont = {
price: ['s_p_desc', 's_p_asc'],
discount: ['p_d_desc', 'p_d_asc'],
sales: ['s_n_desc', 's_n_asc'],
newest: ['s_t_desc', 's_t_asc']
sale: ['s_n_desc', 's_n_asc'],
newest: ['s_t_desc', 's_t_asc'],
stock: ['s_s_desc', 's_s_asc']
};
/**
... ... @@ -129,141 +131,6 @@ const special = (params) => {
};
/**
* 根据性别来决定 默认图片获取字段 如果是 2、3
*
* 则优先从cover2 --》 cover1 -- 》 images_url
* 否则优先从cover1 --》 cover2 -- 》 images_url
*
*/
const procProductImg = (product, gender) => {
if (gender === '2,3') {
return product.cover2 || product.cover1 || product.imagesUrl || '';
}
return product.cover1 || product.cover2 || product.imagesUrl || '';
};
/**
* 商品搜索商品数据处理
*/
const processProductList = (list, options) => {
const pruductList = [];
options = Object.assign({
showTags: true,
showNew: true,
showSale: true,
width: 290,
height: 388,
isApp: false,
showPoint: true,
gender: '2,3'
}, options);
list = camelCase(list);
_.forEach(list, (product) => {
// 商品信息有问题,则不显示
if (!product.productId || !product.goodsList.length) {
return;
}
// 市场价和售价一样,则不显示市场价
if (product.marketPrice === product.salesPrice) {
product.marketPrice = false;
}
// 判别默认的商品是否将默认的图片URL赋值到skn
let flag = false;
// 如果设置了默认图片,就取默认的图片
_.forEach(product.goodsList, (goods) => {
if (flag) {
return;
}
if (goods.isDefault === 'Y') {
product.defaultImages = procProductImg(goods);
flag = true;
}
});
// 如果还未赋值,则取第一个skc产品的默认图片
if (!flag) {
product.defaultImages = procProductImg(product.goodsList[0]);
}
// product = Object.assign(product, {
// id: product.productSkn,
// thumb: product.defaultImages
// });
if (options.showPoint) {
product.price += '.00';
product.salePrice += '.00';
}
product.isSoonSoldOut = product.isSoonSoldOut === 'Y';
product.url = helpers.urlFormat(`/product/pro_${product.productId}_${product.goodsList[0].goodsId}/${product.cnAlphabet}.html`); // eslint-disable-line
// APP访问需要加附加的参数
// 备注:如果以后APP的接口太多,可以把这边参数提取出来,变成一个公共的方法来生成,便于以后管理维护
if (options.isApp) {
product.url += `?openby:yohobuy={"action":"go.productDetail","params":{"product_skn":'${product.productId}'}}`; // eslint-disable-line
}
if (options.showTags) {
product.tags = {};
product.tags.isNew = options.showNew && product.isNew === 'Y'; // 新品
product.tags.isDiscount = options.showSale && product.isDiscount === 'Y'; // 在售
product.tags.isLimited = product.isLimited === 'Y'; // 限量
product.tags.isYohood = product.isYohood === 'Y'; // YOHOOD
product.tags.midYear = product.midYear === 'Y'; // 年中
product.tags.yearEnd = product.yearEnd === 'Y'; // 年末
product.tags.isAdvance = product.isAdvance === 'Y'; // 再到着
// 打折与即将售完组合显示打折
if (product.isSoonSoldOut && product.tags.isDiscount) {
product.tags.isNew = false;
} else if (product.tags.isDiscount &&
(product.tags.isNew || product.tags.isLimited || product.tags.isYohood || product.tags.isAdvance)) {
// 打折与其它组合则隐藏打折
product.tags.isDiscount = false;
} else if (product.tags.isYohood && product.tags.isNew) {
// YOHOOD和新品组合显示YOHOOD
product.tags.isNew = false;
}
}
pruductList.push(product);
});
return pruductList;
};
/**
* 处理筛选数据
* @param list
* @param string | options
* @return array 处理之后的筛选数据
*/
const processFilter = (list, options) => {
const filters = {
classify: {}
};
options = Object.assign({
gender: '1,2,3', // 默认选择的性别,默认1,2,3表示所有
exclude: null // 需要排除的字段
}, options);
list = camelCase(list);
_.forEach(list, (item, key) => {
console.log(key);
});
return filters;
};
/**
* 断码区分类数据处理
*/
const processBreakingSort = (list) => {
... ... @@ -293,12 +160,13 @@ const processBreakingSort = (list) => {
*/
const searchSales = (params) => {
params = Object.assign({
limit: '20'
limit: '50'
}, params);
if (typeCont[params.type]) {
params.order = typeCont[params.type][params.order];
}
return api.get('', sign.apiSign(Object.assign({
method: 'app.search.sales'
}, params)), true);
... ... @@ -310,7 +178,10 @@ const searchSales = (params) => {
exports.getFilterData = (params) => {
return searchSales(params).then((result) => {
if (result && result.code === 200) {
return processFilter(result.data.filter || []);
return productProcess.processFilter(result.data.filter || [], {
hideSize: params.saleType === '1',
hideSort: params.saleType === '1'
});
} else {
logger.error('SALE 商品搜索返回 code 不是 200');
return [];
... ... @@ -318,18 +189,41 @@ exports.getFilterData = (params) => {
});
};
const getUserProfile = (uid) => {
if (!uid) {
return Promise.resolve({
code: 200,
data: {}
});
}
return api.get('', sign.apiSign({
method: 'app.passport.profile',
uid: uid
}), true);
};
/**
* 获取商品数据
*/
exports.getSearchData = (params) => {
return searchSales(params).then((result) => {
if (result && result.code === 200) {
return processProductList(result.data.product_list || []);
} else {
logger.error('SALE 商品搜索返回 code 不是 200');
return {};
}
});
exports.getSearchData = (params, uid) => {
return Promise.all([
searchSales(params).then((result) => {
if (result && result.code === 200) {
return productProcess.processProductList(result.data.product_list || []);
} else {
logger.error('SALE 商品搜索返回 code 不是 200');
return [];
}
}),
getUserProfile(uid).then((result) => {
if (result && result.code === 200) {
return result.data.vip_info ? camelCase(result.data.vip_info) : {};
} else {
logger.error('获取用户信息返回 code 不是 200');
return {};
}
})
]);
};
/**
... ...
... ... @@ -16,7 +16,6 @@
<li class="new active">
<a href="javascript:void(0);">
<span class="span-test">最新</span>
<span class="iconfont cur">&#xe616;</span>
</a>
</li>
<li class="price">
... ... @@ -45,19 +44,5 @@
</li>
</ul>
<div id="goods-container" class="goods-container">
<div class="new-goods container clearfix">
{{# goods}}
{{> common/goods}}
{{/ goods}}
</div>
<div class="price-goods container hide clearfix"></div>
<div class="discount-goods container hide clearfix"></div>
{{> common/filter}}
</div>
{{> common/query-param}}
{{> common/suspend-cart}}
{{> product/sale-common}}
</div>
... ...
<div class="sale-channel-page discount-page yoho-page">
{{> product/sale-banner}}
<ul id="list-nav" class="list-nav clearfix">
<li class="all active">
<a href="javascript:void(0);">
<span class="span-test">全部</span>
</a>
</li>
<li class="price">
<a href="javascript:void(0);">
<span class="span-test">价格</span>
<span class="icon">
<i class="iconfont up cur">&#xe615;</i>
<i class="iconfont down">&#xe616;</i>
</span>
</a>
</li>
<li class="discount">
<a href="javascript:void(0);">
<span class="span-test">折扣</span>
<span class="icon">
<i class="iconfont up cur">&#xe615;</i>
<i class="iconfont down">&#xe616;</i>
</span>
</a>
</li>
<li class="filter">
<a href="javascript:void(0);">
<span class="span-test">筛选</span>
<span class="iconfont cur">&#xe613;</span>
</a>
</li>
</ul>
{{> product/sale-common}}
</div>
\ No newline at end of file
... ...
<div class="sale-vip-page discount-page yoho-page">
{{> product/sale-banner}}
<ul id="list-nav" class="list-nav clearfix">
<li class="new active">
<a href="javascript:void(0);">
<span class="span-test">最新</span>
</a>
</li>
<li class="price">
<a href="javascript:void(0);">
<span class="span-test">价格</span>
<span class="icon">
<i class="iconfont up cur">&#xe615;</i>
<i class="iconfont down">&#xe616;</i>
</span>
</a>
</li>
<li class="sale">
<a href="javascript:void(0);">
<span class="span-test">销量</span>
</a>
</li>
<li class="filter">
<a href="javascript:void(0);">
<span class="span-test">筛选</span>
<span class="iconfont cur">&#xe613;</span>
</a>
</li>
</ul>
{{> product/sale-common}}
</div>
\ No newline at end of file
... ...
<div class="banner">
{{#content}}
{{! 头部banner}}
{{#if focus}}
{{> resources/banner-top}}
{{/if}}
{{/content}}
{{# activity}}
<img src="{{image coverUrl 640 250}}"/>
<p class="activity-time" data-time-ms="{{leftTime}}"><i class="iconfont time-ico">&#xe603;</i><span>{{time}}</span></p>
{{/ activity}}
</div>
\ No newline at end of file
... ...
<div class="banner">
{{#content}}
{{! 头部banner}}
{{#if focus}}
{{> resources/banner-top}}
{{/if}}
{{/content}}
{{# activity}}
<img src="{{image coverUrl 640 250}}"/>
<p class="activity-time" data-time-ms="{{leftTime}}"><i class="iconfont time-ico">&#xe603;</i><span>{{time}}</span></p>
{{/ activity}}
</div>
<ul id="list-nav" class="list-nav clearfix">
<li class="new active">
<a href="javascript:void(0);">
<span class="span-test">最新</span>
<span class="iconfont cur">&#xe616;</span>
</a>
</li>
<li class="price">
<a href="javascript:void(0);">
<span class="span-test">价格</span>
<span class="icon">
<i class="iconfont up cur">&#xe615;</i>
<i class="iconfont down">&#xe616;</i>
</span>
</a>
</li>
<li class="discount">
<a href="javascript:void(0);">
<span class="span-test">折扣</span>
<span class="icon">
<i class="iconfont up cur">&#xe615;</i>
<i class="iconfont down">&#xe616;</i>
</span>
</a>
</li>
<li class="filter">
<a href="javascript:void(0);">
<span class="span-test">筛选</span>
<span class="iconfont cur">&#xe613;</span>
</a>
</li>
</ul>
<div id="goods-container" class="goods-container">
<div class="new-goods container clearfix">
{{# goods}}
... ... @@ -51,6 +6,8 @@
</div>
<div class="price-goods container hide clearfix"></div>
<div class="discount-goods container hide clearfix"></div>
<div class="all-goods container hide clearfix"></div>
<div class="sale-goods container hide clearfix"></div>
{{> common/filter}}
</div>
... ...
... ... @@ -13,7 +13,7 @@ module.exports = {
port: 6001,
siteUrl: 'http://m.yohobuy.com',
domains: {
api: 'http://testapi.yoho.cn:28078/',
api: 'http://api.open.yohobuy.com/', // http://192.168.102.205:8080/gateway http://testapi.yoho.cn:28078/
service: 'http://testservice.yoho.cn:28077/'
},
useOneapm: false,
... ...
{{#if .}} {{!-- 剔除值为false的项 --}}
{{#if this}} {{!-- 剔除值为false的项 --}}
<div class="good-info" data-id="{{productSkn}}" data-bp-id="guang_goodList_{{productName}}_false">
<div class="tag-container clearfix">
{{# tags}}
... ... @@ -12,7 +12,7 @@
<p class="good-tag sale-tag">SALE</p>
{{/ isDiscount}}
{{# isYohoood}}
<p class="good-tag running-man-tag">跑男同款</p>
<p class="good-tag running-man-tag">跑男同款</p>
{{/ isYohoood}}
{{# isLimited}}
<p class="good-tag limit-tag">限量商品</p>
... ... @@ -20,7 +20,7 @@
{{/ tags}}
</div>
<div class="good-detail-img">
<a class="good-thumb" href="{{url}}" data-img={{defaultImages}}>
<a class="good-thumb" href="{{url}}">
<img class="lazy" data-original="{{image defaultImages 235 314}}">
</a>
{{# isSoonSoldOut}}
... ... @@ -40,11 +40,11 @@
<span class="market-price">¥{{.}}</span>
{{/marketPrice}}
</div>
{{#if saleVip}}
{{#if @root.saleVip}}
<div class="vip-info">
<i class="vip-icon"></i>更优惠
</div>
{{/if}}
</div>
</div>
{{/if}}
\ No newline at end of file
{{/if}}
... ...
... ... @@ -13,7 +13,9 @@ let camelCase,
camelCaseObject = (obj) => {
_.forEach(Object.keys(obj), (k) => {
obj[k] = camelCase(obj[k]);
obj[_.camelCase(k)] = obj[k];
if (/[_-]/.test(k)) {
obj[_.camelCase(k)] = obj[k];
}
});
return obj;
};
... ...
... ... @@ -107,6 +107,10 @@ function subClassifyTapEvt($this) {
});
}
if (hCbFn) {
hCbFn();
}
hideFilter();
}
... ...
... ... @@ -25,34 +25,32 @@ var winH = $(window).height(),
// 默认筛选条件
var defaultOpt = require('./query-param');
var storeOpt = $.extend({}, defaultOpt);
var $listNav = $('#list-nav'),
$swiperSize = $('.swiper-size'),
// 导航数据信息
navInfo = {
coat: {
order: 1,
reload: true,
page: 0,
end: false,
saleType: 1
},
trouser: {
order: 1,
reload: true,
page: 0,
end: false,
saleType: 1
},
shoes: {
order: 1,
reload: true,
page: 0,
end: false,
saleType: 1
},
other: {
order: 1,
reload: true,
page: 0,
end: false,
... ... @@ -72,6 +70,18 @@ ellipsis.init();
lazyLoad($('img.lazy'));
if ($('.banner-swiper .swiper-slide').length > 1) {
new Swiper('.swiper-container', {
lazyLoading: true,
lazyLoadingInPrevNext: true,
loop: true,
autoplay: 3000,
autoplayDisableOnInteraction: true,
paginationClickable: true,
pagination: '.banner-top .pagination-inner'
});
}
$.each($swiperSize, function(key) {
swipers[key] = new Swiper('#size-swiper-' + key, {
slidesPerView: 'auto'
... ... @@ -82,6 +92,23 @@ $.each($listNav.find('li'), function(key, item) {
$(item).addClass(goodsType[key]);
});
// 判断导航类型
function judgeType(dom) {
var navType;
if (dom.hasClass('coat')) {
navType = 'coat';
} else if (dom.hasClass('trouser')) {
navType = 'trouser';
} else if (dom.hasClass('shoes')) {
navType = 'shoes';
} else {
navType = 'other';
}
return navType;
}
/**
* 筛选注册的回调,筛选子项点击后逻辑
* 需要执行search的场景:1.点选筛选项;2.relaod为true时切换导航;3.下拉加载
... ... @@ -89,16 +116,22 @@ $.each($listNav.find('li'), function(key, item) {
*/
function search(opt) {
var setting = {},
ext = [],
ext = {},
att,
nav, navType,
page,
i;
delete defaultOpt.size;
if (searching) {
return;
}
if ($.type(opt) === 'object') {
opt = [opt];
}
if (opt) {
// 筛选项变更则重置reload为true
... ... @@ -150,21 +183,10 @@ function search(opt) {
}
$.extend(defaultOpt, ext); // 扩展筛选项
console.log(defaultOpt);
}
// 导航类别
if ($pre.hasClass('coat')) {
navType = 'coat';
} else if ($pre.hasClass('trouser')) {
navType = 'trouser';
} else if ($pre.hasClass('shoes')) {
navType = 'shoes';
} else {
navType = 'other';
}
navType = judgeType($pre);
nav = navInfo[navType];
page = nav.page + 1;
... ... @@ -177,8 +199,8 @@ function search(opt) {
}
$.extend(setting, defaultOpt, {
type: navType,
order: nav.order,
type: 'stock',
order: 0,
page: page
});
... ... @@ -208,7 +230,12 @@ function search(opt) {
break;
}
if (data === ' ') {
if ($container.hasClass('hide')) {
$container.siblings().addClass('hide');
$container.removeClass('hide');
}
if (data === '') {
nav.end = true;
if (nav.reload) {
... ... @@ -254,7 +281,9 @@ function search(opt) {
$.ajax({
type: 'GET',
url: '/product/sale/filter',
data: defaultOpt,
data: $.extend(defaultOpt, {
saleType: '1'
}),
success: function(data) {
$goodsContainer.append(data);
... ... @@ -266,6 +295,8 @@ $.ajax({
// 切换active状态到$pre上
$pre.addClass('active');
$pre.siblings('.filter').removeClass('active');
$('#size-swiper-' + $pre.index()).show();
},
missStatus: true
});
... ... @@ -282,11 +313,6 @@ $listNav.on('touchend touchcancel', function(e) {
nav, sortId, navType, $active;
e.preventDefault();
if (typeof $this === 'undefined' || $this.length === 0) {
return;
}
if ($this.hasClass('filter')) {
// 筛选面板切换状态
... ... @@ -298,30 +324,20 @@ $listNav.on('touchend touchcancel', function(e) {
$this.removeClass('active');
} else {
$pre = $this.siblings('.active');
$swiperSize.hide();
$pre.removeClass('active');
$this.addClass('active');
$swiperSize.hide();
filter.showFilter();
}
} else {
if ($this.hasClass('coat')) {
navType = 'coat';
} else if ($this.hasClass('trouser')) {
navType = 'trouser';
} else if ($this.hasClass('shoes')) {
navType = 'shoes';
} else {
navType = 'other';
}
// 导航类别
navType = judgeType($this);
nav = navInfo[navType];
if ($this.hasClass('active')) {
nav.reload = true;
return;
} else {
if (!($this.hasClass('active'))) {
$active = $this.siblings('.active');
$pre = $this; // $pre为除筛选导航的其他导航项,若当前active的为筛选,则把$pre置为当前点击项
... ... @@ -347,10 +363,16 @@ $listNav.on('touchend touchcancel', function(e) {
case 'shoes':
$shoesgc.removeClass('hide');
break;
default:
case 'other':
$othergc.removeClass('hide');
break;
default:
break;
}
// 重置筛选项
filter.resetFilter();
defaultOpt = $.extend({}, storeOpt);
}
$active.removeClass('active');
... ... @@ -383,26 +405,17 @@ $swiperSize.on('touchend touchcancel', function(e) {
return;
}
if ($parentType.hasClass('coat')) {
navType = 'coat';
} else if ($parentType.hasClass('trouser')) {
navType = 'trouser';
} else if ($parentType.hasClass('shoes')) {
navType = 'shoes';
} else {
navType = 'other';
}
// 导航类别
navType = judgeType($parentType);
nav = navInfo[navType];
if ($this.hasClass('active')) {
nav.reload = true;
return;
} else {
nav.reload = true;
$active = $this.siblings('.active');
$pre = $this; // $pre为除筛选导航的其他导航项,若当前active的为筛选,则把$pre置为当前点击项
$pre = $parentType; // $pre为除筛选导航的其他导航项,若当前active的为筛选,则把$pre置为当前点击项
$active.removeClass('active');
$this.addClass('active');
sortId = $parentType.data('id');
... ...
... ... @@ -11,10 +11,11 @@ var $ = require('yoho-jquery'),
loading = require('../plugin/loading');
var $goodsContainer = $('#goods-container'),
$goodsChildren = $goodsContainer.children(),
$ngc = $($goodsChildren.get(0)),
$pgc = $($goodsChildren.get(1)),
$dgc = $($goodsChildren.get(2));
$ngc = $($goodsContainer.find('.new-goods')),
$dgc = $($goodsContainer.find('.discount-goods')),
$pgc = $($goodsContainer.find('.price-goods')),
$agc = $($goodsContainer.find('.all-goods')),
$sgc = $($goodsContainer.find('.sale-goods'));
var winH = $(window).height(),
noResult = '<p class="no-result">未找到相关搜索结果</p>';
... ... @@ -26,6 +27,12 @@ var $listNav = $('#list-nav'),
// 导航数据信息
navInfo = {
all: {
order: 1,
reload: true,
page: 0,
end: false
},
newest: {
order: 1,
reload: true,
... ... @@ -39,7 +46,13 @@ var $listNav = $('#list-nav'),
end: false
},
discount: {
order: 1,
order: 0,
reload: true,
page: 0,
end: false
},
sale: {
order: 0,
reload: true,
page: 0,
end: false
... ... @@ -55,6 +68,26 @@ ellipsis.init();
lazyLoad($('img.lazy'));
// 判断导航类型
function judgeType(dom) {
var navType;
if (dom.hasClass('new')) {
navType = 'newest';
} else if (dom.hasClass('price')) {
navType = 'price';
} else if (dom.hasClass('discount')) {
navType = 'discount';
} else if (dom.hasClass('sale')) {
navType = 'sale';
} else if (dom.hasClass('all')) {
navType = 'all';
}
return navType;
}
/**
* 筛选注册的回调,筛选子项点击后逻辑
* 需要执行search的场景:1.点选筛选项;2.relaod为true时切换导航;3.下拉加载
... ... @@ -127,15 +160,8 @@ function search(opt) {
$.extend(defaultOpt, ext); // 扩展筛选项
}
// 导航类别
if ($pre.hasClass('new')) {
navType = 'newest';
} else if ($pre.hasClass('price')) {
navType = 'price';
} else if ($pre.hasClass('discount')) {
navType = 'discount';
}
navType = judgeType($pre);
nav = navInfo[navType];
page = nav.page + 1;
... ... @@ -180,11 +206,22 @@ function search(opt) {
case 'discount':
$container = $dgc;
break;
case 'sale':
$container = $sgc;
break;
case 'all':
$container = $agc;
break;
default:
break;
}
if (data === ' ') {
if ($container.hasClass('hide')) {
$container.siblings().addClass('hide');
$container.removeClass('hide');
}
if (data === '') {
nav.end = true;
if (nav.reload) {
... ... @@ -290,20 +327,15 @@ $listNav.on('touchend touchcancel', function(e) {
}
} else {
if ($this.hasClass('new')) {
navType = 'newest';
} else if ($this.hasClass('price')) {
navType = 'price';
} else if ($this.hasClass('discount')) {
navType = 'discount';
}
// 导航类别
navType = judgeType($this);
nav = navInfo[navType];
if ($this.hasClass('active')) {
// 最新无排序切换
if ($this.hasClass('new')) {
if ($this.hasClass('new') || $this.hasClass('sale') || $this.hasClass('all')) {
return;
}
... ... @@ -341,6 +373,14 @@ $listNav.on('touchend touchcancel', function(e) {
case 'discount':
$dgc.removeClass('hide');
break;
case 'sale':
$sgc.removeClass('hide');
break;
case 'all':
$agc.removeClass('hide');
break;
default:
break;
}
... ...
... ... @@ -32,20 +32,22 @@ function getRTime() {
h = Math.floor(endTime / anHour % 24);
m = Math.floor(endTime / aMinute % 60);
s = Math.floor(endTime / aSecond % 60);
}
showTime += d > 0 ? d + '天' : '';
showTime += h > 0 ? h + '小时' : '';
showTime += m > 0 ? m + '分钟' : '';
showTime += s > 0 ? s + '秒' : '';
showTime += d > 0 ? d + '天' : '';
showTime += h > 0 ? h + '小时' : '';
showTime += m > 0 ? m + '分钟' : '';
showTime += s > 0 ? s + '秒' : '';
if (showTime.length !== '') {
showTime = '剩' + showTime;
}
if (showTime.length !== '') {
showTime = '剩' + showTime;
}
$activityTime.find('span').html(showTime);
$activityTime.find('span').html(showTime);
$activityTime.attr('data-time-ms', endTime);
$activityTime.attr('data-time-ms', endTime);
} else {
$activityTime.hide();
}
}
setInterval(getRTime, 1000);
... ...
... ... @@ -48,9 +48,10 @@
width: 20%;
font-size: 28px;
&.active a {
border-bottom: 4px solid #000;
}
/* &.active a {
border-bottom: 4px solid #000;
}
*/
a {
width: 106px;
... ...
... ... @@ -3,13 +3,17 @@
.swiper-container {
width: 100%;
height: 310px;
height: 240px;
img {
height: 100%;
width: 100%;
}
ul {
height: 240px;
}
.swiper-pagination {
bottom: 0;
left: 0;
... ...
.filter-mask, .filter-body {
.filter-mask,
.filter-body {
position: absolute;
left: 0;
right: 0;
... ... @@ -7,7 +8,7 @@
.filter-mask {
height: 100%;
background: rgba(0,0,0,0.1);
background: rgba(0, 0, 0, 0.1);
}
.filter-body {
... ... @@ -70,7 +71,7 @@
-webkit-overflow-scrolling: touch;
> li {
height: 160px;
height: 120px;
line-height: 120px;
padding-left: 30px;
border-bottom: 1px solid #e6e6e6;
... ...
... ... @@ -31,3 +31,9 @@
}
}
}
.sale-vip-page {
.good-info {
height: 570px;
}
}
... ...
'use strict';
const _ = require('lodash');
const camelCase = require('../library/camel-case');
const helpers = require('../library/helpers');
/**
* 根据性别来决定 默认图片获取字段 如果是 2、3
*
* 则优先从cover2 --》 cover1 -- 》 images_url
* 否则优先从cover1 --》 cover2 -- 》 images_url
*
*/
const procProductImg = (product, gender) => {
if (gender === '2,3') {
return product.cover2 || product.cover1 || product.imagesUrl || '';
}
return product.cover1 || product.cover2 || product.imagesUrl || '';
};
/**
* 商品搜索商品数据处理
*/
exports.processProductList = (list, options) => {
const pruductList = [];
options = Object.assign({
showTags: true,
showNew: true,
showSale: true,
width: 290,
height: 388,
isApp: false,
showPoint: true,
gender: '2,3'
}, options);
list = camelCase(list);
_.forEach(list, (product) => {
// 商品信息有问题,则不显示
if (!product.productId || !product.goodsList.length) {
return;
}
// 市场价和售价一样,则不显示市场价
if (product.marketPrice === product.salesPrice) {
product.marketPrice = false;
}
// 判别默认的商品是否将默认的图片URL赋值到skn
let flag = false;
// 如果设置了默认图片,就取默认的图片
_.forEach(product.goodsList, (goods) => {
if (flag) {
return;
}
if (goods.isDefault === 'Y') {
product.defaultImages = procProductImg(goods);
flag = true;
}
});
// 如果还未赋值,则取第一个skc产品的默认图片
if (!flag) {
product.defaultImages = procProductImg(product.goodsList[0]);
}
// product = Object.assign(product, {
// id: product.productSkn,
// thumb: product.defaultImages
// });
if (options.showPoint) {
product.price += '.00';
product.salePrice += '.00';
}
product.isSoonSoldOut = product.isSoonSoldOut === 'Y';
product.url = helpers.urlFormat(`/product/pro_${product.productId}_${product.goodsList[0].goodsId}/${product.cnAlphabet}.html`); // eslint-disable-line
// APP访问需要加附加的参数
// 备注:如果以后APP的接口太多,可以把这边参数提取出来,变成一个公共的方法来生成,便于以后管理维护
if (options.isApp) {
product.url += `?openby:yohobuy={"action":"go.productDetail","params":{"product_skn":'${product.productId}'}}`; // eslint-disable-line
}
if (options.showTags) {
product.tags = {};
product.tags.isNew = options.showNew && product.isNew === 'Y'; // 新品
product.tags.isDiscount = options.showSale && product.isDiscount === 'Y'; // 在售
product.tags.isLimited = product.isLimited === 'Y'; // 限量
product.tags.isYohood = product.isYohood === 'Y'; // YOHOOD
product.tags.midYear = product.midYear === 'Y'; // 年中
product.tags.yearEnd = product.yearEnd === 'Y'; // 年末
product.tags.isAdvance = product.isAdvance === 'Y'; // 再到着
// 打折与即将售完组合显示打折
if (product.isSoonSoldOut && product.tags.isDiscount) {
product.tags.isNew = false;
} else if (product.tags.isDiscount &&
(product.tags.isNew || product.tags.isLimited || product.tags.isYohood || product.tags.isAdvance)) {
// 打折与其它组合则隐藏打折
product.tags.isDiscount = false;
} else if (product.tags.isYohood && product.tags.isNew) {
// YOHOOD和新品组合显示YOHOOD
product.tags.isNew = false;
}
}
pruductList.push(product);
});
return pruductList;
};
/**
* 处理筛选数据
* @param list
* @param string | options
* @return array 处理之后的筛选数据
*/
exports.processFilter = (list, options) => {
const filters = {
classify: []
};
const filtersType = {
brand: {
name: '所有品牌',
title: '品牌',
dataId: 'id',
subsName: 'brandName',
firstSub: 0,
dataType: 'brand'
},
color: {
name: '所有颜色',
title: '颜色',
dataId: 'colorId',
subsName: 'colorName',
firstSub: 0,
dataType: 'color'
},
discount: {
name: '所有商品',
title: '折扣',
dataId: 'key',
subsName: 'name',
firstSub: '0.1,0.9',
dataType: 'discount'
},
gender: {
name: '所有性别',
title: '性别',
dataId: 'key',
subsName: 'flag',
firstSub: '1,2,3',
dataType: 'gender'
},
groupSort: {
name: '所有品类',
title: '品类',
dataId: 'relationParameter',
subsName: 'categoryName',
firstSub: 0,
dataType: 'sort'
},
priceRange: {
name: '所有价格',
title: '价格',
dataId: 'key',
subsName: 'flag',
firstSub: 0,
dataType: 'price'
},
size: {
name: '所有尺码',
title: '尺码',
dataId: 'sizeId',
subsName: 'sizeName',
firstSub: 0,
dataType: 'size'
}
};
options = Object.assign({
gender: '1,2,3', // 默认选择的性别,默认1,2,3表示所有
exclude: null // 需要排除的字段
}, options);
list = camelCase(list);
_.forEach(list, (item, key) => {
let classify = {
subs: []
};
if (key === 'group_sort') {
return;
}
if ((options.hideSize && key === 'size') || (options.hideSort && key === 'groupSort')) {
return;
}
classify.dataType = filtersType[key].dataType;
classify.name = filtersType[key].name;
classify.title = filtersType[key].title;
classify.subs.push({
chosed: true,
dataId: filtersType[key].firstSub,
name: filtersType[key].name
});
_.forEach(item, (sub, index) => {
let subs = {};
if (filtersType[key].dataId === 'key') {
subs.dataId = index;
} else if (filtersType[key].dataId === 'relationParameter') {
subs.dataId = sub.relationParameter['sort']; // eslint-disable-line
} else {
subs.dataId = sub[filtersType[key].dataId];
}
if (filtersType[key].subsName === 'flag') {
subs.name = sub;
} else {
subs.name = sub[filtersType[key].subsName];
if (key === 'discount') {
subs.name = subs.name + '折商品';
}
}
classify.subs.push(subs);
});
filters.classify.push(classify);
});
return filters;
};
... ...