Authored by 周少峰

Merge branch 'feature/newArrivals' into gray

@@ -12,8 +12,10 @@ const channelModel = require('../models/index'); @@ -12,8 +12,10 @@ const channelModel = require('../models/index');
12 12
13 exports.index = (req, res, next) => { 13 exports.index = (req, res, next) => {
14 let channelType = req.path.split('/')[1] || 'boys'; 14 let channelType = req.path.split('/')[1] || 'boys';
  15 + let poolId = req.query.template_id;
  16 + let isJKChannel = req.query.mChannel === 'japanKorean';
15 17
16 - channelModel.getContent(channelType).then(data => { 18 + channelModel.getContent(channelType, isJKChannel, poolId).then(data => {
17 19
18 // channel为空不缓存 20 // channel为空不缓存
19 if (_.isEmpty(data.channel)) { 21 if (_.isEmpty(data.channel)) {
@@ -1138,11 +1138,15 @@ const getNewArrival = (channel, isJKChannel, poolId)=> { @@ -1138,11 +1138,15 @@ const getNewArrival = (channel, isJKChannel, poolId)=> {
1138 * @param {String} type 传入频道页类型,值可以是: boys, girls, kids, lifestyle 1138 * @param {String} type 传入频道页类型,值可以是: boys, girls, kids, lifestyle
1139 * @return {Object} 1139 * @return {Object}
1140 */ 1140 */
1141 -const getContent = (type) => { 1141 +const getContent = (type, isJKChannel, poolId) => {
1142 1142
1143 let params = {new_device: 'Y'}; 1143 let params = {new_device: 'Y'};
1144 1144
1145 - return Promise.all([headerModel.requestHeaderData(type), _requestContent(type, params)]).then(res => { 1145 + return Promise.all([
  1146 + headerModel.requestHeaderData(type),
  1147 + _requestContent(type, params),
  1148 + getNewArrival(type, isJKChannel, poolId)
  1149 + ]).then(res => {
1146 1150
1147 let headerData = res[0].data || res[0], 1151 let headerData = res[0].data || res[0],
1148 contentData = res[1].data ? res[1].data.list : res[1]; 1152 contentData = res[1].data ? res[1].data.list : res[1];
@@ -1156,8 +1160,14 @@ const getContent = (type) => { @@ -1156,8 +1160,14 @@ const getContent = (type) => {
1156 data.page = 'channel'; 1160 data.page = 'channel';
1157 data.pageType = type; 1161 data.pageType = type;
1158 data.footerTop = true; 1162 data.footerTop = true;
1159 - data.channel = processResult.floors; 1163 + data.channel = processResult.floors.map(function(elem) {
1160 1164
  1165 + if (elem.newArrivls) {
  1166 + elem.newArrivls.goods = res[2];
  1167 + }
  1168 +
  1169 + return elem;
  1170 + });
1161 1171
1162 return { 1172 return {
1163 rawData: contentData, 1173 rawData: contentData,
@@ -1188,9 +1198,9 @@ const getContent = (type) => { @@ -1188,9 +1198,9 @@ const getContent = (type) => {
1188 1198
1189 return result.floorData; 1199 return result.floorData;
1190 }); 1200 });
1191 - } else {  
1192 - return result.floorData || result;  
1193 } 1201 }
  1202 +
  1203 + return result.floorData || result;
1194 }); 1204 });
1195 }; 1205 };
1196 1206
@@ -1200,61 +1210,70 @@ const getContent = (type) => { @@ -1200,61 +1210,70 @@ const getContent = (type) => {
1200 * @return {Object} 1210 * @return {Object}
1201 */ 1211 */
1202 const getJKContent = (req) => { 1212 const getJKContent = (req) => {
1203 - let channel = req.query.channel, 1213 + let channel = req.query.channel || req.yoho.channel || 'boys',
1204 contentCode = req.query.content_code; 1214 contentCode = req.query.content_code;
1205 1215
1206 - return Promise.all([headerModel.requestHeaderData(channel),  
1207 - _requestContent(channel, {}, contentCode)]).then(res => { 1216 + return Promise.all([
  1217 + headerModel.requestHeaderData(channel),
  1218 + _requestContent(channel, {}, contentCode),
  1219 + getNewArrival(channel, true, req.query.template_id)
  1220 + ]).then(res => {
1208 1221
1209 - let headerData = res[0].data || res[0],  
1210 - contentData = res[1].data ? res[1].data.list : res[1]; 1222 + let headerData = res[0].data || res[0],
  1223 + contentData = res[1].data ? res[1].data.list : res[1];
1211 1224
1212 - let data = {}; 1225 + let data = {};
1213 1226
1214 - const processResult = _processJKFloorData(contentData); 1227 + const processResult = _processJKFloorData(contentData);
1215 1228
1216 - data = headerData;  
1217 - data.module = 'channel';  
1218 - data.page = 'channel';  
1219 - data.pageType = channel;  
1220 - data.mchannel = 'japanKorean';// 子频道,如日韩馆  
1221 - data.footerTop = true;  
1222 - data.channel = processResult.floors; 1229 + data = headerData;
  1230 + data.module = 'channel';
  1231 + data.page = 'channel';
  1232 + data.pageType = channel;
  1233 + data.mchannel = 'japanKorean';// 子频道,如日韩馆
  1234 + data.footerTop = true;
  1235 + data.channel = processResult.floors.map(function(elem) {
1223 1236
  1237 + if (elem.newArrivls) {
  1238 + elem.newArrivls.goods = res[2];
  1239 + }
1224 1240
1225 - return {  
1226 - rawData: contentData,  
1227 - floorData: data,  
1228 - searchPromise: processResult.promise,  
1229 - singlehotFloorIndex: processResult.singlehotFloorIndex,  
1230 - singlehotFloorTitle: processResult.singlehotFloorTitle,  
1231 - queryParams: processResult.queryParams,  
1232 - channelType: channel  
1233 - }; 1241 + return elem;
  1242 + });
  1243 +
  1244 + return {
  1245 + rawData: contentData,
  1246 + floorData: data,
  1247 + searchPromise: processResult.promise,
  1248 + singlehotFloorIndex: processResult.singlehotFloorIndex,
  1249 + singlehotFloorTitle: processResult.singlehotFloorTitle,
  1250 + queryParams: processResult.queryParams,
  1251 + channelType: channel
  1252 + };
1234 1253
1235 - }).then(result => { 1254 + }).then(result => {
1236 1255
1237 // 如果有promise则做相应处理 1256 // 如果有promise则做相应处理
1238 - if (result.searchPromise.length) {  
1239 - return Promise.all(result.searchPromise).then(res => {  
1240 - _.forEach(res, (data, index) => {  
1241 - result.floorData.channel  
1242 - .splice(result.singlehotFloorIndex[index], 0,  
1243 - _processFloorDataWithQueryReusult(  
1244 - result.rawData,  
1245 - result.queryParams[index],  
1246 - data,  
1247 - result.singlehotFloorTitle[index],  
1248 - result.channelType  
1249 - ));  
1250 - }); 1257 + if (result.searchPromise.length) {
  1258 + return Promise.all(result.searchPromise).then(res => {
  1259 + _.forEach(res, (data, index) => {
  1260 + result.floorData.channel
  1261 + .splice(result.singlehotFloorIndex[index], 0,
  1262 + _processFloorDataWithQueryReusult(
  1263 + result.rawData,
  1264 + result.queryParams[index],
  1265 + data,
  1266 + result.singlehotFloorTitle[index],
  1267 + result.channelType
  1268 + ));
  1269 + });
1251 1270
1252 - return result.floorData;  
1253 - });  
1254 - } else {  
1255 - return result.floorData || result;  
1256 - } 1271 + return result.floorData;
1257 }); 1272 });
  1273 + }
  1274 +
  1275 + return result.floorData || result;
  1276 + });
1258 }; 1277 };
1259 1278
1260 const getResourceData = (formatData) => { 1279 const getResourceData = (formatData) => {
@@ -2,11 +2,13 @@ @@ -2,11 +2,13 @@
2 {{> common/floor-header}} 2 {{> common/floor-header}}
3 3
4 <div class="goods-container clearfix"> 4 <div class="goods-container clearfix">
  5 + {{> product/new-arrivis}}
5 </div> 6 </div>
  7 +
6 <div class="loading"> 8 <div class="loading">
7 {{# navs}} 9 {{# navs}}
8 {{#if @last}} 10 {{#if @last}}
9 - <a href="{{url}}" target= "_blank">Loading...</a> 11 + <a href="{{url}}" target= "_blank">查看更多</a>
10 {{/if}} 12 {{/if}}
11 {{/ navs}} 13 {{/ navs}}
12 </div> 14 </div>
@@ -43,7 +43,7 @@ const apply = (req, res, next) => { @@ -43,7 +43,7 @@ const apply = (req, res, next) => {
43 refer: helpers.urlFormat('/settled/apply', null, 'shop') 43 refer: helpers.urlFormat('/settled/apply', null, 'shop')
44 }); 44 });
45 45
46 - res.redirect(loginUrl); 46 + return res.redirect(loginUrl);
47 } 47 }
48 48
49 let responseData = { 49 let responseData = {
@@ -17,10 +17,10 @@ module.exports = { @@ -17,10 +17,10 @@ module.exports = {
17 cookieDomain: '.yohobuy.com', 17 cookieDomain: '.yohobuy.com',
18 domains: { 18 domains: {
19 // test3 19 // test3
20 - singleApi: 'http://api-test3.yohops.com:9999/',  
21 - api: 'http://api-test3.yohops.com:9999/',  
22 - service: 'http://service-test3.yohops.com:9999/',  
23 - serviceNotify: 'http://service-test3.yohops.com:9999/', 20 + // singleApi: 'http://api-test3.yohops.com:9999/',
  21 + // api: 'http://api-test3.yohops.com:9999/',
  22 + // service: 'http://service-test3.yohops.com:9999/',
  23 + // serviceNotify: 'http://service-test3.yohops.com:9999/',
24 24
25 // prod 25 // prod
26 // singleApi: 'http://single.yoho.cn/', 26 // singleApi: 'http://single.yoho.cn/',
@@ -29,9 +29,9 @@ module.exports = { @@ -29,9 +29,9 @@ module.exports = {
29 // serviceNotify: 'http://service.yoho.cn/', 29 // serviceNotify: 'http://service.yoho.cn/',
30 30
31 // gray 31 // gray
32 - // singleApi: 'http://single.gray.yohops.com/',  
33 - // api: 'http://api.gray.yohops.com/',  
34 - // service: 'http://service.gray.yohops.com/', 32 + singleApi: 'http://single.gray.yohops.com/',
  33 + api: 'http://api.gray.yohops.com/',
  34 + service: 'http://service.gray.yohops.com/',
35 35
36 // dev 36 // dev
37 // api: 'http://dev-api.yohops.com:9999/', 37 // api: 'http://dev-api.yohops.com:9999/',
  1 +{{#each goods}}
  2 +<div class="good-info imgopacity" data-skn="{{skn}}">
  3 + <div class="tag-container clearfix">
  4 + {{# tags}}
  5 + {{# isNew}}
  6 + <span class="good-tag new-tag">NEW</span>
  7 + {{/ isNew}}
  8 + {{# isReNew}}
  9 + <span class="good-tag renew-tag">再到着</span>
  10 + {{/ isReNew}}
  11 + {{# isSale}}
  12 + <span class="good-tag sale-tag">SALE</span>
  13 + {{/ isSale}}
  14 + {{# isNewFestival}}
  15 + <span class="good-tag new-festival-tag">新品节</span>
  16 + {{/ isNewFestival}}
  17 + {{# isLimit}}
  18 + <span class="good-tag limit-tag">限量商品</span>
  19 + {{/ isLimit}}
  20 + {{# isYearEndPromotion}}
  21 + <span class="good-tag yep-tag">年终大促</span>
  22 + {{/ isYearEndPromotion}}
  23 + {{# isYearMidPromotion}}
  24 + <span class="good-tag ymp-tag">年中热促</span>
  25 + {{/ isYearMidPromotion}}
  26 + {{/ tags}}
  27 + </div>
  28 + <div class="good-detail-img">
  29 + <a class="good-thumb" href="{{url}}" target= "_blank">
  30 + <img class="lazy" data-original="{{image2 thumb}}">
  31 + </a>
  32 + {{# isFew}}
  33 + <p class="few-tag">即将售罄</p>
  34 + {{/ isFew}}
  35 +
  36 + {{#if showColBtn}}
  37 + <span class="col-btn iconfont{{#if coled}} coled{{/if}}">&#xe616;</span>
  38 + {{/if}}
  39 + </div>
  40 + <div class="good-detail-text">
  41 + <a href="{{url}}" target= "_blank">{{name}}</a>
  42 + <p class="price">
  43 + <span class="sale-price{{#unless marketPrice}}prime-cost{{/unless}}">
  44 + ¥{{salePrice}}
  45 + </span>
  46 + {{# marketPrice}}
  47 + <span class="market-price">¥{{.}}</span>
  48 + {{/ marketPrice}}
  49 + </p>
  50 + </div>
  51 +</div>
  52 +{{/each}}
@@ -16,5 +16,5 @@ $qrcodeImg.qrcode({ @@ -16,5 +16,5 @@ $qrcodeImg.qrcode({
16 }); 16 });
17 17
18 $qrcodeActivity.mouseenter(function() { 18 $qrcodeActivity.mouseenter(function() {
19 - window._hmt.push(['_trackEvent', '二维码', '活动页', 'id', $(this).attr('data-id')]); 19 + window._hmt && window._hmt.push(['_trackEvent', '二维码', '活动页', 'id', $(this).attr('data-id')]);
20 }); 20 });
@@ -11,7 +11,6 @@ var homePage = $('.home-page').data('page'), @@ -11,7 +11,6 @@ var homePage = $('.home-page').data('page'),
11 shownum = $('.logo-brand').data('shownum'), 11 shownum = $('.logo-brand').data('shownum'),
12 mChannel = $('.home-page').data('mchannel') || ''; 12 mChannel = $('.home-page').data('mchannel') || '';
13 13
14 -var newArrParams = {};  
15 var yas = require('../common/data-yas'); 14 var yas = require('../common/data-yas');
16 15
17 // 给头部js获取当前频道 16 // 给头部js获取当前频道
@@ -29,24 +28,12 @@ require('../common/center-slider'); @@ -29,24 +28,12 @@ require('../common/center-slider');
29 $(document).on('mouseenter', '.imgopacity a img', function() { 28 $(document).on('mouseenter', '.imgopacity a img', function() {
30 $(this).css('opacity', 0.8); // eslint-disable-line 29 $(this).css('opacity', 0.8); // eslint-disable-line
31 }); 30 });
  31 +
32 $(document).on('mouseout', '.imgopacity a img', function() { 32 $(document).on('mouseout', '.imgopacity a img', function() {
33 $(this).css('opacity', 1); // eslint-disable-line 33 $(this).css('opacity', 1); // eslint-disable-line
34 }); 34 });
35 35
36 if ($.inArray(homePage, ['boys', 'girls', 'kids', 'lifestyle']) > -1) { 36 if ($.inArray(homePage, ['boys', 'girls', 'kids', 'lifestyle']) > -1) {
37 - newArrParams = {  
38 - type: homePage,  
39 - url: '/common/getNewArrival',  
40 - count: (homePage === 'boys') || (homePage === 'lifestyle') ? 5 : 4,  
41 - rows: [5, 3]  
42 - };  
43 -  
44 - if (mChannel !== '') {  
45 - newArrParams.mChannel = mChannel;  
46 - newArrParams.poolId = window.queryString().template_id;  
47 - }  
48 -  
49 - require('../product/index/new-arrivls')(newArrParams);  
50 window.setCookie('_Channel', homePage, { 37 window.setCookie('_Channel', homePage, {
51 domain: '.yohobuy.com', 38 domain: '.yohobuy.com',
52 path: '/', 39 path: '/',
@@ -54,8 +41,8 @@ if ($.inArray(homePage, ['boys', 'girls', 'kids', 'lifestyle']) > -1) { @@ -54,8 +41,8 @@ if ($.inArray(homePage, ['boys', 'girls', 'kids', 'lifestyle']) > -1) {
54 }); 41 });
55 } 42 }
56 43
57 -// lazyLoad($('img.lazy'));  
58 lazyLoad($('img.lazy')); 44 lazyLoad($('img.lazy'));
  45 +
59 if (homePage === 'boys') { 46 if (homePage === 'boys') {
60 $('.slide-container').slider({ 47 $('.slide-container').slider({
61 pagination: '.thumb-pagination' 48 pagination: '.thumb-pagination'
@@ -146,9 +146,9 @@ $returnTop.click(function() { @@ -146,9 +146,9 @@ $returnTop.click(function() {
146 }); 146 });
147 147
148 $qrcodeHoverBox.mouseenter(function() { 148 $qrcodeHoverBox.mouseenter(function() {
149 - window._hmt.push(['_trackEvent', '二维码', '右侧悬浮', '', '']); 149 + window._hmt && window._hmt.push(['_trackEvent', '二维码', '右侧悬浮', '', '']);
150 }).click(function() { 150 }).click(function() {
151 - window._hmt.push(['_trackEvent', '二维码', '右侧悬浮', '', '']); 151 + window._hmt && window._hmt.push(['_trackEvent', '二维码', '右侧悬浮', '', '']);
152 }); 152 });
153 153
154 $(window).scroll(function() { 154 $(window).scroll(function() {
@@ -85,9 +85,9 @@ $('#signin-url').attr('href', window.signinUrl()); @@ -85,9 +85,9 @@ $('#signin-url').attr('href', window.signinUrl());
85 $('#reg-url').attr('href', window.registerUrl()); 85 $('#reg-url').attr('href', window.registerUrl());
86 86
87 $('.phoneapp').mouseenter(function() { 87 $('.phoneapp').mouseenter(function() {
88 - _hmt.push(['_trackEvent', '二维码', '头部手机版', '', '']); // eslint-disable-line 88 + window._html && window._hmt.push(['_trackEvent', '二维码', '头部手机版', '', '']); // eslint-disable-line
89 }).click(function() { 89 }).click(function() {
90 - _hmt.push(['_trackEvent', '二维码', '头部手机版', '', '']); // eslint-disable-line 90 + window._html && window._hmt.push(['_trackEvent', '二维码', '头部手机版', '', '']); // eslint-disable-line
91 }); 91 });
92 92
93 // handlebars模板 93 // handlebars模板
@@ -670,7 +670,7 @@ exports.init = function(page) { @@ -670,7 +670,7 @@ exports.init = function(page) {
670 670
671 671
672 $('.qrcode-hover-reg').mouseenter(function() { 672 $('.qrcode-hover-reg').mouseenter(function() {
673 - window._hmt.push(['_trackEvent', '二维码', '注册页', '', '']); 673 + window._hmt && window._hmt.push(['_trackEvent', '二维码', '注册页', '', '']);
674 }).click(function() { 674 }).click(function() {
675 - window._hmt.push(['_trackEvent', '二维码', '注册页', '', '']); 675 + window._hmt && window._hmt.push(['_trackEvent', '二维码', '注册页', '', '']);
676 }); 676 });
@@ -401,7 +401,7 @@ bindEvent.add(function() { @@ -401,7 +401,7 @@ bindEvent.add(function() {
401 }); 401 });
402 402
403 $('#code-buy').mouseenter(function() { 403 $('#code-buy').mouseenter(function() {
404 - window._hmt.push(['_trackEvent', '二维码', '商品详情页', 'skn', $(this).attr('skn')]); 404 + window._hmt && window._hmt.push(['_trackEvent', '二维码', '商品详情页', 'skn', $(this).attr('skn')]);
405 }); 405 });
406 406
407 // 是否能:量贩购买,量贩小于库存才能购买 407 // 是否能:量贩购买,量贩小于库存才能购买
@@ -144,7 +144,7 @@ $qrcodeImg.qrcode({ @@ -144,7 +144,7 @@ $qrcodeImg.qrcode({
144 }); 144 });
145 145
146 $('.qrcode-hover-box').mouseenter(function() { 146 $('.qrcode-hover-box').mouseenter(function() {
147 - window._hmt.push(['_trackEvent', '二维码', '普通店铺', 'shopId', $(this).attr('data-id')]); 147 + window._hmt && window._hmt.push(['_trackEvent', '二维码', '普通店铺', 'shopId', $(this).attr('data-id')]);
148 }); 148 });
149 149
150 require('./good-slide'); 150 require('./good-slide');
@@ -43,11 +43,9 @@ $qrcodeImg.qrcode({ @@ -43,11 +43,9 @@ $qrcodeImg.qrcode({
43 }); 43 });
44 44
45 $('.qrcode-decoration').mouseenter(function() { 45 $('.qrcode-decoration').mouseenter(function() {
46 - window._hmt.push(['_trackEvent', '二维码', '经典店铺', 'shopId', $(this).attr('data-id')]); 46 + window._hmt && window._hmt.push(['_trackEvent', '二维码', '经典店铺', 'shopId', $(this).attr('data-id')]);
47 }); 47 });
48 48
49 -// require('../product/list');  
50 -  
51 product.init(4); 49 product.init(4);
52 50
53 lazyLoad($('img.lazy')); 51 lazyLoad($('img.lazy'));