Authored by 周少峰

Merge branch 'release/4.6' of http://git.yoho.cn/fe/yohobuy-node into release/4.6

... ... @@ -14,8 +14,6 @@ const saleApi = require('./sale-api');
const productProcess = require(`${utils}/product-process`);
const publicHandler = require('./public-handler');
// const headerModel = require('../../../doraemon/models/header');
/**
* 获取商品列表商品数据 Controller 调用
* @param {[type]} params [常规参数]
... ... @@ -32,19 +30,19 @@ exports.getSaleOthersData = (params, channel) => {
// 获取商品数据和顶部筛选条件
if (result[0].code === 200) {
finalResult.goods = productProcess.processProductList(result[0].data.product_list);
finalResult.leftContent = publicHandler.handleSaleSortData(result[0].data.filter.group_sort, params);
}
// 获取左侧类目数据
if (result[1].code === 200) {
finalResult.leftContent = publicHandler.handleSaleSortData(result[1].data.filter.group_sort, params);
finalResult.filters = publicHandler.handleSaleFilterData(result[1].data.filter, params);
finalResult.pathNav = publicHandler.handlePathNavData(result[1].data.filter.group_sort, params);
// 处理排序数据
finalResult.opts = publicHandler.handleSaleOptsData(params, result[1].data.total);
finalResult.totalCount = result[1].data.total;
finalResult.pager = publicHandler.handleSalePagerData(result[1].data.total, params);
Object.assign(finalResult, {
filters: publicHandler.handleSaleFilterData(result[1].data.filter, params),
pathNav: publicHandler.handlePathNavData(result[1].data.filter.group_sort, params),
opts: publicHandler.handleSaleOptsData(params, result[1].data.total),
totalCount: result[1].data.total,
pager: publicHandler.handleSalePagerData(result[1].data.total, params),
goods: productProcess.processProductList(result[1].data.product_list)
});
}
return finalResult;
... ...
... ... @@ -284,3 +284,23 @@ exports.handleOutletstrendGoodData = (origin) => {
return dest;
};
/**
* 处理即将上线品牌数据
* @param origin
* @returns {{}}
*/
exports.handleComeSoonData = (origin) => {
let dest = {
title: '上线预告'
};
dest.brands = [];
_.forEach(origin, value => {
dest.brands.push({
logo: value.logoUrl
});
});
return dest;
};
... ...
... ... @@ -41,8 +41,8 @@ exports.getOutletsIndexData = (params, channel) => {
outletsApi.getOutletsActivityOrigin({type: '1', channel: channel}), // 获取限时活动列表
outletsApi.getOutletsActivityOrigin({type: '2', channel: channel}), // 获取即将结束列表
outletsApi.getOutletsTrendData({limit: '30'}), // 获取潮流速递商品数据
outletsApi.getOutletsGoodsList({limit: params.limit || '100'}) // 获取底部商品数据
outletsApi.getOutletsGoodsList({limit: params.limit || '100'}), // 获取底部商品数据
outletsApi.getOutletsActivityOrigin({type: '3', channel: channel}) // tar add 16171552 即将上线数据
]).then(result => {
let finalResult = {};
... ... @@ -83,6 +83,11 @@ exports.getOutletsIndexData = (params, channel) => {
finalResult.pager = publicHandler.handleSalePagerData(result[5].data.total, params);
}
// 处理即将上架品牌数据
if (result[6].code === 200) {
finalResult.limitedBuy.extra.comeSoon = outletsProcess.handleComeSoonData(result[6].data);
}
return finalResult;
});
};
... ...
... ... @@ -2,7 +2,7 @@
* @Author: Targaryen
* @Date: 2016-06-02 15:50:47
* @Last Modified by: Targaryen
* @Last Modified time: 2016-06-08 19:31:52
* @Last Modified time: 2016-06-17 16:42:51
*/
'use strict';
... ... @@ -236,24 +236,42 @@ exports.handleSalePagerData = (total, params) => {
/**
* 处理 opts 排序数据
* @param {[type]} origin [description]
* @return {[type]} [description]
* @param params
* @param total
* @param extra 什么都可以传进来,多个参数传Object
* @returns {{}}
*/
exports.handleSaleOptsData = (params, total) => {
exports.handleSaleOptsData = (params, total, extra) => {
var dest = {};
dest.sortType = [];
for (let i = 0; i < 4; i++) {
// 用来标记是否是折扣专场,折扣专场只需要前三个排序参数
let count = (extra === 'discont') ? 3 : 4;
for (let i = 0; i < count; i++) {
let opt = {};
switch (i) {
case 0:
opt.href = handleFilterUrl(params, {order: 's_t_desc'});
opt.name = '最新';
opt.hasSortOrient = true;
opt.active = true;
opt.desc = true;
if (extra === 'discont') { // 如果是折扣专场
opt.name = '全部';
if (_.isEmpty(params.order) || params.order === 's_t_desc') {
opt.active = true;
} else {
opt.active = false;
}
} else {
opt.name = '最新';
opt.hasSortOrient = true;
if (_.isEmpty(params.order) || params.order === 's_t_desc') {
opt.active = true;
} else {
opt.active = false;
}
opt.desc = true;
}
break;
case 1:
if (params.order !== 's_p_desc' && params.order !== 's_p_asc') {
... ... @@ -341,7 +359,7 @@ exports.handleSaleOptsData = (params, total) => {
// 上一页下一页
let preHref = (!_.isEmpty(params.page) && parseInt(params.page, 10) > 1) ?
parseInt(params.page, 10) - 1 : 1;
parseInt(params.page, 10) - 1 : 1;
let nextHref = (!_.isEmpty(params.page)) ? parseInt(params.page, 10) + 1 : 2;
if (dest.pageCount > 1 && (parseInt(params.page, 10) !== 1) &&
... ... @@ -364,7 +382,10 @@ exports.handleSaleOptsData = (params, total) => {
/**
* 处理页面左侧分类筛选数据
* @return {[type]} [description]
* @param origin 分类原始数据,一般是接口返回数据中的 group_sort 字段
* @param params 当前 URL 中已有的参数
* @param extra 可以任意传值用来处理特殊情况
* @returns {{}}
*/
exports.handleSaleSortData = (origin, params, extra) => {
var leftContent = {};
... ... @@ -372,15 +393,22 @@ exports.handleSaleSortData = (origin, params, extra) => {
leftContent.allSort = {};
leftContent.allSort.list = [];
let perAllSort = {
name: '全部品类',
href: handleFilterUrl(params),
all: true,
num: extra
};
if (extra === 'discount') {
let tempParams = _.cloneDeep(params);
leftContent.allSort.list.push(perAllSort);
delete tempParams.sort;
leftContent.allSort.all = {
name: '全部品类',
href: handleFilterUrl(tempParams),
active: _.isEmpty(params.sort) ? true : false
};
} else {
leftContent.allSort.all = {
name: '全部品类',
href: handleFilterUrl(params)
};
}
_.forEach(origin, function(value) {
... ... @@ -390,7 +418,7 @@ exports.handleSaleSortData = (origin, params, extra) => {
category.num = value.node_count;
category.childList = [];
category.href = handleFilterUrl(params, {sort: value.relation_parameter.sort});
category.active = false;
category.active = (params.sort === value.relation_parameter.sort) ? true : false;
_.forEach(value.sub, function(subValue) {
category.childList.push({
name: subValue.category_name,
... ...
... ... @@ -2,15 +2,13 @@
* @Author: Targaryen
* @Date: 2016-05-25 18:16:59
* @Last Modified by: Targaryen
* @Last Modified time: 2016-06-08 19:35:20
* @Last Modified time: 2016-06-17 16:43:38
*/
'use strict';
const library = '../../../library';
const helpers = require(`${library}/helpers`);
const _ = require('lodash');
// const aMinute = 60000;
const anHour = 3600000;
const aDay = anHour * 24;
const timeFormat = {
... ... @@ -50,34 +48,6 @@ const processTime = (time) => {
};
/**
* 折扣专场专题详情过期时间处理
* @param {[string]} time
* @return {[boject]}
*/
// const processTimes = (time) => {
// let data = {};
// let type = '';
//
// if (time > aDay) {
// type = 'dhms';
// } else {
// if (time > anHour) {
// type = 'hms';
// } else {
// if (time > aMinute) {
// type = 'ms';
// } else {
// type = 's';
// }
// }
// }
//
// data.time = helpers.dateDiffFormat(timeFormat[type], time, 'ms');
//
// return data.time;
// };
/**
* 折扣文本切割
* @param text 要切割的文本
* @returns {{discount: *, discountText: *}}
... ... @@ -195,31 +165,56 @@ const handleCheckedData = (params, origin, param) => {
* @param origin
* @returns {{}}
*/
// const handleBrandCheckedData = (params, origin) => {
// let dest = {};
//
// let brands = _.split(params.brand, ',');
//
// if (!_.isEmpty(origin)) {
// _.forEach(origin, (value) => {
// if (!_.isEmpty(_.find(brands, o => {
// return o === value.id;
// }))) {
// let checked = {};
//
// checked.name = value.name;
//
// let tempParam = {};
//
// tempParam.brand = '';
// checked.href = handleFilterUrl(params, tempParam);
//
// dest.push(checked);
// }
// });
// }
// return dest;
// };
const handleBrandCheckedData = (params, origin) => {
let dest = [];
// 分拆品牌参数
let brands = _.split(params.brand, ',');
let intBrands = [];
_.forEach(brands, value => {
intBrands.push(parseInt(value, 10));
});
// 遍历品牌数据,如果在参数中,那么加 checked,将此数据加入到 checked 数组中
if (!_.isEmpty(origin)) {
_.forEach(origin, (value) => {
if (typeof _.find(intBrands, o => {
return _.isEqual(o, value.id);
}) !== 'undefined') {
let checked = {}; // push 到已选择数组
checked.name = value.name;
// 为了不污染原始数据
let tempIntBrands = _.cloneDeep(intBrands);
// 去掉当前选项
_.remove(tempIntBrands, n => {
return n === value.id;
});
// 拼接参数
let brand = '';
_.forEach(tempIntBrands, subValue => {
brand += subValue + ',';
});
// 清除参数,保留没有去掉的参数
let tempParam = {
brand: brand
};
checked.href = handleFilterUrl(params, tempParam);
dest.push(checked);
}
});
}
return dest;
};
/**
* 处理断码区尺码筛选数据
... ... @@ -407,8 +402,10 @@ exports.handleSaleFilterData = (origin, params) => {
handleCheckedData(params, dest.gender, 'gender'));
// 处理品牌筛选数据
// dest.checkedConditions.conditions = _.union(dest.checkedConditions.conditions,
// handleCheckedData(params, dest.brand.brandsShow, 'brand'));
dest.checkedConditions.conditions = _.union(dest.checkedConditions.conditions,
handleCheckedData(params, dest.brand.brandsShow, 'brand'));
handleBrandCheckedData(params, dest.brand.brandsShow));
// 处理价格筛选数据
dest.checkedConditions.conditions = _.union(dest.checkedConditions.conditions,
... ... @@ -418,199 +415,6 @@ exports.handleSaleFilterData = (origin, params) => {
};
/**
* 处理 opts 排序数据
* @param params
* @param total
* @param extra 什么都可以传进来,多个参数传Object
* @returns {{}}
*/
exports.handleSaleOptsData = (params, total, extra) => {
var dest = {};
dest.sortType = [];
// 用来标记是否是折扣专场,折扣专场只需要前三个排序参数
let count = (extra === 'discont') ? 3 : 4;
for (let i = 0; i < count; i++) {
let opt = {};
switch (i) {
case 0:
opt.href = handleFilterUrl(params, {order: 's_t_desc'});
if (extra === 'discont') { // 如果是折扣专场
opt.name = '全部';
if (_.isEmpty(params.order) || params.order === 's_t_desc') {
opt.active = true;
} else {
opt.active = false;
}
} else {
opt.name = '最新';
opt.hasSortOrient = true;
if (_.isEmpty(params.order) || params.order === 's_t_desc') {
opt.active = true;
} else {
opt.active = false;
}
opt.desc = true;
}
break;
case 1:
if (params.order !== 's_p_desc' && params.order !== 's_p_asc') {
opt.href = handleFilterUrl(params, {order: 's_p_desc'});
opt.hasSortOrient = true;
} else {
opt.hasSortOrient = true;
opt.active = true;
if (params.order === 's_p_desc') {
opt.href = handleFilterUrl(params, {order: 's_p_asc'});
opt.desc = false;
} else {
opt.href = handleFilterUrl(params, {order: 's_p_desc'});
opt.desc = true;
}
}
opt.name = '价格';
break;
case 2:
if (params.order !== 'p_d_desc' && params.order !== 'p_d_asc') {
opt.href = handleFilterUrl(params, {order: 'p_d_desc'});
opt.hasSortOrient = true;
} else {
opt.hasSortOrient = true;
opt.active = true;
if (params.order === 'p_d_desc') {
opt.href = handleFilterUrl(params, {order: 'p_d_asc'});
opt.desc = false;
} else {
opt.href = handleFilterUrl(params, {order: 'p_d_desc'});
opt.desc = true;
}
}
opt.name = '折扣';
break;
case 3:
if (params.order !== 's_n_desc' && params.order !== 's_n_asc') {
opt.href = handleFilterUrl(params, {order: 's_n_desc'});
opt.hasSortOrient = true;
} else {
opt.hasSortOrient = true;
opt.active = true;
if (params.order === 's_n_desc') {
opt.href = handleFilterUrl(params, {order: 's_n_asc'});
opt.desc = false;
} else {
opt.href = handleFilterUrl(params, {order: 's_n_desc'});
opt.desc = true;
}
}
opt.name = '销量';
break;
default:
break;
}
dest.sortType.push(opt);
}
// 上下翻页数据处理
dest.pageCounts = [{
href: handleFilterUrl(params, {limit: 200}),
count: 200
}, {
href: handleFilterUrl(params, {limit: 100}),
count: 100
}, {
href: handleFilterUrl(params, {limit: 60}),
count: 60
}];
dest.curPage = _.isEmpty(params.page) ? 1 : params.page; // 当前页码数
// 每页商品数量
dest.countPerPage = _.isEmpty(params.limit) ? 60 : params.limit;
// 全部页码数量
dest.pageCount = parseInt(total / (_.isEmpty(params.limit) ? 60 : params.limit), 10) + 1;
// 每页多少商品
let paramsLimit = parseInt((_.isEmpty(params.limit) ? 60 : params.limit), 10);
// 上一页下一页
let preHref = (!_.isEmpty(params.page) && parseInt(params.page, 10) > 1) ?
parseInt(params.page, 10) - 1 : 1;
let nextHref = (!_.isEmpty(params.page)) ? parseInt(params.page, 10) + 1 : 2;
if (dest.pageCount > 1 && (parseInt(params.page, 10) !== 1) &&
(parseInt(params.page, 10) !== dest.pageCount)) {
dest.preHref = handleFilterUrl(params, {page: preHref});
dest.nextHref = handleFilterUrl(params, {page: nextHref});
} else if (dest.pageCount > 1 && (parseInt(params.page, 10) === 1)) {
dest.nextHref = handleFilterUrl(params, {page: nextHref});
} else if (dest.pageCount > 1 && (parseInt(params.page, 10) === dest.pageCount)) {
dest.preHref = handleFilterUrl(params, {page: preHref});
}
// 商品开始结束数
dest.start = (!_.isEmpty(params.page) ? (params.page - 1) : 0) * paramsLimit + 1;
dest.end = (dest.pageCount === parseInt(params.page, 10)) ?
total : parseInt(dest.start, 10) + paramsLimit - 1;
return dest;
};
/**
* 处理页面左侧分类筛选数据
* @param origin 分类原始数据,一般是接口返回数据中的 group_sort 字段
* @param params 当前 URL 中已有的参数
* @param extra 可以任意传值用来处理特殊情况
* @returns {{}}
*/
exports.handleSaleSortData = (origin, params, extra) => {
var leftContent = {};
leftContent.allSort = {};
leftContent.allSort.list = [];
leftContent.allSort.all = {
name: '全部品类',
href: handleFilterUrl(params),
num: extra
};
_.forEach(origin, function(value) {
let category = {};
category.name = value.category_name;
category.num = value.node_count;
category.childList = [];
category.href = handleFilterUrl(params, {sort: value.relation_parameter.sort});
category.active = false;
_.forEach(value.sub, function(subValue) {
category.childList.push({
name: subValue.category_name,
num: subValue.node_count,
href: handleFilterUrl(params, {sort: subValue.relation_parameter.sort}),
childActive: (params.sort === subValue.relation_parameter.sort) ? true : false
});
if (params.sort === subValue.relation_parameter.sort) {
category.active = true;
}
});
leftContent.allSort.list.push(category);
});
return leftContent;
};
/**
* 处理折扣专区活动数据
* @param origin 原始数据
* @param channel 频道 boys girls kids lifestyle
... ... @@ -634,7 +438,7 @@ exports.handleSaleActivityData = (origin, channel) => {
if (key < 3) {
dest.big.push(activity);
} else if (key < 15) {
} else if (key < 27) {
dest.normal.push(activity);
}
});
... ... @@ -781,86 +585,6 @@ exports.handleSaleCategoryData = (origin, saleType, channel, breakingSizeSort) =
};
/**
* 处理分页数据
* @param total 商品总数目
* @param params 当前 URL 中已有的参数
* @returns {string}
*/
exports.handleSalePagerData = (total, params) => {
// 当前页
let currentPage = parseInt((_.isEmpty(params.page) ? 1 : params.page), 10);
let perPageCount = parseInt((_.isEmpty(params.limit) ? 60 : params.limit), 10);
let totalPage = parseInt(total / perPageCount, 10) + 1;
let dest = '<a href ="' + handleFilterUrl(params, {page: (currentPage)}) +
'" class="cur">' + currentPage + '</a>';
// 先处理大多数情况
if ((currentPage > 2) && (currentPage < (parseInt(total, 10) / perPageCount) - 1)) {
for (let i = 1; i < 3; i++) {
dest = '<a href ="' + handleFilterUrl(params, {page: (currentPage - i)}) + '">' +
(currentPage - i) + '</a> ' + dest + ' <a href ="' +
handleFilterUrl(params, {page: (currentPage + i)}) +
'">' + (currentPage + i) + '</a>';
}
// 处理页码小于2的情况
} else if (currentPage <= 2) {
for (let i = currentPage - 1; i > 0; i--) {
dest = '<a href ="' + handleFilterUrl(params, {page: i}) +
'">' + i + '</a>' + dest;
}
for (let i = currentPage + 1; i < (totalPage < 6 ? totalPage : 6); i++) {
dest += '<a href ="' + handleFilterUrl(params, {page: i}) +
'">' + i + '</a>';
}
// 处理页码大于最大页-2的情况
} else if (currentPage > totalPage - 2) {
for (let i = currentPage + 1; i < totalPage + 1; i++) {
dest += '<a href ="' + handleFilterUrl(params, {page: i}) +
'">' + i + '</a>';
}
for (let i = currentPage - 1; i > (currentPage - 5 > 1 ? currentPage - 5 : 1); i--) {
dest = '<a href ="' + handleFilterUrl(params, {page: i}) +
'">' + i + '</a>' + dest;
}
}
// 处理后省略号的情况
if ((totalPage > 5) && (currentPage < (totalPage - 2))) {
dest += ' ... <a href ="' + handleFilterUrl(params, {page: totalPage}) +
'">' + totalPage + '</a>';
}
// 处理前省略号的情况
if (currentPage > 3) {
dest = '<a href ="' + handleFilterUrl(params, {page: 1}) +
'">1</a> ... ' + dest;
}
// 处理上一页下一页
if (currentPage !== 1) {
dest = '<a href="' + handleFilterUrl(params, {page: currentPage - 1}) +
'"><span class="iconfont">&#xe60e;上一页</span></a>' + dest;
}
if (currentPage !== totalPage) {
dest += '<a href="' + handleFilterUrl(params, {page: currentPage + 1}) +
'"><span class="iconfont">下一页&#xe60c;</span></a>';
}
return dest;
};
/**
* 处理断码区尺码数据,输出整合后的筛选条件
* @param origin
*/
... ...
... ... @@ -2,7 +2,7 @@
* @Author: Targaryen
* @Date: 2016-05-19 10:20:08
* @Last Modified by: Targaryen
* @Last Modified time: 2016-06-08 10:02:13
* @Last Modified time: 2016-06-17 16:43:11
*/
'use strict';
... ... @@ -11,6 +11,7 @@ const utils = '../../../utils';
const API = require(`${library}/api`).API;
const api = new API();
const saleApi = require('./sale-api');
const publicHandler = require('./public-handler');
const saleHandler = require('./sale-handler');
const productProcess = require(`${utils}/product-process`);
const _ = require('lodash');
... ... @@ -74,19 +75,21 @@ exports.getSaleGoodsData = (params) => {
switch (result[1].curLevel) {
case '1':
finalResult.goods[key].vipPrice = value.vip1Price;
finalResult.goods[key].salePrice = value.vip1Price;
finalResult.goods[key].vip1 = true;
break;
case '2':
finalResult.goods[key].vipPrice = value.vip2Price;
finalResult.goods[key].salePrice = value.vip2Price;
finalResult.goods[key].vip2 = true;
break;
case '3':
finalResult.goods[key].vipPrice = value.vip3Price;
finalResult.goods[key].salePrice = value.vip3Price;
finalResult.goods[key].vip3 = true;
break;
default:
finalResult.goods[key].vip = true;
finalResult.goods[key].salePrice = value.marketPrice;
delete finalResult.goods[key].marketPrice;
break;
}
... ... @@ -242,9 +245,9 @@ exports.getSaleOthersData = (params, channel) => {
}
// 处理排序数据
finalResult.opts = saleHandler.handleSaleOptsData(params, result[1].data.total);
finalResult.opts = publicHandler.handleSaleOptsData(params, result[1].data.total);
finalResult.totalCount = result[1].data.total;
finalResult.pager = saleHandler.handleSalePagerData(result[1].data.total, params);
finalResult.pager = publicHandler.handleSalePagerData(result[1].data.total, params);
// 处理所有商品标题数据
finalResult.saleTitle = {
... ... @@ -253,8 +256,9 @@ exports.getSaleOthersData = (params, channel) => {
};
_.forEach(finalResult.goods, (value, key) => {
finalResult.goods[key].tags.isNew = false; // 屏蔽 new 标签
finalResult.goods[key].tags.isSale = false;
delete finalResult.goods[key].tags.isNew; // 屏蔽 new 标签
delete finalResult.goods[key].tags.isSale;// 屏蔽 sale 标签
delete finalResult.goods[key].discount; // 屏蔽折扣信息
});
}
... ... @@ -267,7 +271,7 @@ exports.getSaleOthersData = (params, channel) => {
if (result[3].code === 200) {
// 获取左侧类目数据
finalResult.leftContent = saleHandler.handleSaleSortData(result[3].data.filter.group_sort, params);
finalResult.leftContent = publicHandler.handleSaleSortData(result[3].data.filter.group_sort, params);
}
... ... @@ -278,23 +282,21 @@ exports.getSaleOthersData = (params, channel) => {
switch (result[4].curLevel) {
case '1':
finalResult.goods[key].vipPrice =
finalResult.goods[key].salePrice = value.vip1_price;
finalResult.goods[key].salePrice = value.vip1_price;
finalResult.goods[key].vip1 = true;
break;
case '2':
finalResult.goods[key].vipPrice =
finalResult.goods[key].salePrice = value.vip2_price;
finalResult.goods[key].salePrice = value.vip2_price;
finalResult.goods[key].vip2 = true;
break;
case '3':
finalResult.goods[key].vipPrice =
finalResult.goods[key].salePrice = value.vip3_price;
finalResult.goods[key].salePrice = value.vip3_price;
finalResult.goods[key].vip3 = true;
break;
default:
finalResult.goods[key].vipPrice = value.vip_price;
finalResult.goods[key].vip = true;
finalResult.goods[key].salePrice = value.marketPrice;
delete finalResult.goods[key].marketPrice;
break;
}
... ... @@ -326,8 +328,9 @@ exports.getSaleDiscountData = (params, channel) => {
finalResult.saleList.totalCount = result[1].data.total;
_.forEach(finalResult.saleList.goods, (value, key) => {
finalResult.saleList.goods[key].tags.isNew = false; // 屏蔽 new 标签
finalResult.saleList.goods[key].tags.isSale = false;
delete finalResult.saleList.goods[key].tags.isNew; // 屏蔽 new 标签
delete finalResult.saleList.goods[key].tags.isSale;// 屏蔽 sale 标签
delete finalResult.saleList.goods[key].discount; // 屏蔽折扣信息
});
}
... ... @@ -344,9 +347,10 @@ exports.getSaleDiscountData = (params, channel) => {
// 处理分页等筛选信息
if (result[3].code === 200) {
finalResult.leftContent = saleHandler.handleSaleSortData(result[3].data.filter.group_sort, params);
finalResult.saleList.pager = saleHandler.handleSalePagerData(result[3].data.total, params);
finalResult.saleList.opts = saleHandler.handleSaleOptsData(params, result[3].data.total);
finalResult.leftContent =
publicHandler.handleSaleSortData(result[3].data.filter.group_sort, params, 'discount');
finalResult.saleList.pager = publicHandler.handleSalePagerData(result[3].data.total, params);
finalResult.saleList.opts = publicHandler.handleSaleOptsData(params, result[3].data.total);
}
... ... @@ -356,8 +360,9 @@ exports.getSaleDiscountData = (params, channel) => {
/**
* 获取断码区数据 Controller 调用
* @param {[type]} params [description]
* @return {[type]} [description]
* @param params
* @param channel
* @returns {*|Promise.<TResult>}
*/
exports.getSalebreakingYardsData = (params, channel) => {
return api.all([
... ... @@ -393,7 +398,7 @@ exports.getSalebreakingYardsData = (params, channel) => {
// 处理筛选条件数据
if (subResult[0].code === 200) {
finalResult.leftContent =
saleHandler.handleSaleSortData(subResult[0].data.filter.group_sort, params);
publicHandler.handleSaleSortData(subResult[0].data.filter.group_sort, params);
}
// 处理商品数据
... ... @@ -406,9 +411,9 @@ exports.getSalebreakingYardsData = (params, channel) => {
}
finalResult.goods = productProcess.processProductList(subResult[1].data.product_list);
finalResult.opts = saleHandler.handleSaleOptsData(params, subResult[1].data.total);
finalResult.opts = publicHandler.handleSaleOptsData(params, subResult[1].data.total);
finalResult.totalCount = subResult[1].data.total;
finalResult.pager = saleHandler.handleSalePagerData(subResult[1].data.total, params);
finalResult.pager = publicHandler.handleSalePagerData(subResult[1].data.total, params);
// 处理所有商品标题数据
finalResult.saleTitle = {};
... ... @@ -417,8 +422,9 @@ exports.getSalebreakingYardsData = (params, channel) => {
finalResult.saleTitle.count = subResult[1].data.count;
_.forEach(finalResult.goods, (value, key) => {
finalResult.goods[key].tags.isNew = false; // 屏蔽 new 标签
finalResult.goods[key].tags.isSale = false;
delete finalResult.goods[key].tags.isNew; // 屏蔽 new 标签
delete finalResult.goods[key].tags.isSale;// 屏蔽 sale 标签
delete finalResult.goods[key].discount; // 屏蔽折扣信息
});
}
return finalResult;
... ...
... ... @@ -30,6 +30,7 @@ router.get('/sale/newSale', sale.newSale); // 最新降价
router.get('/sale/goods', sale.getGoodsList); // ajax 获取商品列表
// 奥特莱斯routers
router.get('/outlets', outlets.index);
router.get('/outlets/index', outlets.index);
router.get('/outlets/special/detail', outlets.special);
router.get('/outlets/list', outlets.list); // 奥莱品类页
... ...
... ... @@ -53,10 +53,10 @@
¥{{.}}
</span>
{{/ salesPrice}}
{{#vip}}<span class="vip-tag"> VIP </span><strong>更优惠</strong>{{/vip}}
{{#vip1}}<span class="vip-1"> </span>{{/vip1}}
{{#vip2}}<span class="vip-2"> </span>{{/vip2}}
{{#vip3}}<span class="vip-3"> </span>{{/vip3}}
{{#vip}}<span class="vip-tag vip-span"><span> VIP </span></span><strong>更优惠</strong>{{/vip}}
{{#vip1}}<span class="vip-1 vip-span"></span>{{/vip1}}
{{#vip2}}<span class="vip-2 vip-span"></span>{{/vip2}}
{{#vip3}}<span class="vip-3 vip-span"></span>{{/vip3}}
</p>
</div>
</div>
... ...
{{#pager}}
{{#pre}}
<a href="{{href}}"><span class="iconfont">&#xe60e;上一页</span></a>
{{/pre}}
{{#pageNum}}
<a {{#if href}}href="{{href}}"{{/if}}>{{name}}</a>
{{/pageNum}}
{{#next}}
<a href="{{href}}"><span class="iconfont">下一页&#xe60c;</span></a>
{{/next}}
{{/pager}}
\ No newline at end of file
... ...
... ... @@ -30,7 +30,7 @@
<div class="sale-group clearfix">
{{#normal}}
<a class="item pull-left" href="{{link}}" target= "_blank">
<img class="pic" src="{{image img 378 500}}">
<img class="pic" src="{{image img 350 360}}">
<div class="detail">
<div class="title">{{title}}{{discount}}{{discountText}}</div>
<div class="time">{{time}}</div>
... ...
... ... @@ -19,10 +19,10 @@
{{#leftContent}}
{{#allSort}}
{{#all}}
<li class="{{#if checked}}active{{/if}}"><a href="{{href}}">{{name}} {{#if num}}({{num}}){{/if}}</a></li>
<li class="{{#if active}}active{{/if}}"><a href="{{href}}">{{name}} {{#if num}}({{num}}){{/if}}</a></li>
{{/all}}
{{#list}}
<li class="{{#if checked}}active{{/if}}"><a href="{{href}}">{{name}} {{#if num}}({{num}}){{/if}}</a></li>
<li class="{{#if active}}active{{/if}}"><a href="{{href}}">{{name}} {{#if num}}({{num}}){{/if}}</a></li>
{{/list}}
{{/allSort}}
{{/leftContent}}
... ...
... ... @@ -32,17 +32,28 @@
<p class="few-tag">即将售罄</p>
{{/ isFew}}
{{# isSaleOut}}
<div class="sale-out">
<span class="sale-out-tip">已抢光</span>
</div>
{{/ isSaleOut}}
{{#if showColBtn}}
<span class="col-btn iconfont{{#if coled}} coled{{/if}}">&#xe616;</span>
{{/if}}
</div>
<div class="good-detail-text">
<a href="{{url}}" target="_blank">{{{productName}}}</a>
{{!-- {{# brandName}} --}}
{{#if isSaleOut}}
<a href="javascript:;">{{{productName}}}</a>
<p class="brand">
<a href="javascript:;">{{brandName}}</a>
</p>
{{^}}
<a href="{{url}}" target="_blank">{{{productName}}}</a>
<p class="brand">
<a href="{{brandUrl}}">{{brandName}}</a>
</p>
{{!-- {{/ brandName}} --}}
{{/if}}
<p class="price">
{{# marketPrice}}
<span class="market-price">¥{{.}}</span>
... ... @@ -50,14 +61,19 @@
<span class="sale-price{{#unless marketPrice}}prime-cost{{/unless}}">
¥{{salesPrice}}
</span>
{{#vip}}<span class="vip-tag"> VIP </span><strong>更优惠</strong>{{/vip}}
{{#vip1}}<span class="vip-1"> </span>{{/vip1}}
{{#vip2}}<span class="vip-2"> </span>{{/vip2}}
{{#vip3}}<span class="vip-3"> </span>{{/vip3}}
{{# discount}}
<span class="discount">{{.}}</span>
{{/ discount}}
{{#vip}}<span class="vip-tag vip-span"><span> VIP </span></span><strong>更优惠</strong>{{/vip}}
{{#vip1}}<span class="vip-1 vip-span"></span>{{/vip1}}
{{#vip2}}<span class="vip-2 vip-span"></span>{{/vip2}}
{{#vip3}}<span class="vip-3 vip-span"></span>{{/vip3}}
</p>
<div class="goodsList hide">
<div class="hideList hide">
{{#goodsList}}
<div class="list" imgUrl = "{{image imagesUrl 220 300}}" url = "{{goodsId}}" cover = "{{cover1}}"></div>
<li data-src="{{image imagesUrl 235 314}}" data-url="{{../url}}"></li>
{{/goodsList}}
</div>
</div>
... ...
... ... @@ -94,3 +94,7 @@ exports.webSign = (params) => {
return params.key === md5(md5(webPrivateKey) + params.uid);
};
exports.makeToken = (string) => {
return md5(md5(string + '#@!@#'));
};
... ...
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.

2.67 KB | W: | H:

3.62 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin

2.67 KB | W: | H:

3.62 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin
... ... @@ -15,7 +15,7 @@ var homePage = $('.home-page').data('page'),
require('../common');
require('../plugins/slider');
require('../plugins/logo-brand');
require('../product/index/logo-brand');
require('../plugins/accordion');
... ... @@ -27,7 +27,7 @@ $(document).on('mouseout', '.imgopacity a img', function() {
});
if ($.inArray(homePage, ['boys', 'girls', 'kids', 'lifestyle']) > -1) {
require('../plugins/new-arrivls')({
require('../product/index/new-arrivls')({
type: homePage,
url: '/common/getNewArrival',
count: (homePage === 'boys') || (homePage === 'lifestyle') ? 5 : 4,
... ...
... ... @@ -8,7 +8,7 @@ var $ = require('yoho-jquery'),
Handlebars = require('yoho-handlebars'),
lazyLoad = require('yoho-jquery-lazyload');
(function($) {
(function() {
var LogoBrand = function(element, options) {
this.$element = $(element);
this.options = $.extend({}, $.fn.logoBrand.defaults, options);
... ... @@ -153,4 +153,4 @@ var $ = require('yoho-jquery'),
showNum: 16,
url: '/boys/getBrand'
};
})($);
}());
... ...
... ... @@ -112,7 +112,7 @@ module.exports = function(data) {
delete data.count;
delete data.rows;
loadAjax = function(url, data, count) {
loadAjax = function() {
var options = {
type: 'POST',
... ... @@ -154,14 +154,14 @@ module.exports = function(data) {
};
load.on('after', function(p) {
load.on('after', function() {
data.pageCount = count * rows[1];
loadAjax(url, data);
});
load.on('before', function(p) {
load.on('before', function() {
load.tpl = '{{#each this}}';
... ...
... ... @@ -83,88 +83,12 @@ exports.init = function(num) {
});
}
// 原来的
// productList.addHandler('MouseEnter', function(event) {
// var itemMr = 10, // list的右边距
// itemMb = 35, // list的下边距
// ulStr = '',
// ulNum,
// wrapperWidth,
// diffWidth,
// wrapperX,
// wrapperY,
// wrapperPl, // 鼠标移入时弹层的左内边距
// wrapperPt, // 鼠标移入时弹层的上内边距
// containerPt, // 商品列表容器的上内边距
// _from = event.target.attr('data-from') || '';
//
// $.ajax({
// type: 'POST',
// url: '/product/list/getProductPic',
// dataType: 'jsonp',
// jsonp: 'callback',
// data: {
// skn: event.target.attr('data-skn'),
// skc: event.target.attr('data-skc')
// }
// }).then(function(res) {
// var data = res.data,
// colorList = createColorList(data.pics, _from);
//
// removeHtmlFn();
//
// ulStr = colorList.colorListStr; // ajax请求的颜色列表
// ulNum = colorList.ulNum;// ajax请求的颜色的数量
//
// $goodInfoMain.append(event.targetDuplicate);
// $goodSelectColor.append($(ulStr));
//
// // 点击收藏商品不需要了
// // if (data.isFavorite) {
// // $goodInfoMain.find('.col-btn').addClass('coled');
// // } else {
// // $goodInfoMain.find('.col-btn').removeClass('coled');
// // }
//
// wrapperPl = $goodItemWrapper.css('paddingLeft');
// wrapperPt = $goodItemWrapper.css('paddingTop');
// containerPt = $goodsContainer.css('paddingTop');
//
// wrapperWidth = 10 + (15 + 50) * ulNum + event.targetWidth;
//
// // wrapperWidth = $goodItemWrapper.width();
//
// wrapperX = (event.targetX - 1) * (event.targetWidth + itemMr) - (parseInt(wrapperPl) + 1);
// wrapperY = (event.targetY - 1) *
// (event.targetHeight + itemMb) + parseInt(containerPt) - (parseInt(wrapperPt) + 1);
//
// // todo
// // event.offsetR表示当前列表距离浏览器右侧边缘的距离
// diffWidth = event.offsetR - ((15 + 50) * ulNum + 25);
//
// if (diffWidth <= 0) {
// wrapperX = wrapperX + diffWidth - 25;
// }
// $goodItemWrapper.css({
// width: wrapperWidth,
// left: wrapperX,
// top: wrapperY,
// display: 'inline-block'
// });
//
// // 鼠标悬浮获取到商品信息后显示第一张图片
// if (data.pics[0] && data.pics[0].src) {
// $goodInfoMain.find('.good-thumb img').attr('src', data.pics[0].src);
// }
// });
// });
productList.addHandler('MouseEnter', function(event) {
var itemMr = 10, // list的右边距
itemMb = 35, // list的下边距
imageList,
colorList,
pic, pics,
pic,
pics,
ulNum, ulStr,
wrapperWidth,
diffWidth,
... ... @@ -177,21 +101,13 @@ exports.init = function(num) {
pics = [];
event.target.find('.goodsList').find('.list').each(function() {
pic = {
url: $(this).attr('url'),
src: $(this).attr('imgUrl'),
coverImg: $(this).attr('cover')
};
event.target.find('.hideList > li').each(function() {
pic = $(this).data();
pic.coverImg = pic.src;
pics.push(pic);
});
imageList = {
pics: pics
};
colorList = createColorList(imageList.pics, _from);
colorList = createColorList(pics, _from);
removeHtmlFn();
... ... @@ -227,8 +143,8 @@ exports.init = function(num) {
});
// 鼠标悬浮获取到商品信息后显示第一张图片
if (imageList.pics[0] && imageList.pics[0].src) {
$goodInfoMain.find('.good-thumb img').attr('src', imageList.pics[0].src);
if (pics[0] && pics[0].src) {
$goodInfoMain.find('.good-thumb img').attr('src', pics[0].src);
}
});
... ... @@ -244,9 +160,9 @@ exports.init = function(num) {
};
// 鼠标放在颜色列表上效果
$(document).on('hover', '.good-select-color li', function() {
$(document).on('mouseenter', '.good-select-color li', function() {
var coverImg = $(this).find('img').attr('data-cover'),
$coverImg = $(this).closest('.good-item-wrapper').find('.good-detail-img').find('img');
$coverImg = $(this).closest('.good-item-wrapper').find('.good-detail-img img');
$coverImg.attr('src', coverImg);
});
... ...
... ... @@ -4,9 +4,9 @@
* @date: 2016/06/3
*/
var product = require('../../plugins/product');
var product = require('../index/product');
require('../../plugins/filter');
require('../../plugins/sort-pager');
product.init(4);
... ...
/**
* sale页面
* @author: da<abel.wang@yoho.cn>
* @date: 2016/05/31
*/
var $ = require('yoho-jquery'),
lazyLoad = require('yoho-jquery-lazyload'),
product = require('../plugins/product');
product = require('./index/product');
var limitTime = [];
... ... @@ -37,7 +42,7 @@ function getNaviData(items) {
goodItems.html('');
goodItems.append(res);
lazyLoad($('img.lazy'));
lazyLoad(items.closest('.sale-box').find('.lazy'));
});
}
... ...
... ... @@ -37,31 +37,32 @@ slide = new Slide({
index: 0
});
if ($item.length > 1) {
slide.on('change', function(data) {
if (current) {
current = false;
} else {
return;
}
index++;
$('.sale-list-pagation').find('span').removeClass('active');
$item.eq(data.from).animate({
opacity: 0
}, 300);
$item.eq(data.to).css({
zIndex: index
}).animate({
opacity: 1
}, 300, function() {
current = true;
});
$('.sale-list-pagation').find('span').eq(data.to).addClass('active');
slide.on('change', function(data) {
if (current) {
current = false;
} else {
return;
}
index++;
$('.sale-list-pagation').find('span').removeClass('active');
$item.eq(data.from).animate({
opacity: 0
}, 300);
$item.eq(data.to).css({
zIndex: index
}).animate({
opacity: 1
}, 300, function() {
current = true;
});
$('.sale-list-pagation').find('span').eq(data.to).addClass('active');
});
}
$contain.hover(function() {
if (current) {
... ...
... ... @@ -314,7 +314,7 @@
background: resolve('layout/outlets.png') no-repeat center center;
width: 200px;
height: 34px;
left: 42%;
left: 45%;
margin-top: 28px;
position: absolute;
display: none;
... ... @@ -437,19 +437,20 @@
top: 30px;
right: -14px;
width: 378px;
background: #f8f8f8 resolve('layout/empty_car.png') no-repeat 106px 132px;
z-index: 1000;
background: #f8f8f8;
display: none;
.empty-cart {
padding: 280px 0 200px;
text-align: center;
background: resolve('layout/empty_car.png') no-repeat 106px 132px;
}
.loading-cart {
padding: 200px 0;
text-align: center;
background: #f8f8f8 reslove('layout/loading.gif') no-repeat center 170px;
background: resolve('layout/loading.gif') no-repeat center 170px;
}
.rich-cart {
... ... @@ -744,7 +745,6 @@
}
.sub-nav-list {
padding-left: 15%;
a {
color: #222;
... ... @@ -760,6 +760,10 @@
li:hover a {
border-color: #555;
}
li:first-child {
margin-left: 15%;
}
}
}
... ...
... ... @@ -6,7 +6,7 @@
.good-detail-img {
width: 100%;
height: 100%;
height: 315px;
position: relative;
.good-thumb,
... ... @@ -29,6 +29,24 @@
text-align: center;
bottom: 0;
}
.sale-out {
width: 100%;
height: 100%;
text-align: center;
top: 0;
position: absolute;
background: resolve('product/sale-out-bg.png');
}
.sale-out-tip {
width: 110px;
height: 110px;
margin-top: 105px;
display: inline-block;
background: resolve('product/sale-out-tip.png') no-repeat center center;
text-indent: -9999px;
}
}
.good-detail-text {
... ... @@ -47,7 +65,6 @@
> .price {
margin-top: 5px;
text-align: center;
}
.brand {
... ... @@ -63,57 +80,48 @@
margin-right: 15px;
}
span.vip-tag {
background-image: resolve("sale/vip.png");
background-repeat: no-repeat;
background-size: 100% 90%;
width: 40px;
.discount {
font-size: 12px;
line-height: 22px;
color: #fff;
font-style: italic;
margin-right: 10px;
margin-left: 10px;
width: 30px;
padding: 0 6px 0 16px;
background: resolve('product/discount-tag.png') no-repeat;
display: inline-block;
}
span.vip-1 {
background-image: resolve("product/silver-small.png");
.vip-span {
background-repeat: no-repeat;
width: 30px;
display: inline-block;
height: 12px;
background-size: 100% 100%;
width: 35px;
height: 15px;
line-height: 15px;
color: #fff;
font-style: italic;
margin-right: 10px;
margin-left: 10px;
position: absolute;
padding-right: 5px;
padding-left: 5px;
font-weight: bold;
}
span.vip-2 {
.vip-tag {
background-image: resolve("sale/vip.png");
}
.vip-1 {
background-image: resolve("product/silver-small.png");
float: left;
margin-top: -3px;
}
.vip-2 {
background-image: resolve("product/golden-small.png");
background-repeat: no-repeat;
width: 30px;
display: inline-block;
height: 12px;
color: #fff;
font-style: italic;
margin-right: 10px;
margin-left: 10px;
position: absolute;
float: left;
margin-top: -3px;
}
span.vip-3 {
.vip-3 {
background-image: resolve("product/platinum-small.png");
background-repeat: no-repeat;
width: 30px;
display: inline-block;
height: 12px;
color: #fff;
font-style: italic;
margin-right: 10px;
margin-left: 10px;
position: absolute;
float: left;
margin-top: -3px;
}
}
.col-btn {
... ...
... ... @@ -57,4 +57,8 @@
}
}
.brand .attr-content {
max-width: 730px;
}
}
... ...
... ... @@ -34,7 +34,6 @@
display: block;
}
.slide-wrapper {
height: 100%;
}
... ... @@ -242,10 +241,10 @@
.title {
font-size: 10px;
height: 40px;
height: 20px;
width: auto;
font-size: 10px;
line-height: 40px;
line-height: 20px;
text-align: center;
max-width: 200px;
overflow: hidden;
... ... @@ -260,7 +259,7 @@
}
.time {
font-size: 14px;
font-size: 13px;
}
}
}
... ... @@ -418,66 +417,6 @@
color: #565656;
font-size: 13px;
}
span.vip-tag {
background-image: resolve("sale/vip.png");
background-repeat: no-repeat;
background-size: 100% 90%;
width: 40px;
color: #fff;
font-style: italic;
margin-right: 5px;
margin-left: 5px;
width: 30px;
}
span.vip-1 {
background-image: resolve("product/silver-small.png");
background-repeat: no-repeat;
width: 30px;
display: inline-block;
height: 12px;
color: #fff;
font-style: italic;
margin-right: 5px;
margin-left: 5px;
position: absolute;
}
span.vip-2 {
background-image: resolve("product/golden-small.png");
background-repeat: no-repeat;
width: 30px;
display: inline-block;
height: 12px;
color: #fff;
font-style: italic;
margin-right: 5px;
margin-left: 5px;
position: absolute;
}
span.vip-3 {
background-image: resolve("product/platinum-small.png");
background-repeat: no-repeat;
width: 30px;
display: inline-block;
height: 12px;
color: #fff;
font-style: italic;
margin-right: 5px;
margin-left: 5px;
position: absolute;
}
.price-sale {
margin-left: 10px;
padding-left: 10px;
width: 36px;
height: 20px;
line-height: 20px;
background: url('../assets/images/furniture/sale-tag-bg.png?1450667948');
color: #fff;
}
}
}
... ... @@ -496,6 +435,47 @@
height: 77px;
}
}
.good-info {
.good-detail-img {
width: 100%;
height: 100%;
position: relative;
}
.good-detail-text {
> a {
margin-top: 16px;
line-height: 1.5;
display: block;
text-align: center;
@mixin ellipsis;
}
> .price {
margin-top: 5px;
text-align: center;
}
.brand {
display: none;
}
.market-price {
text-decoration: line-through;
margin-right: 15px;
color: #444;
font-weight: bold;
}
> .price {
margin-top: 5px;
font-weight: bold;
}
}
}
}
.sale-discount-page {
... ... @@ -514,9 +494,10 @@
display: inline-block;
margin-right: 10px;
padding: 0 10px;
height: 25px;
vertical-align: center;
font-weight: lighter;
line-height: 16px;
vertical-align: text-bottom;
line-height: 25px;
color: #fff;
background: #ff575c;
}
... ... @@ -555,4 +536,20 @@
.pager {
float: right;
}
.good-info {
.good-detail-text {
> .price {
margin-top: 5px;
text-align: center;
}
.market-price {
text-decoration: line-through;
margin-right: 15px;
color: #444;
font-weight: bold;
}
}
}
}
... ...
.sale-discount-page {
.sale-list-banner {
width: 100%;
width: 1150px;
position: relative;
margin: auto;
ul {
overflow: hidden;
... ... @@ -184,6 +185,28 @@
margin-right: 40px;
}
}
.good-info {
.good-detail-text {
> .price {
margin-top: 5px;
font-weight: bold;
}
.vip-1 {
float: left;
margin-top: -3px;
}
.vip-2 {
float: left;
margin-top: -3px;
}
.vip-3 {
float: left;
margin-top: -3px;
}
}
}
}
.min-screen .new-sale-page .new-brands .brands-wrap {
... ...
... ... @@ -18,6 +18,24 @@ const procProductImg = (product, gender) => {
return product.cover1 || product.cover2 || product.imagesUrl || '';
};
/**
* 处理列表大图周边小图数据,拼接添加 href
* @param origin goods 原始数据
* @returns {{}} goods 输出数据,结构不变
*/
const handleGoodsListData = (origin) => {
_.forEach(origin, (value, key) => {
if (!_.isEmpty(value.goodsList)) {
_.forEach(value.goodsList, (subValue, subKey) => {
origin[key].goodsList[subKey].url =
helpers.urlFormat(`/product/pro_${value.productId}_${subValue.goodsId}/${value.cnAlphabet}.html`);
});
}
});
return origin;
};
/**
* 商品搜索商品数据处理
*/
... ... @@ -42,7 +60,7 @@ exports.processProductList = (list, options) => {
return;
}
//折扣
// 折扣
product.discount = (product.salesPrice / product.marketPrice * 10).toFixed(1);
// 市场价和售价一样,则不显示市场价
... ... @@ -129,7 +147,7 @@ exports.processProductList = (list, options) => {
pruductList.push(product);
});
return pruductList;
return handleGoodsListData(pruductList);
};
... ...