Authored by 周少峰

outlets channel data

@@ -269,7 +269,6 @@ exports.channel = (req, res) => { @@ -269,7 +269,6 @@ exports.channel = (req, res) => {
269 outlets.getOutletsChannelData({channel:req.params.channel}).then(outletsData => { 269 outlets.getOutletsChannelData({channel:req.params.channel}).then(outletsData => {
270 response.module = 'product'; 270 response.module = 'product';
271 response.page = 'outlets'; 271 response.page = 'outlets';
272 - response.footerTop = true;  
273 response.devEnv = true; 272 response.devEnv = true;
274 //输出数据 273 //输出数据
275 Object.assign(response, outletsData); 274 Object.assign(response, outletsData);
  1 +'use strict';
  2 +const library = '../../../library';
  3 +const helpers = require(`${library}/helpers`);
  4 +const _ = require('lodash');
  5 +const camelCase = require('../../../library/camel-case');
  6 +
  7 +/**
  8 + * NL2R图片轮播
  9 + */
  10 +const NL2R = (data) => {
  11 + const result = {
  12 + left: [],
  13 + right: [],
  14 + };
  15 + //左侧
  16 + _.forEach(data.left, (value, key) => {
  17 + result.left.push({
  18 + img: value.src,
  19 + url: value.url
  20 + });
  21 + })
  22 + //右侧
  23 + _.forEach(data.right, (value, key) => {
  24 + result.right.push({
  25 + img: value.src,
  26 + url: value.url
  27 + });
  28 + })
  29 + return result
  30 +}
  31 +
  32 +/**
  33 + * 热门分类
  34 + */
  35 +const hotCategory = (data) => {
  36 + return {
  37 + hotCategory: {
  38 + name: data.name,
  39 + list: data.menuNav.list,
  40 + blocks: data.menuNav.blocks,
  41 + brands: data.imgs.slice(0, 1),
  42 + types: data.imgs.slice(1, 7)
  43 + }
  44 + }
  45 +}
  46 +
  47 +/**
  48 + * 分类导航
  49 + */
  50 + const categoryNavigation = (data) => {
  51 +
  52 + }
  53 +
  54 +
  55 +/**
  56 + * 处理楼层数据
  57 + * @param {[array]} list
  58 + * @return {[array]}
  59 + */
  60 +exports.processFloor = (list) => {
  61 + const formatData = [];
  62 + var floorData;
  63 + list = list || [];
  64 + list = camelCase(list);
  65 +
  66 + //格式化数据
  67 + _.forEach(list, (floor) => {
  68 + switch (floor.templateName) {
  69 + case 'NL2R':
  70 + floorData = NL2R(floor.data);
  71 + break;
  72 + case 'hotCategory':
  73 + floorData = hotCategory(floor.data);
  74 + break;
  75 + case 'categoryNavigation':
  76 + floorData = categoryNavigation(floor.data);
  77 + break;
  78 + default:
  79 + floorData = floor.data;
  80 + break;
  81 +
  82 + }
  83 + Object.assign(formatData, floorData);
  84 + });
  85 + return formatData;
  86 +};
  87 +
  88 +/**
  89 + * 组织嗨购数据
  90 + */
  91 + exports.formatActivityData = (data) => {
  92 + var high = {
  93 + name: '限时嗨购',
  94 + imgHot: []
  95 + };
  96 + _.forEach(data, (value) => {
  97 + high.imgHot.push({
  98 + url: value.webUrl,
  99 + img: value.coverUrl,
  100 + logo: value.logoUrl,
  101 + name: value.title,
  102 + price: value.promotionName,
  103 + count: value.endTime
  104 + });
  105 + })
  106 + return high;
  107 + }
@@ -15,6 +15,8 @@ const api = new API(); @@ -15,6 +15,8 @@ const api = new API();
15 const sign = require(`${library}/sign`); 15 const sign = require(`${library}/sign`);
16 const helpers = require(`${library}/helpers`); 16 const helpers = require(`${library}/helpers`);
17 const camelCase = require('../../../library/camel-case'); 17 const camelCase = require('../../../library/camel-case');
  18 +const saleApi = require('./sale-api');
  19 +const outletsProcess = require('./outlets-handler');
18 20
19 21
20 /** 22 /**
@@ -75,84 +77,20 @@ const channelCode = { @@ -75,84 +77,20 @@ const channelCode = {
75 } 77 }
76 78
77 /** 79 /**
78 - * 处理楼层数据  
79 - * @param {[array]} list  
80 - * @return {[array]}  
81 - */  
82 -const processFloor = (list) => {  
83 - const formatData = [];  
84 - var floorData;  
85 - list = list || [];  
86 - list = camelCase(list);  
87 -  
88 - //格式化数据  
89 - _.forEach(list, (floor) => {  
90 - if (floor.templateName === 'NL2R' && floor.data) {  
91 - floorData = NL2R(floor.data);  
92 - }  
93 -  
94 - if (floor.templateName === 'hotCategory' && floor.data) {  
95 - floorData = hotCategory(floor.data);  
96 - console.log(floorData)  
97 - }  
98 - Object.assign(formatData, floorData);  
99 -  
100 - });  
101 - return formatData;  
102 -};  
103 -  
104 -//NL2R图片轮播  
105 -const NL2R = (data) => {  
106 - const result = {  
107 - left: [],  
108 - right: [],  
109 - };  
110 - //左侧  
111 - _.forEach(data.left, (value, key) => {  
112 - result.left.push({  
113 - img: value.src,  
114 - url: value.url  
115 - });  
116 - })  
117 - //右侧  
118 - _.forEach(data.right, (value, key) => {  
119 - result.right.push({  
120 - img: value.src,  
121 - url: value.url  
122 - });  
123 - })  
124 - return result  
125 -}  
126 -  
127 -// 热门分类  
128 -const hotCategory = (data) => {  
129 - return {  
130 - hotCategory: {  
131 - name: data.name,  
132 - list: data.menuNav.list,  
133 - blocks: data.menuNav.blocks,  
134 - brands: data.imgs.slice(0, 1),  
135 - types: data.imgs.slice(1, 7)  
136 - }  
137 - }  
138 -}  
139 -  
140 -  
141 -/**  
142 * 获取奥莱频道页面数据 80 * 获取奥莱频道页面数据
143 * @param {[object]} gender 81 * @param {[object]} gender
144 * @return {[type]} 82 * @return {[type]}
145 */ 83 */
146 exports.getOutletsChannelData = (params) => { 84 exports.getOutletsChannelData = (params) => {
147 -  
148 - return api.all([getChannelResouceData({content_code: channelCode[params.channel]}), getOutletsActivityData()]).then(result => {  
149 - if (resul[0].code === 200) {  
150 - return processFloor(result[0].data.list);  
151 - }  
152 -  
153 - if (resul[1].code === 200) {  
154 - 85 + var channelData = {};
  86 + return api.all([getChannelResouceData({content_code: channelCode[params.channel]}), getOutletsActivityData({platform: 2, size: 0, type:1})]).then(result => {
  87 + if (result[0].code === 200) {
  88 + Object.assign(channelData, outletsProcess.processFloor(result[0].data.list));
  89 + }
  90 + if (result[1].code === 200) {
  91 + Object.assign(channelData, {flashSale: outletsProcess.formatActivityData(result[1].data)});
155 } 92 }
  93 + return channelData;
156 }); 94 });
157 } 95 }
158 96
@@ -162,7 +100,7 @@ exports.getOutletsChannelData = (params) => { @@ -162,7 +100,7 @@ exports.getOutletsChannelData = (params) => {
162 * @return {[type]} 100 * @return {[type]}
163 */ 101 */
164 const getChannelResouceData = (params) => { 102 const getChannelResouceData = (params) => {
165 - return serviceApi.get('operations/api/v5/resource/home', params) 103 + return serviceApi.get('operations/api/v5/resource/home', sign.apiSign(params))
166 } 104 }
167 105
168 /** 106 /**
@@ -181,3 +119,17 @@ const getOutletsActivityData = (params) => { @@ -181,3 +119,17 @@ const getOutletsActivityData = (params) => {
181 method: 'app.outlets.activityGet', 119 method: 'app.outlets.activityGet',
182 }, params))); 120 }, params)));
183 } 121 }
  122 +
  123 +/**
  124 + * 获取奥莱频道商品分类
  125 + * @param {[object]} params
  126 + * @return {[type]}
  127 + */
  128 + const getOutletsSortData = (params) => {
  129 + return api.get('', sign.apiSign(
  130 + Object.assign({
  131 + method: 'app.outlets.activityGet',
  132 + }, params)));
  133 + }
  134 +
  135 +
@@ -5,13 +5,13 @@ @@ -5,13 +5,13 @@
5 {{#each imgHot}} 5 {{#each imgHot}}
6 <li> 6 <li>
7 <a href="{{href}}" target= "_blank"><div class="flash-sale-banner"> 7 <a href="{{href}}" target= "_blank"><div class="flash-sale-banner">
8 - <img src="{{img}}"/></div> 8 + <img src="{{image img 560 260}}"/></div>
9 <div class="flash-sale-bottom"> 9 <div class="flash-sale-bottom">
10 <p class="flash-sale-count">{{count}}折起</p> 10 <p class="flash-sale-count">{{count}}折起</p>
11 <p class="flash-sale-name">{{name}}</p> 11 <p class="flash-sale-name">{{name}}</p>
12 <p class="flash-sale-timer">timer</p> 12 <p class="flash-sale-timer">timer</p>
13 <div class="flash-sale-logo"> 13 <div class="flash-sale-logo">
14 - <img src="{{logo}}"/> 14 + <img src="{{image logo 100 60}}"/>
15 </div> 15 </div>
16 </div> 16 </div>
17 </a> 17 </a>