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) => {
// 将woman转换为girls,以便model层进行处理
channelType === 'woman' ? channelType = 'girls' : null;
channelModel.getContent(channelType, req).then(data => {
channelModel.getContent(channelType).then(data => {
// channel为空不缓存
if (_.isEmpty(data.channel)) {
... ... @@ -28,7 +28,7 @@ exports.index = (req, res, next) => {
exports.getbrandFloorDataAjax = (req, res, next) => {
const channelType = req.query.channelType || 'boys';
channelModel.getbrandFloorDataAjax(channelType, req).then(data => {
channelModel.getbrandFloorDataAjax(channelType).then(data => {
res.json(data);
}).catch(next);
};
... ... @@ -77,3 +77,10 @@ exports.getIndexGuide = (req, res, next) => {
res.render('guide', result);
}).catch(next);
};
exports.hasNewUserFloor = (req, res, next) => {
channelModel.hasNewUserFloor(req.yoho.channel, req.user.uid).then(data => {
res.send(data);
}).catch(next);
};
... ...
... ... @@ -576,7 +576,6 @@ const _requestContent = (type, params) => {
};
Object.assign(data, params);
return serviceApi.get('operations/api/v5/resource/home', data, {
cache: true,
code: 200
... ... @@ -894,14 +893,9 @@ const getNewArrival = channel => {
* @param {String} type 传入频道页类型,值可以是: boys, girls, kids, lifestyle
* @return {Object}
*/
const getContent = (type, req) => {
let params = {};
const getContent = (type) => {
let params = {new_device: 'Y'};
if (!req.user.uid) {
params.new_device = 'Y';
} else {
params.uid = req.user.uid;
}
return Promise.all([headerModel.requestHeaderData(type), _requestContent(type, params)]).then(res => {
let headerData = res[0].data || res[0],
... ... @@ -956,14 +950,9 @@ const getContent = (type, req) => {
// 优选品牌楼层floorData-ajax
const getbrandFloorDataAjax = (type, req) => {
let params = {};
const getbrandFloorDataAjax = (type) => {
let params = {new_device: 'Y'};
if (!req.user.uid) {
params.new_device = 'Y';
} else {
params.uid = req.user.uid;
}
return _requestContent(type, params).then(res => {
let contentData = res.data ? res.data.list : [];
... ... @@ -1026,12 +1015,34 @@ const getIndexGuideData = () => {
return serviceApi.get('operations/api/v6/category/getCategory', params, config.apiCache);
};
const hasNewUserFloor = (channelType, uid) => {
let params = {uid: uid};
return _requestContent(channelType, params).then(res => {
let isNewUser = false,
contentData = res.data ? res.data.list : res;
_.forEach(contentData, (data) => {
if (data.template_name === 'new_user_floor' || data.template_intro === '新人专享') {
isNewUser = true;
return false;
}
});
return {
isNewUser: isNewUser
};
});
};
module.exports = {
getNewArrival: getNewArrival,
getContent: getContent,
getbrandFloorDataAjax: getbrandFloorDataAjax,
getIndexGuideData: getIndexGuideData,
formatIndexGuideData: formatIndexGuideData,
getResourceData: getResourceData
getResourceData: getResourceData,
hasNewUserFloor: hasNewUserFloor
};
... ...
... ... @@ -6,7 +6,7 @@
'use strict';
const router = require('express').Router(); // eslint-disable-line
const router = require('express').Router(); // eslint-disable-line
const cRoot = './controllers';
// Your controller here
... ... @@ -17,6 +17,7 @@ router.get('/', channelController.index);
router.get('/woman', channelController.index);
router.get('/kids', channelController.index);
router.get('/lifestyle', channelController.index);
router.get('/channel/isNewUserAjax', channelController.hasNewUserFloor);
// ajax
router.get('/getbrandFloorDataAjax', channelController.getbrandFloorDataAjax);
... ...
... ... @@ -43,8 +43,6 @@ if ($.inArray(homePage, ['boys', 'girls', 'kids', 'lifestyle']) > -1) {
});
}
lazyLoad($('img.lazy'));
if (homePage === 'boys') {
$('.slide-container').slider({
... ... @@ -73,3 +71,18 @@ $('.new-user-proList').slider2({
shownum: 5,
isCircle: false
});
if (window.cookie('_UID')) {
// 判断是否有新人专享
$.ajax({
type: 'GET',
url: '/channel/isNewUserAjax',
data: {},
success: function(res) {
if (!res.isNewuser) {
$('.new-user').addClass('hide');
}
}
});
}
... ...