Authored by 周少峰

Merge branch 'feature/newArrivals' into gray

... ... @@ -12,8 +12,10 @@ const channelModel = require('../models/index');
exports.index = (req, res, next) => {
let channelType = req.path.split('/')[1] || 'boys';
let poolId = req.query.template_id;
let isJKChannel = req.query.mChannel === 'japanKorean';
channelModel.getContent(channelType).then(data => {
channelModel.getContent(channelType, isJKChannel, poolId).then(data => {
// channel为空不缓存
if (_.isEmpty(data.channel)) {
... ...
... ... @@ -1138,11 +1138,15 @@ const getNewArrival = (channel, isJKChannel, poolId)=> {
* @param {String} type 传入频道页类型,值可以是: boys, girls, kids, lifestyle
* @return {Object}
*/
const getContent = (type) => {
const getContent = (type, isJKChannel, poolId) => {
let params = {new_device: 'Y'};
return Promise.all([headerModel.requestHeaderData(type), _requestContent(type, params)]).then(res => {
return Promise.all([
headerModel.requestHeaderData(type),
_requestContent(type, params),
getNewArrival(type, isJKChannel, poolId)
]).then(res => {
let headerData = res[0].data || res[0],
contentData = res[1].data ? res[1].data.list : res[1];
... ... @@ -1156,8 +1160,14 @@ const getContent = (type) => {
data.page = 'channel';
data.pageType = type;
data.footerTop = true;
data.channel = processResult.floors;
data.channel = processResult.floors.map(function(elem) {
if (elem.newArrivls) {
elem.newArrivls.goods = res[2];
}
return elem;
});
return {
rawData: contentData,
... ... @@ -1188,9 +1198,9 @@ const getContent = (type) => {
return result.floorData;
});
} else {
return result.floorData || result;
}
return result.floorData || result;
});
};
... ... @@ -1200,61 +1210,70 @@ const getContent = (type) => {
* @return {Object}
*/
const getJKContent = (req) => {
let channel = req.query.channel,
let channel = req.query.channel || req.yoho.channel || 'boys',
contentCode = req.query.content_code;
return Promise.all([headerModel.requestHeaderData(channel),
_requestContent(channel, {}, contentCode)]).then(res => {
return Promise.all([
headerModel.requestHeaderData(channel),
_requestContent(channel, {}, contentCode),
getNewArrival(channel, true, req.query.template_id)
]).then(res => {
let headerData = res[0].data || res[0],
contentData = res[1].data ? res[1].data.list : res[1];
let headerData = res[0].data || res[0],
contentData = res[1].data ? res[1].data.list : res[1];
let data = {};
let data = {};
const processResult = _processJKFloorData(contentData);
const processResult = _processJKFloorData(contentData);
data = headerData;
data.module = 'channel';
data.page = 'channel';
data.pageType = channel;
data.mchannel = 'japanKorean';// 子频道,如日韩馆
data.footerTop = true;
data.channel = processResult.floors;
data = headerData;
data.module = 'channel';
data.page = 'channel';
data.pageType = channel;
data.mchannel = 'japanKorean';// 子频道,如日韩馆
data.footerTop = true;
data.channel = processResult.floors.map(function(elem) {
if (elem.newArrivls) {
elem.newArrivls.goods = res[2];
}
return {
rawData: contentData,
floorData: data,
searchPromise: processResult.promise,
singlehotFloorIndex: processResult.singlehotFloorIndex,
singlehotFloorTitle: processResult.singlehotFloorTitle,
queryParams: processResult.queryParams,
channelType: channel
};
return elem;
});
return {
rawData: contentData,
floorData: data,
searchPromise: processResult.promise,
singlehotFloorIndex: processResult.singlehotFloorIndex,
singlehotFloorTitle: processResult.singlehotFloorTitle,
queryParams: processResult.queryParams,
channelType: channel
};
}).then(result => {
}).then(result => {
// 如果有promise则做相应处理
if (result.searchPromise.length) {
return Promise.all(result.searchPromise).then(res => {
_.forEach(res, (data, index) => {
result.floorData.channel
.splice(result.singlehotFloorIndex[index], 0,
_processFloorDataWithQueryReusult(
result.rawData,
result.queryParams[index],
data,
result.singlehotFloorTitle[index],
result.channelType
));
});
if (result.searchPromise.length) {
return Promise.all(result.searchPromise).then(res => {
_.forEach(res, (data, index) => {
result.floorData.channel
.splice(result.singlehotFloorIndex[index], 0,
_processFloorDataWithQueryReusult(
result.rawData,
result.queryParams[index],
data,
result.singlehotFloorTitle[index],
result.channelType
));
});
return result.floorData;
});
} else {
return result.floorData || result;
}
return result.floorData;
});
}
return result.floorData || result;
});
};
const getResourceData = (formatData) => {
... ...
... ... @@ -2,11 +2,13 @@
{{> common/floor-header}}
<div class="goods-container clearfix">
{{> product/new-arrivis}}
</div>
<div class="loading">
{{# navs}}
{{#if @last}}
<a href="{{url}}" target= "_blank">Loading...</a>
<a href="{{url}}" target= "_blank">查看更多</a>
{{/if}}
{{/ navs}}
</div>
... ...
... ... @@ -43,7 +43,7 @@ const apply = (req, res, next) => {
refer: helpers.urlFormat('/settled/apply', null, 'shop')
});
res.redirect(loginUrl);
return res.redirect(loginUrl);
}
let responseData = {
... ...
... ... @@ -17,10 +17,10 @@ module.exports = {
cookieDomain: '.yohobuy.com',
domains: {
// test3
singleApi: 'http://api-test3.yohops.com:9999/',
api: 'http://api-test3.yohops.com:9999/',
service: 'http://service-test3.yohops.com:9999/',
serviceNotify: 'http://service-test3.yohops.com:9999/',
// singleApi: 'http://api-test3.yohops.com:9999/',
// api: 'http://api-test3.yohops.com:9999/',
// service: 'http://service-test3.yohops.com:9999/',
// serviceNotify: 'http://service-test3.yohops.com:9999/',
// prod
// singleApi: 'http://single.yoho.cn/',
... ... @@ -29,9 +29,9 @@ module.exports = {
// serviceNotify: 'http://service.yoho.cn/',
// gray
// singleApi: 'http://single.gray.yohops.com/',
// api: 'http://api.gray.yohops.com/',
// service: 'http://service.gray.yohops.com/',
singleApi: 'http://single.gray.yohops.com/',
api: 'http://api.gray.yohops.com/',
service: 'http://service.gray.yohops.com/',
// dev
// api: 'http://dev-api.yohops.com:9999/',
... ...
{{#each goods}}
<div class="good-info imgopacity" data-skn="{{skn}}">
<div class="tag-container clearfix">
{{# tags}}
{{# isNew}}
<span class="good-tag new-tag">NEW</span>
{{/ isNew}}
{{# isReNew}}
<span class="good-tag renew-tag">再到着</span>
{{/ isReNew}}
{{# isSale}}
<span class="good-tag sale-tag">SALE</span>
{{/ isSale}}
{{# isNewFestival}}
<span class="good-tag new-festival-tag">新品节</span>
{{/ isNewFestival}}
{{# isLimit}}
<span class="good-tag limit-tag">限量商品</span>
{{/ isLimit}}
{{# isYearEndPromotion}}
<span class="good-tag yep-tag">年终大促</span>
{{/ isYearEndPromotion}}
{{# isYearMidPromotion}}
<span class="good-tag ymp-tag">年中热促</span>
{{/ isYearMidPromotion}}
{{/ tags}}
</div>
<div class="good-detail-img">
<a class="good-thumb" href="{{url}}" target= "_blank">
<img class="lazy" data-original="{{image2 thumb}}">
</a>
{{# isFew}}
<p class="few-tag">即将售罄</p>
{{/ isFew}}
{{#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">{{name}}</a>
<p class="price">
<span class="sale-price{{#unless marketPrice}}prime-cost{{/unless}}">
¥{{salePrice}}
</span>
{{# marketPrice}}
<span class="market-price">¥{{.}}</span>
{{/ marketPrice}}
</p>
</div>
</div>
{{/each}}
... ...
... ... @@ -16,5 +16,5 @@ $qrcodeImg.qrcode({
});
$qrcodeActivity.mouseenter(function() {
window._hmt.push(['_trackEvent', '二维码', '活动页', 'id', $(this).attr('data-id')]);
window._hmt && window._hmt.push(['_trackEvent', '二维码', '活动页', 'id', $(this).attr('data-id')]);
});
... ...
... ... @@ -11,7 +11,6 @@ var homePage = $('.home-page').data('page'),
shownum = $('.logo-brand').data('shownum'),
mChannel = $('.home-page').data('mchannel') || '';
var newArrParams = {};
var yas = require('../common/data-yas');
// 给头部js获取当前频道
... ... @@ -29,24 +28,12 @@ require('../common/center-slider');
$(document).on('mouseenter', '.imgopacity a img', function() {
$(this).css('opacity', 0.8); // eslint-disable-line
});
$(document).on('mouseout', '.imgopacity a img', function() {
$(this).css('opacity', 1); // eslint-disable-line
});
if ($.inArray(homePage, ['boys', 'girls', 'kids', 'lifestyle']) > -1) {
newArrParams = {
type: homePage,
url: '/common/getNewArrival',
count: (homePage === 'boys') || (homePage === 'lifestyle') ? 5 : 4,
rows: [5, 3]
};
if (mChannel !== '') {
newArrParams.mChannel = mChannel;
newArrParams.poolId = window.queryString().template_id;
}
require('../product/index/new-arrivls')(newArrParams);
window.setCookie('_Channel', homePage, {
domain: '.yohobuy.com',
path: '/',
... ... @@ -54,8 +41,8 @@ if ($.inArray(homePage, ['boys', 'girls', 'kids', 'lifestyle']) > -1) {
});
}
// lazyLoad($('img.lazy'));
lazyLoad($('img.lazy'));
if (homePage === 'boys') {
$('.slide-container').slider({
pagination: '.thumb-pagination'
... ...
... ... @@ -146,9 +146,9 @@ $returnTop.click(function() {
});
$qrcodeHoverBox.mouseenter(function() {
window._hmt.push(['_trackEvent', '二维码', '右侧悬浮', '', '']);
window._hmt && window._hmt.push(['_trackEvent', '二维码', '右侧悬浮', '', '']);
}).click(function() {
window._hmt.push(['_trackEvent', '二维码', '右侧悬浮', '', '']);
window._hmt && window._hmt.push(['_trackEvent', '二维码', '右侧悬浮', '', '']);
});
$(window).scroll(function() {
... ...
... ... @@ -85,9 +85,9 @@ $('#signin-url').attr('href', window.signinUrl());
$('#reg-url').attr('href', window.registerUrl());
$('.phoneapp').mouseenter(function() {
_hmt.push(['_trackEvent', '二维码', '头部手机版', '', '']); // eslint-disable-line
window._html && window._hmt.push(['_trackEvent', '二维码', '头部手机版', '', '']); // eslint-disable-line
}).click(function() {
_hmt.push(['_trackEvent', '二维码', '头部手机版', '', '']); // eslint-disable-line
window._html && window._hmt.push(['_trackEvent', '二维码', '头部手机版', '', '']); // eslint-disable-line
});
// handlebars模板
... ...
... ... @@ -670,7 +670,7 @@ exports.init = function(page) {
$('.qrcode-hover-reg').mouseenter(function() {
window._hmt.push(['_trackEvent', '二维码', '注册页', '', '']);
window._hmt && window._hmt.push(['_trackEvent', '二维码', '注册页', '', '']);
}).click(function() {
window._hmt.push(['_trackEvent', '二维码', '注册页', '', '']);
window._hmt && window._hmt.push(['_trackEvent', '二维码', '注册页', '', '']);
});
... ...
... ... @@ -401,7 +401,7 @@ bindEvent.add(function() {
});
$('#code-buy').mouseenter(function() {
window._hmt.push(['_trackEvent', '二维码', '商品详情页', 'skn', $(this).attr('skn')]);
window._hmt && window._hmt.push(['_trackEvent', '二维码', '商品详情页', 'skn', $(this).attr('skn')]);
});
// 是否能:量贩购买,量贩小于库存才能购买
... ...
... ... @@ -144,7 +144,7 @@ $qrcodeImg.qrcode({
});
$('.qrcode-hover-box').mouseenter(function() {
window._hmt.push(['_trackEvent', '二维码', '普通店铺', 'shopId', $(this).attr('data-id')]);
window._hmt && window._hmt.push(['_trackEvent', '二维码', '普通店铺', 'shopId', $(this).attr('data-id')]);
});
require('./good-slide');
... ...
... ... @@ -43,11 +43,9 @@ $qrcodeImg.qrcode({
});
$('.qrcode-decoration').mouseenter(function() {
window._hmt.push(['_trackEvent', '二维码', '经典店铺', 'shopId', $(this).attr('data-id')]);
window._hmt && window._hmt.push(['_trackEvent', '二维码', '经典店铺', 'shopId', $(this).attr('data-id')]);
});
// require('../product/list');
product.init(4);
lazyLoad($('img.lazy'));
... ...