Authored by hongweigao

修改最新上架接口

@@ -38,7 +38,8 @@ exports.getNewArrival = (req, res, next) => { @@ -38,7 +38,8 @@ exports.getNewArrival = (req, res, next) => {
38 pageCount = reqBody.pageCount, 38 pageCount = reqBody.pageCount,
39 channel = reqBody.type || req.yoho.channel, 39 channel = reqBody.type || req.yoho.channel,
40 goods = [], 40 goods = [],
41 - result = {}; 41 + result = {},
  42 + isJKChannel = reqBody.mChannel === 'japanKorean' ? true : false;
42 43
43 if (pageIndex < 0) { 44 if (pageIndex < 0) {
44 pageIndex = 0; 45 pageIndex = 0;
@@ -47,7 +48,7 @@ exports.getNewArrival = (req, res, next) => { @@ -47,7 +48,7 @@ exports.getNewArrival = (req, res, next) => {
47 pageCount = 20; 48 pageCount = 20;
48 } 49 }
49 50
50 - channelModel.getNewArrival(channel).then(data => { 51 + channelModel.getNewArrival(channel, isJKChannel).then(data => {
51 goods = _.slice(data, pageIndex, pageIndex + pageCount); 52 goods = _.slice(data, pageIndex, pageIndex + pageCount);
52 53
53 if (goods.length !== 0) { 54 if (goods.length !== 0) {
@@ -434,6 +434,25 @@ const _getSingleHotFloorData = (args, type) => { @@ -434,6 +434,25 @@ const _getSingleHotFloorData = (args, type) => {
434 return _getGirlsSingleHot(args, type); 434 return _getGirlsSingleHot(args, type);
435 } 435 }
436 }; 436 };
  437 +/**
  438 + * 组装最新上架楼层数据
  439 + *
  440 + * @param string data
  441 + * return obj
  442 + */
  443 +const _getNewGoodsFloorData = args => {
  444 + const data = {};
  445 +
  446 + if (!_.isEmpty(args)) {
  447 + data.newArrivls = {
  448 + name: args[0].data.text,
  449 + navs: []
  450 + };
  451 +
  452 + data.newArrivls.navs = args[1].data || {};
  453 + }
  454 + return data;
  455 +};
437 456
438 /** 457 /**
439 * 文本标题 458 * 文本标题
@@ -452,6 +471,10 @@ const _getFloorTitleData = (args) => { @@ -452,6 +471,10 @@ const _getFloorTitleData = (args) => {
452 } else { 471 } else {
453 resData.floorHeader.name = args.data.text; 472 resData.floorHeader.name = args.data.text;
454 } 473 }
  474 +
  475 + if (resData.floorHeader.name.indexOf('最新上架') >= 0) {
  476 + resData = _getNewGoodsFloorData(args);
  477 + }
455 return resData; 478 return resData;
456 }; 479 };
457 480
@@ -565,25 +588,7 @@ const _processFloorDataWithQueryReusult = (rawData, originQuery, queryResult, ti @@ -565,25 +588,7 @@ const _processFloorDataWithQueryReusult = (rawData, originQuery, queryResult, ti
565 return data; 588 return data;
566 }; 589 };
567 590
568 -/**  
569 - * 组装最新上架楼层数据  
570 - *  
571 - * @param string data  
572 - * return obj  
573 - */  
574 -const _getNewGoodsFloorData = args => {  
575 - const data = {};  
576 -  
577 - if (!_.isEmpty(args)) {  
578 - data.newArrivls = {  
579 - name: args[0].data.text,  
580 - navs: []  
581 - };  
582 591
583 - data.newArrivls.navs = args[1].data || {};  
584 - }  
585 - return data;  
586 -};  
587 592
588 const _getCategoryFloorData = args => { 593 const _getCategoryFloorData = args => {
589 const data = { 594 const data = {
@@ -715,9 +720,9 @@ const _processFloorData = (rawData, type, isJKChannel, code) => { @@ -715,9 +720,9 @@ const _processFloorData = (rawData, type, isJKChannel, code) => {
715 if (text.indexOf('最新速报') >= 0) { 720 if (text.indexOf('最新速报') >= 0) {
716 floorData = _getNewReportFloorData(rawData.slice(index, index + 5), type, code); 721 floorData = _getNewReportFloorData(rawData.slice(index, index + 5), type, code);
717 722
718 - //单个图作为最新速报模块用过的,标识一下,不作为广告位了 723 + // 单个图作为最新速报模块用过的,标识一下,不作为广告位了
719 _.filter(rawData.slice(index, index + 5), function(o) { 724 _.filter(rawData.slice(index, index + 5), function(o) {
720 - if(o.template_name === 'single_image') { 725 + if (o.template_name === 'single_image') {
721 o.hasUser = true; 726 o.hasUser = true;
722 } 727 }
723 }); 728 });
@@ -748,7 +753,7 @@ const _processFloorData = (rawData, type, isJKChannel, code) => { @@ -748,7 +753,7 @@ const _processFloorData = (rawData, type, isJKChannel, code) => {
748 // 1标题12图,在日韩馆频道页,作为7个品类显示 753 // 1标题12图,在日韩馆频道页,作为7个品类显示
749 floorData = floorMap.sevenCategory.call(null, data.data); 754 floorData = floorMap.sevenCategory.call(null, data.data);
750 } else if (isJKChannel && data && data.template_name === 'single_image') { 755 } else if (isJKChannel && data && data.template_name === 'single_image') {
751 - if(!data.hasUser) { 756 + if (!data.hasUser) {
752 // 一张图,在日韩馆频道页,做广告位 757 // 一张图,在日韩馆频道页,做广告位
753 floorData = floorMap.ad.call(null, data.data); 758 floorData = floorMap.ad.call(null, data.data);
754 } 759 }
@@ -922,9 +927,19 @@ const formatIndexGuideData = data => { @@ -922,9 +927,19 @@ const formatIndexGuideData = data => {
922 * @param string $channel 927 * @param string $channel
923 * @return array 928 * @return array
924 */ 929 */
925 -const getNewArrival = channel => { 930 +const getNewArrival = (channel, isJKChannel)=> {
926 let rel = [], 931 let rel = [],
927 sortList = sortMap[channel], 932 sortList = sortMap[channel],
  933 + params = {},
  934 + method = '';
  935 +
  936 + if (isJKChannel) {
  937 + method = 'app.search.sales';
  938 + params = {
  939 + productPool: 519
  940 + };
  941 + } else {
  942 + method = 'web.search.newshelve';
928 params = { 943 params = {
929 order: 'shelve_time:desc', 944 order: 'shelve_time:desc',
930 status: 1, 945 status: 1,
@@ -933,6 +948,8 @@ const getNewArrival = channel => { @@ -933,6 +948,8 @@ const getNewArrival = channel => {
933 stocknumber: 3, 948 stocknumber: 3,
934 dayLimit: 4 949 dayLimit: 4
935 }; 950 };
  951 + }
  952 +
936 953
937 params.gender = channelMap[channel].gender; 954 params.gender = channelMap[channel].gender;
938 955
@@ -940,7 +957,7 @@ const getNewArrival = channel => { @@ -940,7 +957,7 @@ const getNewArrival = channel => {
940 let data = Object.assign(item, params, {limit: item.viewNum}); 957 let data = Object.assign(item, params, {limit: item.viewNum});
941 958
942 rel.push(api.get('', Object.assign({ 959 rel.push(api.get('', Object.assign({
943 - method: 'web.search.newshelve' 960 + method: method
944 }, data), {cache: true})); 961 }, data), {cache: true}));
945 }); 962 });
946 963
@@ -978,13 +995,14 @@ const getContent = (type, req) => { @@ -978,13 +995,14 @@ const getContent = (type, req) => {
978 let title = req.query.title, 995 let title = req.query.title,
979 contentCode = req.query.content_code; 996 contentCode = req.query.content_code;
980 997
  998 + let isJKChannel = title === 'japanKorean' ? true : false;
  999 +
981 return Promise.all([headerModel.requestHeaderData(type), _requestContent(type, contentCode)]).then(res => { 1000 return Promise.all([headerModel.requestHeaderData(type), _requestContent(type, contentCode)]).then(res => {
982 1001
983 let headerData = res[0].data || res[0], 1002 let headerData = res[0].data || res[0],
984 contentData = res[1].data ? res[1].data.list : res[1]; 1003 contentData = res[1].data ? res[1].data.list : res[1];
985 1004
986 - let data = {},  
987 - isJKChannel = title === 'japanKorean' ? true : false; 1005 + let data = {};
988 1006
989 const processResult = _processFloorData(contentData, type, isJKChannel, contentCode); 1007 const processResult = _processFloorData(contentData, type, isJKChannel, contentCode);
990 1008
@@ -992,6 +1010,7 @@ const getContent = (type, req) => { @@ -992,6 +1010,7 @@ const getContent = (type, req) => {
992 data.module = 'channel'; 1010 data.module = 'channel';
993 data.page = 'channel'; 1011 data.page = 'channel';
994 data.pageType = type; 1012 data.pageType = type;
  1013 + isJKChannel ? data.mchannel = 'japanKorean' : '';// 子频道,如日韩馆
995 data.footerTop = true; 1014 data.footerTop = true;
996 data.channel = processResult.floors; 1015 data.channel = processResult.floors;
997 1016
1 -<div class="home-page yoho-page {{pageType}}" data-page="{{pageType}}"> 1 +<div class="home-page yoho-page {{pageType}}" data-page="{{pageType}}" data-mchannel="{{mchannel}}">
2 {{# channel}} 2 {{# channel}}
3 {{! 头部banner}} 3 {{! 头部banner}}
4 {{# slide}} 4 {{# slide}}
@@ -19,6 +19,9 @@ module.exports = { @@ -19,6 +19,9 @@ module.exports = {
19 favApi: 'http://192.168.102.31:8092/brower', 19 favApi: 'http://192.168.102.31:8092/brower',
20 api: 'http://api-test3.yohops.com:9999/', 20 api: 'http://api-test3.yohops.com:9999/',
21 service: 'http://service-test3.yohops.com:9999/', 21 service: 'http://service-test3.yohops.com:9999/',
  22 +
  23 + // api: 'http://api.yoho.cn/',
  24 + // service: 'http://service.yoho.cn/',
22 search: 'http://192.168.102.216:8080/yohosearch/' 25 search: 'http://192.168.102.216:8080/yohosearch/'
23 }, 26 },
24 subDomains: { 27 subDomains: {
@@ -7,7 +7,10 @@ @@ -7,7 +7,10 @@
7 var $ = require('yoho-jquery'); 7 var $ = require('yoho-jquery');
8 8
9 var homePage = $('.home-page').data('page'), 9 var homePage = $('.home-page').data('page'),
10 - brandUrl = $('.logo-brand').data('url'); 10 + brandUrl = $('.logo-brand').data('url'),
  11 + mChannel = $('.home-page').data('mchannel') || '';
  12 +
  13 +var newArrParams = {};
11 14
12 // 给头部js获取当前频道 15 // 给头部js获取当前频道
13 window.homePage = homePage; 16 window.homePage = homePage;
@@ -28,13 +31,19 @@ $(document).on('mouseout', '.imgopacity a img', function() { @@ -28,13 +31,19 @@ $(document).on('mouseout', '.imgopacity a img', function() {
28 $(this).css('opacity', 1); // eslint-disable-line 31 $(this).css('opacity', 1); // eslint-disable-line
29 }); 32 });
30 33
31 -if ($.inArray(homePage, ['boys', 'girls', 'kids', 'lifestyle', 'japanKorean']) > -1) {  
32 - require('../product/index/new-arrivls')({ 34 +if ($.inArray(homePage, ['boys', 'girls', 'kids', 'lifestyle']) > -1) {
  35 + newArrParams = {
33 type: homePage, 36 type: homePage,
34 url: '/common/getNewArrival', 37 url: '/common/getNewArrival',
35 count: (homePage === 'boys') || (homePage === 'lifestyle') ? 5 : 4, 38 count: (homePage === 'boys') || (homePage === 'lifestyle') ? 5 : 4,
36 rows: [5, 3] 39 rows: [5, 3]
37 - }); 40 + };
  41 +
  42 + if (mChannel !== '') {
  43 + newArrParams.mChannel = mChannel;
  44 + }
  45 +
  46 + require('../product/index/new-arrivls')(newArrParams);
38 window.setCookie('_Channel', homePage, { 47 window.setCookie('_Channel', homePage, {
39 domain: '.yohobuy.com', 48 domain: '.yohobuy.com',
40 path: '/', 49 path: '/',
@@ -126,7 +126,6 @@ module.exports = function(data) { @@ -126,7 +126,6 @@ module.exports = function(data) {
126 pos = result.goods.length - len - 1; 126 pos = result.goods.length - len - 1;
127 127
128 result.goods.splice(pos, len); 128 result.goods.splice(pos, len);
129 -  
130 myTemplate = Handlebars.compile(load.tpl); 129 myTemplate = Handlebars.compile(load.tpl);
131 130
132 $container.append(myTemplate(result.goods)); 131 $container.append(myTemplate(result.goods));