Authored by yyq

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

@@ -15,7 +15,7 @@ exports.index = (req, res, next) => { @@ -15,7 +15,7 @@ exports.index = (req, res, next) => {
15 15
16 // 将woman转换为girls,以便model层进行处理 16 // 将woman转换为girls,以便model层进行处理
17 channelType === 'woman' ? channelType = 'girls' : null; 17 channelType === 'woman' ? channelType = 'girls' : null;
18 - channelModel.getContent(channelType, req).then(data => { 18 + channelModel.getContent(channelType).then(data => {
19 19
20 // channel为空不缓存 20 // channel为空不缓存
21 if (_.isEmpty(data.channel)) { 21 if (_.isEmpty(data.channel)) {
@@ -28,7 +28,7 @@ exports.index = (req, res, next) => { @@ -28,7 +28,7 @@ exports.index = (req, res, next) => {
28 exports.getbrandFloorDataAjax = (req, res, next) => { 28 exports.getbrandFloorDataAjax = (req, res, next) => {
29 const channelType = req.query.channelType || 'boys'; 29 const channelType = req.query.channelType || 'boys';
30 30
31 - channelModel.getbrandFloorDataAjax(channelType, req).then(data => { 31 + channelModel.getbrandFloorDataAjax(channelType).then(data => {
32 res.json(data); 32 res.json(data);
33 }).catch(next); 33 }).catch(next);
34 }; 34 };
@@ -77,3 +77,10 @@ exports.getIndexGuide = (req, res, next) => { @@ -77,3 +77,10 @@ exports.getIndexGuide = (req, res, next) => {
77 res.render('guide', result); 77 res.render('guide', result);
78 }).catch(next); 78 }).catch(next);
79 }; 79 };
  80 +
  81 +exports.hasNewUserFloor = (req, res, next) => {
  82 +
  83 + channelModel.hasNewUserFloor(req.yoho.channel, req.user.uid).then(data => {
  84 + res.send(data);
  85 + }).catch(next);
  86 +};
@@ -576,7 +576,6 @@ const _requestContent = (type, params) => { @@ -576,7 +576,6 @@ const _requestContent = (type, params) => {
576 }; 576 };
577 577
578 Object.assign(data, params); 578 Object.assign(data, params);
579 -  
580 return serviceApi.get('operations/api/v5/resource/home', data, { 579 return serviceApi.get('operations/api/v5/resource/home', data, {
581 cache: true, 580 cache: true,
582 code: 200 581 code: 200
@@ -894,14 +893,9 @@ const getNewArrival = channel => { @@ -894,14 +893,9 @@ const getNewArrival = channel => {
894 * @param {String} type 传入频道页类型,值可以是: boys, girls, kids, lifestyle 893 * @param {String} type 传入频道页类型,值可以是: boys, girls, kids, lifestyle
895 * @return {Object} 894 * @return {Object}
896 */ 895 */
897 -const getContent = (type, req) => {  
898 - let params = {}; 896 +const getContent = (type) => {
  897 + let params = {new_device: 'Y'};
899 898
900 - if (!req.user.uid) {  
901 - params.new_device = 'Y';  
902 - } else {  
903 - params.uid = req.user.uid;  
904 - }  
905 return Promise.all([headerModel.requestHeaderData(type), _requestContent(type, params)]).then(res => { 899 return Promise.all([headerModel.requestHeaderData(type), _requestContent(type, params)]).then(res => {
906 900
907 let headerData = res[0].data || res[0], 901 let headerData = res[0].data || res[0],
@@ -956,14 +950,9 @@ const getContent = (type, req) => { @@ -956,14 +950,9 @@ const getContent = (type, req) => {
956 950
957 951
958 // 优选品牌楼层floorData-ajax 952 // 优选品牌楼层floorData-ajax
959 -const getbrandFloorDataAjax = (type, req) => {  
960 - let params = {}; 953 +const getbrandFloorDataAjax = (type) => {
  954 + let params = {new_device: 'Y'};
961 955
962 - if (!req.user.uid) {  
963 - params.new_device = 'Y';  
964 - } else {  
965 - params.uid = req.user.uid;  
966 - }  
967 return _requestContent(type, params).then(res => { 956 return _requestContent(type, params).then(res => {
968 let contentData = res.data ? res.data.list : []; 957 let contentData = res.data ? res.data.list : [];
969 958
@@ -1026,12 +1015,34 @@ const getIndexGuideData = () => { @@ -1026,12 +1015,34 @@ const getIndexGuideData = () => {
1026 return serviceApi.get('operations/api/v6/category/getCategory', params, config.apiCache); 1015 return serviceApi.get('operations/api/v6/category/getCategory', params, config.apiCache);
1027 }; 1016 };
1028 1017
  1018 +const hasNewUserFloor = (channelType, uid) => {
  1019 + let params = {uid: uid};
  1020 +
  1021 + return _requestContent(channelType, params).then(res => {
  1022 + let isNewUser = false,
  1023 + contentData = res.data ? res.data.list : res;
  1024 +
  1025 + _.forEach(contentData, (data) => {
  1026 + if (data.template_name === 'new_user_floor' || data.template_intro === '新人专享') {
  1027 + isNewUser = true;
  1028 + return false;
  1029 + }
  1030 + });
  1031 +
  1032 + return {
  1033 + isNewUser: isNewUser
  1034 + };
  1035 + });
  1036 +};
  1037 +
  1038 +
1029 module.exports = { 1039 module.exports = {
1030 getNewArrival: getNewArrival, 1040 getNewArrival: getNewArrival,
1031 getContent: getContent, 1041 getContent: getContent,
1032 getbrandFloorDataAjax: getbrandFloorDataAjax, 1042 getbrandFloorDataAjax: getbrandFloorDataAjax,
1033 getIndexGuideData: getIndexGuideData, 1043 getIndexGuideData: getIndexGuideData,
1034 formatIndexGuideData: formatIndexGuideData, 1044 formatIndexGuideData: formatIndexGuideData,
1035 - getResourceData: getResourceData 1045 + getResourceData: getResourceData,
  1046 + hasNewUserFloor: hasNewUserFloor
1036 1047
1037 }; 1048 };
@@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
6 6
7 'use strict'; 7 'use strict';
8 8
9 -const router = require('express').Router(); // eslint-disable-line 9 +const router = require('express').Router(); // eslint-disable-line
10 const cRoot = './controllers'; 10 const cRoot = './controllers';
11 11
12 // Your controller here 12 // Your controller here
@@ -17,6 +17,7 @@ router.get('/', channelController.index); @@ -17,6 +17,7 @@ router.get('/', channelController.index);
17 router.get('/woman', channelController.index); 17 router.get('/woman', channelController.index);
18 router.get('/kids', channelController.index); 18 router.get('/kids', channelController.index);
19 router.get('/lifestyle', channelController.index); 19 router.get('/lifestyle', channelController.index);
  20 +router.get('/channel/isNewUserAjax', channelController.hasNewUserFloor);
20 21
21 // ajax 22 // ajax
22 router.get('/getbrandFloorDataAjax', channelController.getbrandFloorDataAjax); 23 router.get('/getbrandFloorDataAjax', channelController.getbrandFloorDataAjax);
@@ -43,8 +43,6 @@ if ($.inArray(homePage, ['boys', 'girls', 'kids', 'lifestyle']) > -1) { @@ -43,8 +43,6 @@ if ($.inArray(homePage, ['boys', 'girls', 'kids', 'lifestyle']) > -1) {
43 }); 43 });
44 } 44 }
45 45
46 -  
47 -  
48 lazyLoad($('img.lazy')); 46 lazyLoad($('img.lazy'));
49 if (homePage === 'boys') { 47 if (homePage === 'boys') {
50 $('.slide-container').slider({ 48 $('.slide-container').slider({
@@ -73,3 +71,18 @@ $('.new-user-proList').slider2({ @@ -73,3 +71,18 @@ $('.new-user-proList').slider2({
73 shownum: 5, 71 shownum: 5,
74 isCircle: false 72 isCircle: false
75 }); 73 });
  74 +
  75 +if (window.cookie('_UID')) {
  76 + // 判断是否有新人专享
  77 + $.ajax({
  78 + type: 'GET',
  79 + url: '/channel/isNewUserAjax',
  80 + data: {},
  81 + success: function(res) {
  82 + if (!res.isNewuser) {
  83 + $('.new-user').addClass('hide');
  84 + }
  85 + }
  86 + });
  87 +}
  88 +