Authored by zhangxiaoru

明星原创

@@ -16,29 +16,60 @@ let channels = { @@ -16,29 +16,60 @@ let channels = {
16 lifestyle: '4' 16 lifestyle: '4'
17 }; 17 };
18 18
  19 +let yhChannel = {
  20 + boys: 1,
  21 + girl: 2
  22 +}
  23 +
19 const getListData = (req, res, next) => { 24 const getListData = (req, res, next) => {
20 let gender = req.query.gender || req.cookies._Channel && channels[req.cookies._Channel] || '1,3'; 25 let gender = req.query.gender || req.cookies._Channel && channels[req.cookies._Channel] || '1,3';
21 let recom = '4'; 26 let recom = '4';
22 let all = '1'; 27 let all = '1';
  28 + let type = req.query.type;
  29 + let channel = req.cookies._Channel && yhChannel[req.cookies._Channel] || 1;
  30 + let isRecommend = '0';
  31 + let starBrand = '2';
  32 + let originalBrand = '3';
  33 + console.log(type)
23 34
24 - plustarModel.getListData(gender, recom, all).then((result) => { 35 + if(type === '2') {
  36 + plustarModel.getBrandsData(gender, starBrand, originalBrand, channel, isRecommend).then((result) => {
  37 + res.render('plustar/list', {
  38 + module: 'guang',
  39 + page: 'plustar-list',
  40 + title: '明星原创',
  41 + pageHeader: headerModel.setNav({
  42 + navTitle: '明星原创'
  43 + }),
  44 + pageFooter: true,
  45 + ps: {
  46 + sName: '明星潮品',
  47 + pName: '原创潮牌',
  48 + star: result.star,
  49 + plus: result.plus
  50 + }
  51 + });
  52 + }).catch(next);
  53 + } else {
  54 + plustarModel.getListData(gender, recom, all).then((result) => {
25 55
26 - res.render('plustar/list', {  
27 - module: 'guang',  
28 - page: 'plustar-list',  
29 - title: '国际优选',  
30 - pageHeader: headerModel.setNav({  
31 - navTitle: '国际优选'  
32 - }),  
33 - pageFooter: true,  
34 - ps: {  
35 - sName: '设计师',  
36 - pName: '经典潮牌',  
37 - star: result.star,  
38 - plus: result.plus  
39 - }  
40 - });  
41 - }).catch(next); 56 + res.render('plustar/list', {
  57 + module: 'guang',
  58 + page: 'plustar-list',
  59 + title: '国际优选',
  60 + pageHeader: headerModel.setNav({
  61 + navTitle: '国际优选'
  62 + }),
  63 + pageFooter: true,
  64 + ps: {
  65 + sName: '设计师',
  66 + pName: '经典潮牌',
  67 + star: result.star,
  68 + plus: result.plus
  69 + }
  70 + });
  71 + }).catch(next);
  72 + }
42 }; 73 };
43 74
44 const getDetailData = (req, res, next) => { 75 const getDetailData = (req, res, next) => {
@@ -13,7 +13,6 @@ const formaData = (data, gender) => { @@ -13,7 +13,6 @@ const formaData = (data, gender) => {
13 _.forEach(data, function(val) { 13 _.forEach(data, function(val) {
14 // 多张图 14 // 多张图
15 if (val.data[1]) { 15 if (val.data[1]) {
16 -  
17 let imgs = []; 16 let imgs = [];
18 17
19 _.forEach(val.data, function(list) { 18 _.forEach(val.data, function(list) {
@@ -34,7 +33,7 @@ const formaData = (data, gender) => { @@ -34,7 +33,7 @@ const formaData = (data, gender) => {
34 } 33 }
35 34
36 // 单张图 35 // 单张图
37 - if (val.data[0]) { 36 + if (val.data[0] && !val.data[1]) {
38 _.forEach(val.data, function(list) { 37 _.forEach(val.data, function(list) {
39 build.push({ 38 build.push({
40 url: '/guang/plustar/brandinfo?id=' + val.id + '&gender=' + gender, 39 url: '/guang/plustar/brandinfo?id=' + val.id + '&gender=' + gender,
@@ -48,15 +47,19 @@ const formaData = (data, gender) => { @@ -48,15 +47,19 @@ const formaData = (data, gender) => {
48 return build; 47 return build;
49 }; 48 };
50 49
  50 +const getContentData = (gender, type, channel, isRecommend) => {
  51 + let param = {
  52 + gender: gender,
  53 + brand_type: type,
  54 + yh_channel: channel
  55 + };
51 56
52 -const getContentData = (gender, type) => { 57 + if (isRecommend) {
  58 + param.is_recommend = isRecommend;
  59 + }
53 60
54 - return serviceAPI.get('guang/api/v3/plustar/getlist', {  
55 - gender: gender,  
56 - brand_type: type  
57 - }).then((result) => { 61 + return serviceAPI.get('guang/api/v3/plustar/getlist', param).then((result) => {
58 if (result && result.code === 200) { 62 if (result && result.code === 200) {
59 - // console.log(result)  
60 return formaData(result.data.data.list[0].data, gender); 63 return formaData(result.data.data.list[0].data, gender);
61 } else { 64 } else {
62 logger.error('列表 list data return code is not 200'); 65 logger.error('列表 list data return code is not 200');
@@ -74,6 +77,15 @@ const getListData = (gender, recom, all) => { @@ -74,6 +77,15 @@ const getListData = (gender, recom, all) => {
74 }); 77 });
75 }; 78 };
76 79
  80 +const getBrandsData = (gender, starBrand, originalBrand, channel, isRecommend) => {
  81 + return Promise.all([getContentData(gender, starBrand, isRecommend, channel), getContentData(gender, originalBrand, isRecommend, channel)]).then((result) => {
  82 + return {
  83 + star: result[0],
  84 + plus: result[1]
  85 + };
  86 + });
  87 +}
  88 +
77 // 新品到着 89 // 新品到着
78 const getNewProduct = (brandId, gender, url) => { 90 const getNewProduct = (brandId, gender, url) => {
79 91
@@ -270,5 +282,6 @@ const getDetailData = (id, uid, udid, gender, isApp, clientType) => { @@ -270,5 +282,6 @@ const getDetailData = (id, uid, udid, gender, isApp, clientType) => {
270 module.exports = { 282 module.exports = {
271 getListData, 283 getListData,
272 getContentData, 284 getContentData,
273 - getDetailData 285 + getDetailData,
  286 + getBrandsData
274 }; 287 };