Authored by zhangxiaoru

明星原创

... ... @@ -16,29 +16,60 @@ let channels = {
lifestyle: '4'
};
let yhChannel = {
boys: 1,
girl: 2
}
const getListData = (req, res, next) => {
let gender = req.query.gender || req.cookies._Channel && channels[req.cookies._Channel] || '1,3';
let recom = '4';
let all = '1';
let type = req.query.type;
let channel = req.cookies._Channel && yhChannel[req.cookies._Channel] || 1;
let isRecommend = '0';
let starBrand = '2';
let originalBrand = '3';
console.log(type)
plustarModel.getListData(gender, recom, all).then((result) => {
if(type === '2') {
plustarModel.getBrandsData(gender, starBrand, originalBrand, channel, isRecommend).then((result) => {
res.render('plustar/list', {
module: 'guang',
page: 'plustar-list',
title: '明星原创',
pageHeader: headerModel.setNav({
navTitle: '明星原创'
}),
pageFooter: true,
ps: {
sName: '明星潮品',
pName: '原创潮牌',
star: result.star,
plus: result.plus
}
});
}).catch(next);
} else {
plustarModel.getListData(gender, recom, all).then((result) => {
res.render('plustar/list', {
module: 'guang',
page: 'plustar-list',
title: '国际优选',
pageHeader: headerModel.setNav({
navTitle: '国际优选'
}),
pageFooter: true,
ps: {
sName: '设计师',
pName: '经典潮牌',
star: result.star,
plus: result.plus
}
});
}).catch(next);
res.render('plustar/list', {
module: 'guang',
page: 'plustar-list',
title: '国际优选',
pageHeader: headerModel.setNav({
navTitle: '国际优选'
}),
pageFooter: true,
ps: {
sName: '设计师',
pName: '经典潮牌',
star: result.star,
plus: result.plus
}
});
}).catch(next);
}
};
const getDetailData = (req, res, next) => {
... ...
... ... @@ -13,7 +13,6 @@ const formaData = (data, gender) => {
_.forEach(data, function(val) {
// 多张图
if (val.data[1]) {
let imgs = [];
_.forEach(val.data, function(list) {
... ... @@ -34,7 +33,7 @@ const formaData = (data, gender) => {
}
// 单张图
if (val.data[0]) {
if (val.data[0] && !val.data[1]) {
_.forEach(val.data, function(list) {
build.push({
url: '/guang/plustar/brandinfo?id=' + val.id + '&gender=' + gender,
... ... @@ -48,15 +47,19 @@ const formaData = (data, gender) => {
return build;
};
const getContentData = (gender, type, channel, isRecommend) => {
let param = {
gender: gender,
brand_type: type,
yh_channel: channel
};
const getContentData = (gender, type) => {
if (isRecommend) {
param.is_recommend = isRecommend;
}
return serviceAPI.get('guang/api/v3/plustar/getlist', {
gender: gender,
brand_type: type
}).then((result) => {
return serviceAPI.get('guang/api/v3/plustar/getlist', param).then((result) => {
if (result && result.code === 200) {
// console.log(result)
return formaData(result.data.data.list[0].data, gender);
} else {
logger.error('列表 list data return code is not 200');
... ... @@ -74,6 +77,15 @@ const getListData = (gender, recom, all) => {
});
};
const getBrandsData = (gender, starBrand, originalBrand, channel, isRecommend) => {
return Promise.all([getContentData(gender, starBrand, isRecommend, channel), getContentData(gender, originalBrand, isRecommend, channel)]).then((result) => {
return {
star: result[0],
plus: result[1]
};
});
}
// 新品到着
const getNewProduct = (brandId, gender, url) => {
... ... @@ -270,5 +282,6 @@ const getDetailData = (id, uid, udid, gender, isApp, clientType) => {
module.exports = {
getListData,
getContentData,
getDetailData
getDetailData,
getBrandsData
};
... ...