Authored by 郭成尧

品牌一览OK

@@ -52,7 +52,10 @@ module.exports = { @@ -52,7 +52,10 @@ module.exports = {
52 }, 52 },
53 53
54 getBrandList: (req, res) => { 54 getBrandList: (req, res) => {
55 - brandModel.getBrandListData().then(result => { 55 +
  56 + brandModel.getBrandListData({
  57 + channel: req.query.channel || req.cookies._Channel || 'boys'
  58 + }).then(result => {
56 res.json(result); 59 res.json(result);
57 }); 60 });
58 }, 61 },
@@ -7,6 +7,21 @@ @@ -7,6 +7,21 @@
7 'use strict'; 7 'use strict';
8 const api = global.yoho.API; 8 const api = global.yoho.API;
9 9
  10 +const yhChannel = {
  11 + boys: {
  12 + channel: '1'
  13 + },
  14 + girls: {
  15 + channel: '2'
  16 + },
  17 + kids: {
  18 + channel: '3'
  19 + },
  20 + lifestyle: {
  21 + channel: '4'
  22 + }
  23 +};
  24 +
10 module.exports = { 25 module.exports = {
11 26
12 /** 27 /**
@@ -35,7 +50,8 @@ module.exports = { @@ -35,7 +50,8 @@ module.exports = {
35 */ 50 */
36 getBrandListOriginData(params) { 51 getBrandListOriginData(params) {
37 return api.get('', { 52 return api.get('', {
38 - method: '' 53 + method: 'app.brand.newBrandList',
  54 + yh_channel: yhChannel[params.channel].channel
39 }); 55 });
40 }, 56 },
41 57
@@ -6,7 +6,38 @@ @@ -6,7 +6,38 @@
6 */ 6 */
7 'use strict'; 7 'use strict';
8 const api = global.yoho.API; 8 const api = global.yoho.API;
  9 +const helpers = global.yoho.helpers;
9 const brandApi = require('./brand-api'); 10 const brandApi = require('./brand-api');
  11 +const logger = global.yoho.logger;
  12 +const _ = require('lodash');
  13 +
  14 +/**
  15 + * 处理品牌一览品牌列表数据
  16 + * @param origin
  17 + * @returns {Array}
  18 + */
  19 +const handleBrandList = origin => {
  20 + let dest = [];
  21 +
  22 + _.forEach(origin, (value, key) => {
  23 + let brands = [];
  24 +
  25 + _.forEach(value, (subValue) => {
  26 + brands.push({
  27 + name: subValue.brand_name,
  28 + link: helpers.urlFormat('', null, subValue.brand_domain),
  29 + logo: subValue.brand_ico
  30 + });
  31 + });
  32 +
  33 + dest.push({
  34 + index: key,
  35 + brands: brands
  36 + });
  37 + });
  38 +
  39 + return dest;
  40 +};
10 41
11 /** 42 /**
12 * 获取品牌店铺数据 43 * 获取品牌店铺数据
@@ -53,70 +84,13 @@ const getBrandListData = params => { @@ -53,70 +84,13 @@ const getBrandListData = params => {
53 let finalResult = {}; 84 let finalResult = {};
54 85
55 return api.all([brandApi.getBrandListOriginData(params)]).then(result => { 86 return api.all([brandApi.getBrandListOriginData(params)]).then(result => {
56 - Object.assign(finalResult, {  
57 - brandList: [  
58 - {  
59 - index: 'A',  
60 - brands: [  
61 - {  
62 - name: 'Yohji Yamamoto(eyes wear)',  
63 - link: '#',  
64 - logo: 'https://img11.static.yhbimg.com/brandLogo/2016/04/13/15/010eb8606c1072fd2e769c62567d3bbe93.png?imageView2/2/w/140/h/140'  
65 - },  
66 - {  
67 - name: 'TEEN TEAM',  
68 - link: '#',  
69 - logo: 'https://img12.static.yhbimg.com/brandLogo/2015/12/03/14/02d4dba71951e8e971dc85d2eab5fe7a7f.jpg?imageView2/2/w/140/h/140'  
70 - },  
71 - {  
72 - name: 'MYGESMART',  
73 - link: '#',  
74 - logo: 'https://img11.static.yhbimg.com/brandLogo/2014/01/27/11/01d9dbee4c83e9122bd1fc363ceb85e484.jpg?imageView2/2/w/140/h/140'  
75 - },  
76 - {  
77 - name: 'MYGESMART',  
78 - link: '#',  
79 - logo: 'https://img11.static.yhbimg.com/brandLogo/2014/01/27/11/01d9dbee4c83e9122bd1fc363ceb85e484.jpg?imageView2/2/w/140/h/140'  
80 - },  
81 - {  
82 - name: 'MYGESMART',  
83 - link: '#',  
84 - logo: 'https://img11.static.yhbimg.com/brandLogo/2014/01/27/11/01d9dbee4c83e9122bd1fc363ceb85e484.jpg?imageView2/2/w/140/h/140'  
85 - }  
86 - ]  
87 - },  
88 - {  
89 - index: 'B',  
90 - brands: [  
91 - {  
92 - name: 'Yohji Yamamoto(eyes wear)',  
93 - link: '#',  
94 - logo: 'https://img11.static.yhbimg.com/brandLogo/2016/04/13/15/010eb8606c1072fd2e769c62567d3bbe93.png?imageView2/2/w/140/h/140'  
95 - },  
96 - {  
97 - name: 'TEEN TEAM',  
98 - link: '#',  
99 - logo: 'https://img12.static.yhbimg.com/brandLogo/2015/12/03/14/02d4dba71951e8e971dc85d2eab5fe7a7f.jpg?imageView2/2/w/140/h/140'  
100 - },  
101 - {  
102 - name: 'MYGESMART',  
103 - link: '#',  
104 - logo: 'https://img11.static.yhbimg.com/brandLogo/2014/01/27/11/01d9dbee4c83e9122bd1fc363ceb85e484.jpg?imageView2/2/w/140/h/140'  
105 - },  
106 - {  
107 - name: 'MYGESMART',  
108 - link: '#',  
109 - logo: 'https://img11.static.yhbimg.com/brandLogo/2014/01/27/11/01d9dbee4c83e9122bd1fc363ceb85e484.jpg?imageView2/2/w/140/h/140'  
110 - },  
111 - {  
112 - name: 'MYGESMART',  
113 - link: '#',  
114 - logo: 'https://img11.static.yhbimg.com/brandLogo/2014/01/27/11/01d9dbee4c83e9122bd1fc363ceb85e484.jpg?imageView2/2/w/140/h/140'  
115 - }  
116 - ]  
117 - }  
118 - ]  
119 - }); 87 + if (result[0].code === 200 && result[0].data.all_list) {
  88 + Object.assign(finalResult, {
  89 + brandList: handleBrandList(result[0].data.all_list)
  90 + });
  91 + } else {
  92 + logger.error('getBrandListOriginData api code no 200 or allList is null');
  93 + }
120 94
121 return finalResult; 95 return finalResult;
122 }); 96 });
@@ -6,9 +6,8 @@ @@ -6,9 +6,8 @@
6 <div class="brand-box" v-for="brand in item.brands"> 6 <div class="brand-box" v-for="brand in item.brands">
7 <a href="{{brand.link}}"> 7 <a href="{{brand.link}}">
8 <div class="brand-logo"> 8 <div class="brand-logo">
9 - <img v-lazy="brand.logo" alt="{{brand.name}}"> 9 + <img v-lazy="brand.logo | resize 150 150" alt="{{brand.name}}">
10 </div> 10 </div>
11 -  
12 <span class="brand-name">{{brand.name}}</span> 11 <span class="brand-name">{{brand.name}}</span>
13 </a> 12 </a>
14 </div> 13 </div>
@@ -21,6 +20,12 @@ @@ -21,6 +20,12 @@
21 width: 100%; 20 width: 100%;
22 height: 600px; 21 height: 600px;
23 22
  23 + .per-brand-box {
  24 + .index {
  25 + padding: 20px;
  26 + }
  27 + }
  28 +
24 .brand-big-box { 29 .brand-big-box {
25 width: 100%; 30 width: 100%;
26 } 31 }
@@ -30,6 +35,7 @@ @@ -30,6 +35,7 @@
30 height: 175px; 35 height: 175px;
31 float: left; 36 float: left;
32 overflow: hidden; 37 overflow: hidden;
  38 + text-align: center;
33 39
34 .brand-logo { 40 .brand-logo {
35 height: 150px; 41 height: 150px;