Authored by yyq

merge

... ... @@ -73,7 +73,6 @@ exports.channel = (req, res) => {
outlets.getOutletsChannelData({ channel: req.params.channel }).then(outletsData => {
response.module = 'product';
response.page = 'outlets';
response.footerTop = true;
response.devEnv = true;
// 输出数据
... ...
... ... @@ -100,7 +100,8 @@ exports.discount = (req, res) => {
*/
exports.vip = (req, res) => {
let params = Object.assign({
saleType: 2
saleType: 2,
order: 's_t_asc,s_s_asc'
}, req.query);
params.uid = req.user.uid || 0;
... ... @@ -208,9 +209,7 @@ exports.breakingYards = (req, res) => {
* @return {[type]} [description]
*/
exports.getGoodsList = (req, res) => {
let params = Object.assign({
saleType: 1
}, req.query);
let params = req.query;
params.uid = req.user.uid || 0;
... ...
'use strict';
const library = '../../../library';
const helpers = require(`${library}/helpers`);
const _ = require('lodash');
const camelCase = require('../../../library/camel-case');
/**
* NL2R图片轮播
*/
const NL2R = (data) => {
const result = {
left: [],
right: [],
};
//左侧
_.forEach(data.left, (value, key) => {
result.left.push({
img: value.src,
url: value.url
});
})
//右侧
_.forEach(data.right, (value, key) => {
result.right.push({
img: value.src,
url: value.url
});
})
return result
}
/**
* 热门分类
*/
const hotCategory = (data) => {
return {
hotCategory: {
name: data.name,
list: data.menuNav.list,
blocks: data.menuNav.blocks,
brands: data.imgs.slice(0, 1),
types: data.imgs.slice(1, 7)
}
}
}
/**
* 分类导航
*/
const categoryNavigation = (data) => {
}
/**
* 处理楼层数据
* @param {[array]} list
* @return {[array]}
*/
exports.processFloor = (list) => {
const formatData = [];
var floorData;
list = list || [];
list = camelCase(list);
//格式化数据
_.forEach(list, (floor) => {
switch (floor.templateName) {
case 'NL2R':
floorData = NL2R(floor.data);
break;
case 'hotCategory':
floorData = hotCategory(floor.data);
break;
case 'categoryNavigation':
floorData = categoryNavigation(floor.data);
break;
default:
floorData = floor.data;
break;
}
Object.assign(formatData, floorData);
});
return formatData;
};
/**
* 组织嗨购数据
*/
exports.formatActivityData = (data) => {
var high = {
name: '限时嗨购',
imgHot: []
};
_.forEach(data, (value) => {
high.imgHot.push({
url: value.webUrl,
img: value.coverUrl,
logo: value.logoUrl,
name: value.title,
price: value.promotionName,
count: value.endTime
});
})
return high;
}
\ No newline at end of file
... ...
... ... @@ -9,87 +9,15 @@
const library = '../../../library';
const _ = require('lodash');
const API = require(`${library}/api`).API;
const ServiceAPI = require(`${global.library}/api`).ServiceAPI;
const serviceApi = new ServiceAPI();
const api = new API();
const outletsApi = require('./outlets-api');
// const helpers = require(`${library}/helpers`);
const sign = require(`${library}/sign`);
const helpers = require(`${library}/helpers`);
const camelCase = require('../../../library/camel-case');
// 奥莱频道资源码
const channelCode = {
boys: '2af513637dc5feeec7f6f8b52989b24b',
// 'boys' : 'e0565dad65fb8da1f39bc1ac83fc8346',
girls: 'd1b56b56c3a12dc1f2f83958680a0911',
kids: '0fd7ad594940f9ec5a03697317cf6521',
lifestyle: 'b3d3f55a26f130ac2b516b9fb3823711'
};
// nl2r 图片轮播
const nl2r = (data) => {
const result = {
left: [],
right: []
};
// 左侧
_.forEach(data.left, (value) => {
result.left.push({
img: value.src,
url: value.url
});
});
// 右侧
_.forEach(data.right, (value) => {
result.right.push({
img: value.src,
url: value.url
});
});
return result;
};
// 热门分类
const hotCategory = (data) => {
return {
hotCategory: {
name: data.name,
list: data.menuNav.list,
blocks: data.menuNav.blocks,
brands: data.imgs.slice(0, 1),
types: data.imgs.slice(1, 7)
}
};
};
/**
* 处理楼层数据
* @param {[array]} list
* @return {[array]}
*/
const processFloor = (list) => {
const formatData = [];
var floorData;
list = list || [];
list = camelCase(list);
// 格式化数据
_.forEach(list, (floor) => {
if (floor.templateName === 'NL2R' && floor.data) {
floorData = nl2r(floor.data);
}
if (floor.templateName === 'hotCategory' && floor.data) {
floorData = hotCategory(floor.data);
console.log(floorData);
}
Object.assign(formatData, floorData);
});
return formatData;
};
const saleApi = require('./sale-api');
const outletsProcess = require('./outlets-handler');
const outletsApi = require('./outlets-api');
/**
* 处理奥莱活动数据
... ... @@ -113,29 +41,6 @@ const handleOutletsActivityData = (origin) => {
};
/**
* 处理奥莱资源位数据
* @param {[type]} origin [description]
* @return {[type]} [description]
*/
const handleOutletsBannersData = (origin) => {
var dest = {};
dest.mainBanner = {};
_.forEach(origin.list, value => {
if (value.template_name === 'focus') {
dest.mainBanner.list = value.data;
}
if (value.template_name === 'threePicture') {
dest.column = value.data;
}
});
return dest;
};
/**
* 获取奥莱首页数据
* @param {[type]} origin [description]
* @return {[type]} [description]
... ... @@ -161,24 +66,31 @@ exports.getOutletsIndexData = (params) => {
});
};
// 奥莱频道资源码
const channelCode = {
boys: '2af513637dc5feeec7f6f8b52989b24b',
// 'boys' : 'e0565dad65fb8da1f39bc1ac83fc8346',
girls: 'd1b56b56c3a12dc1f2f83958680a0911',
kids: '0fd7ad594940f9ec5a03697317cf6521',
lifestyle: 'b3d3f55a26f130ac2b516b9fb3823711'
};
/**
* 获取奥莱频道页面数据
* @param {[object]} gender
* @return {[type]}
*/
exports.getOutletsChannelData = (params) => {
return api.all([
outletsApi.getChannelResouceData({
content_code: channelCode[params.channel]
}),
outletsApi.getOutletsActivityData()
]).then(result => {
var channelData = {};
return api.all([outletsApi.getChannelResouceData({content_code: channelCode[params.channel]}), outletsApi.getOutletsActivityOrigin({platform: 2, size: 0, type:1})]).then(result => {
if (result[0].code === 200) {
return processFloor(result[0].data.list);
Object.assign(channelData, outletsProcess.processFloor(result[0].data.list));
}
// if (result[1].code === 200) {}
if (result[1].code === 200) {
Object.assign(channelData, {flashSale: outletsProcess.formatActivityData(result[1].data)});
}
return channelData;
});
};
... ...
... ... @@ -2,7 +2,7 @@
* @Author: Targaryen
* @Date: 2016-05-25 18:16:59
* @Last Modified by: Targaryen
* @Last Modified time: 2016-06-01 17:01:39
* @Last Modified time: 2016-06-01 18:58:00
*/
'use strict';
... ... @@ -441,11 +441,14 @@ exports.handleSaleSortData = (origin, params) => {
leftContent.allSort.list = [];
_.forEach(origin, function(value) {
let category = {};
category.name = value.category_name;
category.num = value.node_count;
category.childList = [];
category.checked = (params.sort === value.relation_parameter.sort) ? true : false;
category.href = handleFilterUrl(params, { sort: value.relation_parameter.sort });
let gender = !_.isEmpty(params.gender) ? `&gender=${params.gender}` : '';
... ... @@ -575,26 +578,26 @@ exports.handleSaleCategoryData = () => {
urlLocation: 'www.baidu.com',
navItem: [{
vip: true,
urlLocation: '?saleType=2&order=s_t_desc',
urlLocation: '?saleType=2&order=s_t_desc&limit=11',
title: '今日推荐'
}, {
incompleteSize: true,
urlLocation: '?saleType=2&order=s_t_desc&' +
urlLocation: '?saleType=2&order=s_t_desc&limit=11&' +
'sort=119,114,115,124,258,123,125,121,227,117,116,293,173,122,118,413',
title: '上装'
}, {
newDiscount: true,
urlLocation: '?saleType=2&order=s_t_desc&' +
urlLocation: '?saleType=2&order=s_t_desc&limit=11&' +
'sort=129,130,131,346,133,348',
title: '裤装'
}, {
vip: true,
urlLocation: '?saleType=2&order=s_t_desc&' +
urlLocation: '?saleType=2&order=s_t_desc&limit=11&' +
'sort=147,148,151,149',
title: '鞋履'
}, {
vip: true,
urlLocation: '?saleType=2&order=s_t_desc&' +
urlLocation: '?saleType=2&order=s_t_desc&limit=11&' +
'sort=152,153,186,313,162,311,322,75,235,424,142,238,211' +
',76,156,171,376,407,275,397,272,212,267,277,405,357,273,' +
'401,240,323,327,157,163,342,160,167,234,111,432,183,373,' +
... ... @@ -610,26 +613,26 @@ exports.handleSaleCategoryData = () => {
urlLocation: 'www',
navItem: [{
vip: true,
urlLocation: '?saleType=1&order=s_t_desc',
urlLocation: '?saleType=1&order=s_t_desc&limit=19',
title: '今日推荐'
}, {
incompleteSize: true,
urlLocation: '?saleType=1&order=s_t_desc&' +
urlLocation: '?saleType=1&order=s_t_desc&limit=19&' +
'sort=119,114,115,124,258,123,125,121,227,117,116,293,173,122,118,413',
title: '上装'
}, {
newDiscount: true,
urlLocation: '?saleType=1&order=s_t_desc&' +
urlLocation: '?saleType=1&order=s_t_desc&limit=19&' +
'sort=129,130,131,346,133,348',
title: '裤装'
}, {
vip: true,
urlLocation: '?saleType=1&order=s_t_desc&' +
urlLocation: '?saleType=1&order=s_t_desc&limit=19&' +
'sort=147,148,151,149',
title: '鞋履'
}, {
vip: true,
urlLocation: '?saleType=1&order=s_t_desc&' +
urlLocation: '?saleType=1&order=s_t_desc&limit=19&' +
'sort=152,153,186,313,162,311,322,75,235,424,142,238,211' +
',76,156,171,376,407,275,397,272,212,267,277,405,357,273,' +
'401,240,323,327,157,163,342,160,167,234,111,432,183,373,' +
... ...
... ... @@ -2,7 +2,7 @@
* @Author: Targaryen
* @Date: 2016-05-19 10:20:08
* @Last Modified by: Targaryen
* @Last Modified time: 2016-06-01 16:54:20
* @Last Modified time: 2016-06-01 18:46:02
*/
'use strict';
... ... @@ -29,8 +29,25 @@ exports.getSaleGoodsData = (params) => {
if (result[0].code === 200) {
finalResult.goods = productProcess.processProductList(result[0].data.product_list);
switch (params.saleType) {
case '1':
finalResult.goods.push({
thumb: 'http://img10.static.yhbimg.com/product/2014/01/15/11/01fa01614784f6239760f1b749663016f1.jpg?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/90',
url: 'http://localhost:6002/product/sale/breakingYards'
});
break;
case '2':
finalResult.goods.push({
thumb: 'http://img10.static.yhbimg.com/product/2014/01/15/11/01fa01614784f6239760f1b749663016f1.jpg?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/90',
url: 'http://localhost:6002/product/sale/vip'
});
break;
default:
break;
}
}
// 处理 VIP 商品数据
if (result[1].code === 200 && parseInt(params.saleType, 10) === 2) {
_.forEach(finalResult.goods, (value, key) => {
... ... @@ -103,9 +120,8 @@ exports.getSaleOthersData = (params) => {
promiseObject = [
saleApi.getSaleGoodsList(params),
saleApi.getSaleBannerList(cCode),
saleApi.getLeftContentList()
// saleApi.getUserProfile(params.uid) // 不处理 VIP
saleApi.getLeftContentList(),
saleApi.getUserProfile(params.uid)
];
} else {
cCode = '7c2b77093421efa8ae9302c91460db73';
... ... @@ -131,6 +147,12 @@ exports.getSaleOthersData = (params) => {
finalResult.opts = saleHandler.handleSaleOptsData(params, result[0].data.total);
finalResult.totalCount = result[0].data.total;
finalResult.pager = saleHandler.handleSalePagerData(result[0].data.total, params);
// 处理所有商品标题数据
finalResult.saleTitle = {};
finalResult.saleTitle.name = '所有商品';
finalResult.saleTitle.count = finalResult.totalCount;
}
// 获取焦点图数据
... ... @@ -147,14 +169,31 @@ exports.getSaleOthersData = (params) => {
}
}
// 不处理 VIP
// if (!_.isEmpty(params) && params.saleType === 2) {
// 处理 VIP 商品数据
if (result[3].code === 200 && parseInt(params.saleType, 10) === 2) {
_.forEach(finalResult.goods, (value, key) => {
switch (result[3].curLevel) {
case '1':
finalResult.goods[key].vipPrice = value.vip1_price;
finalResult.goods[key].vip1 = true;
break;
case '2':
finalResult.goods[key].vipPrice = value.vip2_price;
finalResult.goods[key].vip2 = true;
break;
case '3':
finalResult.goods[key].vipPrice = value.vip3_price;
finalResult.goods[key].vip3 = true;
break;
default:
finalResult.goods[key].vipPrice = value.vip_price;
finalResult.goods[key].vip = true;
break;
}
// // 获取用户数据
// if (result[3].code === 200) {
// finalResult.vip = result[3].curLevel > 0 ? result[3].curLevel : false;
// }
// }
});
}
return finalResult;
});
... ... @@ -177,8 +216,14 @@ exports.getSaleDiscountData = (params) => {
finalResult.saleList = {};
finalResult.saleList.goods = productProcess.processProductList(result[0].data.product_list);
finalResult.leftContent = saleHandler.handleSaleSortData(result[0].data.filter.group_sort, params);
finalResult.totalCount = result[0].data.total;
finalResult.pager = saleHandler.handleSalePagerData(result[0].data.total, params);
finalResult.saleList.totalCount = result[0].data.total;
finalResult.saleList.pager = saleHandler.handleSalePagerData(result[0].data.total, params);
// 处理所有商品标题数据
finalResult.saleTitle = {};
finalResult.saleTitle.name = '所有商品';
finalResult.saleTitle.count = finalResult.totalCount;
}
// 处理焦点图数据
... ...
{{!-- <pre>{{resultShow}}</pre> --}}
{{# result}}
{{#each goods}}
<div class="good-info" data-skn="{{skn}}" data-from="{{from}}">
<div class="good-info {{#if vip}} good-info-big{{/if}} {{#if vip1}} good-info-big{{/if}} {{#if vip2}} good-info-big{{/if}} {{#if vip3}} good-info-big{{/if}}" data-skn="{{skn}}" data-from="{{from}}">
<div class="tag-container clearfix">
{{# tags}}
{{# isNew}}
... ... @@ -29,7 +29,7 @@
</div>
<div class="good-detail-img">
<a class="good-thumb" href="{{url}}" target="_blank">
<img class="lazy" data-original="{{image thumb 235 315}}">
<img class="lazy" data-original="{{image thumb 280 375}}">
</a>
{{# isFew}}
<p class="few-tag">即将售罄</p>
... ... @@ -53,10 +53,10 @@
<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-tag">VIPⅠ </span><strong>{{vipPrice}}</strong>{{/vip1}}
{{#vip2}}<span class="vip-tag">VIPⅡ </span><strong>{{vipPrice}}</strong>{{/vip2}}
{{#vip3}}<span class="vip-tag">VIPⅢ </span><strong>{{vipPrice}}</strong>{{/vip3}}
{{#vip}}<span class="vip-tag"> VIP </span><strong>{{vipPrice}}</strong>{{/vip}}
{{#vip1}}<span class="vip-1"> </span><strong>{{vipPrice}}</strong>{{/vip1}}
{{#vip2}}<span class="vip-2"> </span><strong>{{vipPrice}}</strong>{{/vip2}}
{{#vip3}}<span class="vip-3"> </span><strong>{{vipPrice}}</strong>{{/vip3}}
</p>
</div>
</div>
... ...
... ... @@ -17,7 +17,7 @@
{{/if}}
<div class="time pull-right">
<span class="iconfont">&#xe60d;</span>{{time}}
<span class="iconfont">&#xe60a;</span>{{time}}
</div>
</div>
{{/saleTitle}}
... ... @@ -26,7 +26,7 @@
{{#leftContent}}
{{#allSort}}
{{#list}}
<li class="{{#if active}}active{{/if}}"><a href="#">{{name}}{{#if number}}({{number}}){{/if}}</a></li>
<li class="{{#if checked}}active{{/if}}"><a href="{{href}}">{{name}}({{num}})</a></li>
{{/list}}
{{/allSort}}
{{/leftContent}}
... ...
... ... @@ -5,13 +5,13 @@
{{#each imgHot}}
<li>
<a href="{{href}}" target= "_blank"><div class="flash-sale-banner">
<img src="{{img}}"/></div>
<img src="{{image img 560 260}}"/></div>
<div class="flash-sale-bottom">
<p class="flash-sale-count">{{count}}折起</p>
<p class="flash-sale-name">{{name}}</p>
<p class="flash-sale-timer">timer</p>
<div class="flash-sale-logo">
<img src="{{logo}}"/>
<img src="{{image logo 100 60}}"/>
</div>
</div>
</a>
... ...
<div class="activity-entry clearfix">
{{#activityEnter}}
<img class="entry-item pull-left {{#if @first}}first{{/if}} {{#if @last}}last{{/if}}" href="{{link}}" src="{{image icon 330 300}}">
<a href="{{href}}">
<img class="entry-item pull-left {{#if @first}}first{{/if}} {{#if @last}}last{{/if}}" src="{{image icon 330 300}}">
</img>
</a>
{{/activityEnter}}
</div>
... ...
<div class="good-info" data-skn="{{skn}}" data-from="{{from}}">
<div class="good-info {{#if vip}} good-info-big{{/if}} {{#if vip1}} good-info-big{{/if}} {{#if vip2}} good-info-big{{/if}} {{#if vip3}} good-info-big{{/if}}" data-skn="{{skn}}" data-from="{{from}}">
<div class="tag-container clearfix">
{{# tags}}
{{# isNew}}
... ... @@ -26,7 +26,7 @@
</div>
<div class="good-detail-img">
<a class="good-thumb" href="{{url}}" target="_blank">
<img class="lazy" data-original="{{image thumb 235 315}}">
<img class="lazy" data-original="{{image thumb 280 375}}">
</a>
{{# isFew}}
<p class="few-tag">即将售罄</p>
... ... @@ -50,6 +50,10 @@
<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><strong>{{vipPrice}}</strong>{{/vip1}}
{{#vip2}}<span class="vip-2"> </span><strong>{{vipPrice}}</strong>{{/vip2}}
{{#vip3}}<span class="vip-3"> </span><strong>{{vipPrice}}</strong>{{/vip3}}
</p>
<div class="goodsList hide">
{{#goodsList}}
... ...
... ... @@ -71,6 +71,40 @@
font-style: italic;
margin-right: 5px;
}
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;
}
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;
}
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;
}
}
.col-btn {
... ... @@ -210,3 +244,10 @@
}
}
.good-info-big {
width: 280px;
margin-right: 10px;
float: left;
margin-bottom: 35px;
}
... ...
... ... @@ -402,6 +402,9 @@
background-image: resolve("sale/vip.png");
background-repeat: no-repeat;
background-size: 100% 90%;
width: 30px;
display: inline-block;
height: 10px;
color: #fff;
font-style: italic;
margin-right: 5px;
... ... @@ -489,4 +492,7 @@
}
}
}
.pager {
float: right;
}
}
... ...