Authored by 郭成尧

添加 contentCode

@@ -64,6 +64,8 @@ exports.discount = (req, res) => { @@ -64,6 +64,8 @@ exports.discount = (req, res) => {
64 saleType: 3 64 saleType: 3
65 }, req.query); 65 }, req.query);
66 66
  67 + let channel = req.query.channel || req.cookies._Channel || 'boys';
  68 +
67 let responseData = {}; 69 let responseData = {};
68 70
69 headerModel.requestHeaderData() 71 headerModel.requestHeaderData()
@@ -77,7 +79,7 @@ exports.discount = (req, res) => { @@ -77,7 +79,7 @@ exports.discount = (req, res) => {
77 // 假数据输出 79 // 假数据输出
78 // res.render('sale/discount', Object.assign(responseData, simulation.discount())); 80 // res.render('sale/discount', Object.assign(responseData, simulation.discount()));
79 81
80 - sale.getSaleDiscountData(params).then((result) => { 82 + sale.getSaleDiscountData(params, channel).then((result) => {
81 responseData.result = result; 83 responseData.result = result;
82 responseData.resultShow = JSON.stringify(result, null, 4); 84 responseData.resultShow = JSON.stringify(result, null, 4);
83 85
@@ -104,6 +106,8 @@ exports.vip = (req, res) => { @@ -104,6 +106,8 @@ exports.vip = (req, res) => {
104 order: 's_t_asc,s_s_asc' 106 order: 's_t_asc,s_s_asc'
105 }, req.query); 107 }, req.query);
106 108
  109 + let channel = req.query.channel || req.cookies._Channel || 'boys';
  110 +
107 params.uid = req.user.uid || 0; 111 params.uid = req.user.uid || 0;
108 112
109 let responseData = {}; 113 let responseData = {};
@@ -118,7 +122,7 @@ exports.vip = (req, res) => { @@ -118,7 +122,7 @@ exports.vip = (req, res) => {
118 // 假数据输出 122 // 假数据输出
119 // res.render('sale/other', Object.assign(responseData, simulation.other())); 123 // res.render('sale/other', Object.assign(responseData, simulation.other()));
120 124
121 - sale.getSaleOthersData(params).then((result) => { 125 + sale.getSaleOthersData(params, channel).then((result) => {
122 responseData.saleList = result; 126 responseData.saleList = result;
123 responseData.resultShow = JSON.stringify(result, null, 4); 127 responseData.resultShow = JSON.stringify(result, null, 4);
124 128
@@ -142,26 +146,28 @@ exports.newSale = (req, res) => { @@ -142,26 +146,28 @@ exports.newSale = (req, res) => {
142 order: 's_t_desc' 146 order: 's_t_desc'
143 }, req.query); 147 }, req.query);
144 148
  149 + let channel = req.query.channel || req.cookies._Channel || 'boys';
  150 +
145 let responseData = {}; 151 let responseData = {};
146 152
147 headerModel.requestHeaderData().then(headerData => { 153 headerModel.requestHeaderData().then(headerData => {
148 - responseData = headerModel.setHeaderData(headerData.data, 'newSale');  
149 - responseData.module = 'product';  
150 - responseData.page = 'sale';  
151 - responseData.footerTop = true;  
152 - responseData.devEnv = true; 154 + responseData = headerModel.setHeaderData(headerData.data, 'newSale');
  155 + responseData.module = 'product';
  156 + responseData.page = 'sale';
  157 + responseData.footerTop = true;
  158 + responseData.devEnv = true;
153 159
154 // 假数据输出 160 // 假数据输出
155 // res.render('sale/other', Object.assign(responseData, simulation.other())); 161 // res.render('sale/other', Object.assign(responseData, simulation.other()));
156 162
157 - sale.getSaleOthersData(params).then((result) => {  
158 - responseData.saleList = result;  
159 - responseData.resultShow = JSON.stringify(result, null, 4); 163 + sale.getSaleOthersData(params, channel).then((result) => {
  164 + responseData.saleList = result;
  165 + responseData.resultShow = JSON.stringify(result, null, 4);
160 166
161 - res.render('sale/other', responseData);  
162 - }); 167 + res.render('sale/other', responseData);
  168 + });
163 169
164 - }) 170 + })
165 .catch(() => { 171 .catch(() => {
166 res.render('error', { devEnv: true, pageErr: true }); 172 res.render('error', { devEnv: true, pageErr: true });
167 }); 173 });
@@ -178,6 +184,8 @@ exports.breakingYards = (req, res) => { @@ -178,6 +184,8 @@ exports.breakingYards = (req, res) => {
178 saleType: 1 184 saleType: 1
179 }, req.query); 185 }, req.query);
180 186
  187 + let channel = req.query.channel || req.cookies._Channel || 'boys';
  188 +
181 let responseData = {}; 189 let responseData = {};
182 190
183 headerModel.requestHeaderData().then(headerData => { 191 headerModel.requestHeaderData().then(headerData => {
@@ -190,7 +198,7 @@ exports.breakingYards = (req, res) => { @@ -190,7 +198,7 @@ exports.breakingYards = (req, res) => {
190 // 假数据输出 198 // 假数据输出
191 // res.render('sale/other', Object.assign(responseData, simulation.other())); 199 // res.render('sale/other', Object.assign(responseData, simulation.other()));
192 200
193 - sale.getSalebreakingYardsData(params).then((result) => { 201 + sale.getSalebreakingYardsData(params, channel).then((result) => {
194 responseData.saleList = result; 202 responseData.saleList = result;
195 responseData.resultShow = JSON.stringify(result, null, 4); 203 responseData.resultShow = JSON.stringify(result, null, 4);
196 204
@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 * @Author: Targaryen 2 * @Author: Targaryen
3 * @Date: 2016-05-19 10:20:08 3 * @Date: 2016-05-19 10:20:08
4 * @Last Modified by: Targaryen 4 * @Last Modified by: Targaryen
5 - * @Last Modified time: 2016-06-01 18:46:02 5 + * @Last Modified time: 2016-06-02 12:53:05
6 */ 6 */
7 7
8 'use strict'; 8 'use strict';
@@ -15,6 +15,34 @@ const saleHandler = require('./sale-handler'); @@ -15,6 +15,34 @@ const saleHandler = require('./sale-handler');
15 const productProcess = require(`${utils}/product-process`); 15 const productProcess = require(`${utils}/product-process`);
16 const _ = require('lodash'); 16 const _ = require('lodash');
17 17
  18 +
  19 +/**
  20 + * 资源位code码
  21 + */
  22 +const contentCode = {
  23 + boys: {
  24 + sale: 'f6400250a73a2a1a8764a0d9be73abf2',
  25 + breakCode: 'a97451680222cb1b215de14bbef64921',
  26 + vip: '0400ac0dffbb2fefe84949200cf2be4a'
  27 + },
  28 + girls: {
  29 + sale: 'd74adc70f939a6658b68386ee39199e7',
  30 + breakCode: '91e604f06449783a5bd93c6f4f99a396',
  31 + vip: 'e261419fde3613781a3ec9d367a2e534'
  32 + },
  33 + kids: {
  34 + sale: '01937a472a5a3ccf7204f734f2506865',
  35 + breakCode: '4c1dff47c68aace0608eb821fbaf40fd',
  36 + vip: '40db7c9a491548fa8d441815cc7a0617'
  37 + },
  38 + lifestyle: {
  39 + sale: '32944e49d627a031f1d7e14a1f90ccac',
  40 + breakCode: 'c605c9d2f1a426cecad232a7d41e6b97',
  41 + vip: '6ac5f0ee1cf0f2dab89c9cf80263028a'
  42 + }
  43 +};
  44 +
  45 +
18 /** 46 /**
19 * 获取Sale首页商品列表数据 仅 Ajax 调用 Controller 调用 47 * 获取Sale首页商品列表数据 仅 Ajax 调用 Controller 调用
20 * @return {[type]} [description] 48 * @return {[type]} [description]
@@ -107,27 +135,22 @@ exports.getSaleIndexData = () => { @@ -107,27 +135,22 @@ exports.getSaleIndexData = () => {
107 * 获取 VIP 会员专享和新降价专区数据 Controller 调用 135 * 获取 VIP 会员专享和新降价专区数据 Controller 调用
108 * @return {[type]} [description] 136 * @return {[type]} [description]
109 */ 137 */
110 -exports.getSaleOthersData = (params) => { 138 +exports.getSaleOthersData = (params, channel) => {
111 139
112 let promiseObject; 140 let promiseObject;
113 141
114 - // cCode 是资源位代码,根据页面不同传不同的 CODE,目前一样,待处理  
115 // saleType: 1表示断码区,2表示会员专区,3 折扣专区,4表示奥莱 142 // saleType: 1表示断码区,2表示会员专区,3 折扣专区,4表示奥莱
116 - let cCode;  
117 -  
118 if (!_.isEmpty(params) && params.saleType === 2) { 143 if (!_.isEmpty(params) && params.saleType === 2) {
119 - cCode = '7c2b77093421efa8ae9302c91460db73';  
120 promiseObject = [ 144 promiseObject = [
121 saleApi.getSaleGoodsList(params), 145 saleApi.getSaleGoodsList(params),
122 - saleApi.getSaleBannerList(cCode), 146 + saleApi.getSaleBannerList(contentCode[channel].vip),
123 saleApi.getLeftContentList(), 147 saleApi.getLeftContentList(),
124 saleApi.getUserProfile(params.uid) 148 saleApi.getUserProfile(params.uid)
125 ]; 149 ];
126 } else { 150 } else {
127 - cCode = '7c2b77093421efa8ae9302c91460db73';  
128 promiseObject = [ 151 promiseObject = [
129 saleApi.getSaleGoodsList(params), 152 saleApi.getSaleGoodsList(params),
130 - saleApi.getSaleBannerList(cCode), 153 + saleApi.getSaleBannerList(contentCode[channel].vip),
131 saleApi.getLeftContentList() 154 saleApi.getLeftContentList()
132 ]; 155 ];
133 } 156 }
@@ -169,30 +192,32 @@ exports.getSaleOthersData = (params) => { @@ -169,30 +192,32 @@ exports.getSaleOthersData = (params) => {
169 } 192 }
170 } 193 }
171 194
172 - // 处理 VIP 商品数据  
173 - if (result[3].code === 200 && parseInt(params.saleType, 10) === 2) {  
174 - _.forEach(finalResult.goods, (value, key) => {  
175 -  
176 - switch (result[3].curLevel) {  
177 - case '1':  
178 - finalResult.goods[key].vipPrice = value.vip1_price;  
179 - finalResult.goods[key].vip1 = true;  
180 - break;  
181 - case '2':  
182 - finalResult.goods[key].vipPrice = value.vip2_price;  
183 - finalResult.goods[key].vip2 = true;  
184 - break;  
185 - case '3':  
186 - finalResult.goods[key].vipPrice = value.vip3_price;  
187 - finalResult.goods[key].vip3 = true;  
188 - break;  
189 - default:  
190 - finalResult.goods[key].vipPrice = value.vip_price;  
191 - finalResult.goods[key].vip = true;  
192 - break;  
193 - }  
194 -  
195 - }); 195 + if (!_.isEmpty(result[3])) {
  196 + // 处理 VIP 商品数据
  197 + if (result[3].code === 200 && parseInt(params.saleType, 10) === 2) {
  198 + _.forEach(finalResult.goods, (value, key) => {
  199 +
  200 + switch (result[3].curLevel) {
  201 + case '1':
  202 + finalResult.goods[key].vipPrice = value.vip1_price;
  203 + finalResult.goods[key].vip1 = true;
  204 + break;
  205 + case '2':
  206 + finalResult.goods[key].vipPrice = value.vip2_price;
  207 + finalResult.goods[key].vip2 = true;
  208 + break;
  209 + case '3':
  210 + finalResult.goods[key].vipPrice = value.vip3_price;
  211 + finalResult.goods[key].vip3 = true;
  212 + break;
  213 + default:
  214 + finalResult.goods[key].vipPrice = value.vip_price;
  215 + finalResult.goods[key].vip = true;
  216 + break;
  217 + }
  218 +
  219 + });
  220 + }
196 } 221 }
197 222
198 return finalResult; 223 return finalResult;
@@ -203,10 +228,10 @@ exports.getSaleOthersData = (params) => { @@ -203,10 +228,10 @@ exports.getSaleOthersData = (params) => {
203 * 获取折扣专场数据 Controller 调用 228 * 获取折扣专场数据 Controller 调用
204 * @return {[type]} [description] 229 * @return {[type]} [description]
205 */ 230 */
206 -exports.getSaleDiscountData = (params) => { 231 +exports.getSaleDiscountData = (params, channel) => {
207 return api.all([ 232 return api.all([
208 saleApi.getSaleGoodsList(params), 233 saleApi.getSaleGoodsList(params),
209 - saleApi.getSaleBannerList('7c2b77093421efa8ae9302c91460db73'), 234 + saleApi.getSaleBannerList(contentCode[channel].sale),
210 saleApi.getSaleActivityList(params) 235 saleApi.getSaleActivityList(params)
211 ]).then(result => { 236 ]).then(result => {
212 let finalResult = {}; 237 let finalResult = {};
@@ -219,7 +244,7 @@ exports.getSaleDiscountData = (params) => { @@ -219,7 +244,7 @@ exports.getSaleDiscountData = (params) => {
219 finalResult.saleList.totalCount = result[0].data.total; 244 finalResult.saleList.totalCount = result[0].data.total;
220 finalResult.saleList.pager = saleHandler.handleSalePagerData(result[0].data.total, params); 245 finalResult.saleList.pager = saleHandler.handleSalePagerData(result[0].data.total, params);
221 246
222 - // 处理所有商品标题数据 247 + // 处理所有商品标题数据
223 finalResult.saleTitle = {}; 248 finalResult.saleTitle = {};
224 249
225 finalResult.saleTitle.name = '所有商品'; 250 finalResult.saleTitle.name = '所有商品';
@@ -247,11 +272,11 @@ exports.getSaleDiscountData = (params) => { @@ -247,11 +272,11 @@ exports.getSaleDiscountData = (params) => {
247 * @param {[type]} params [description] 272 * @param {[type]} params [description]
248 * @return {[type]} [description] 273 * @return {[type]} [description]
249 */ 274 */
250 -exports.getSalebreakingYardsData = (params) => { 275 +exports.getSalebreakingYardsData = (params, channel) => {
251 return api.all([ 276 return api.all([
252 saleApi.getSaleGoodsList(params), 277 saleApi.getSaleGoodsList(params),
253 saleApi.getSalebreakingYardsSortList(), 278 saleApi.getSalebreakingYardsSortList(),
254 - saleApi.getSaleBannerList('7c2b77093421efa8ae9302c91460db73'), 279 + saleApi.getSaleBannerList(contentCode[channel].breakCode),
255 saleApi.getLeftContentList() 280 saleApi.getLeftContentList()
256 ]).then(result => { 281 ]).then(result => {
257 let finalResult = {}; 282 let finalResult = {};