|
@@ -5,7 +5,8 @@ |
|
@@ -5,7 +5,8 @@ |
5
|
*/
|
5
|
*/
|
6
|
'use strict';
|
6
|
'use strict';
|
7
|
const serviceAPI = global.yoho.ServiceAPI;
|
7
|
const serviceAPI = global.yoho.ServiceAPI;
|
8
|
-const api = global.yoho.API;
|
8
|
+
|
|
|
9
|
+// const api = global.yoho.API;
|
9
|
const camelCase = global.yoho.camelCase;
|
10
|
const camelCase = global.yoho.camelCase;
|
10
|
const _ = require('lodash');
|
11
|
const _ = require('lodash');
|
11
|
const Promise = require('bluebird');
|
12
|
const Promise = require('bluebird');
|
|
@@ -54,7 +55,7 @@ const _processListData = (list) => { |
|
@@ -54,7 +55,7 @@ const _processListData = (list) => { |
54
|
|
55
|
|
55
|
listData = _.assign(listData, {
|
56
|
listData = _.assign(listData, {
|
56
|
total: list.total
|
57
|
total: list.total
|
57
|
- })
|
58
|
+ });
|
58
|
|
59
|
|
59
|
_.forEach(list.list.artList, (data, index) => {
|
60
|
_.forEach(list.list.artList, (data, index) => {
|
60
|
if (index === 0) {
|
61
|
if (index === 0) {
|
|
@@ -202,7 +203,7 @@ const _processHeadData = (list) => { |
|
@@ -202,7 +203,7 @@ const _processHeadData = (list) => { |
202
|
if (index === 0) {
|
203
|
if (index === 0) {
|
203
|
|
204
|
|
204
|
data.isPraise = data.isPraise === 'Y';
|
205
|
data.isPraise = data.isPraise === 'Y';
|
205
|
- data.isFavor = data.isFavor === 'Y'
|
206
|
+ data.isFavor = data.isFavor === 'Y';
|
206
|
|
207
|
|
207
|
newData.headData = {
|
208
|
newData.headData = {
|
208
|
title: data.intro,
|
209
|
title: data.intro,
|
|
@@ -257,30 +258,31 @@ const _processHeadData = (list) => { |
|
@@ -257,30 +258,31 @@ const _processHeadData = (list) => { |
257
|
|
258
|
|
258
|
|
259
|
|
259
|
// 推荐商品
|
260
|
// 推荐商品
|
260
|
-const _getRelatedData = (id) => {
|
|
|
261
|
- return api.get('', {
|
|
|
262
|
- query: id,
|
|
|
263
|
- method: 'app.search.li'
|
|
|
264
|
- }).then((result) => {
|
|
|
265
|
- let productList = {};
|
|
|
266
|
-
|
|
|
267
|
- if (result && result.code === 200) {
|
|
|
268
|
- // console.log(result);
|
|
|
269
|
- _.forEach(result.data. product_list, function(data){
|
|
|
270
|
- //console.log(data)
|
|
|
271
|
- productList.name = data.product_name;
|
|
|
272
|
- productList.price = data.sales_price;
|
|
|
273
|
- productList.productId = data.product_id;
|
|
|
274
|
- productList.cnAlphabet = data.cn_alphabet;
|
|
|
275
|
- })
|
|
|
276
|
- // console.log(productList)
|
|
|
277
|
- return productList;
|
|
|
278
|
- } else {
|
|
|
279
|
- logger.error('推荐商品 cood 不是 200');
|
|
|
280
|
- return {};
|
|
|
281
|
- }
|
|
|
282
|
- });
|
|
|
283
|
-};
|
261
|
+// const _getRelatedData = (id) => {
|
|
|
262
|
+// return api.get('', {
|
|
|
263
|
+// query: id,
|
|
|
264
|
+// method: 'app.search.li'
|
|
|
265
|
+// }).then((result) => {
|
|
|
266
|
+// let productList = {};
|
|
|
267
|
+
|
|
|
268
|
+// if (result && result.code === 200) {
|
|
|
269
|
+// // console.log(result);
|
|
|
270
|
+// _.forEach(result.data. product_list, function(data) {
|
|
|
271
|
+// // console.log(data)
|
|
|
272
|
+// productList.name = data.product_name;
|
|
|
273
|
+// productList.price = data.sales_price;
|
|
|
274
|
+// productList.id = data.product_id;
|
|
|
275
|
+// productList.cnAlphabet = data.cn_alphabet;
|
|
|
276
|
+// });
|
|
|
277
|
+
|
|
|
278
|
+// // console.log(productList)
|
|
|
279
|
+// return productList;
|
|
|
280
|
+// } else {
|
|
|
281
|
+// logger.error('推荐商品 cood 不是 200');
|
|
|
282
|
+// return {};
|
|
|
283
|
+// }
|
|
|
284
|
+// });
|
|
|
285
|
+// };
|
284
|
|
286
|
|
285
|
/**
|
287
|
/**
|
286
|
* 详情页文章内容数据处理
|
288
|
* 详情页文章内容数据处理
|
|
@@ -310,43 +312,46 @@ const _processContentData = (list) => { |
|
@@ -310,43 +312,46 @@ const _processContentData = (list) => { |
310
|
});
|
312
|
});
|
311
|
|
313
|
|
312
|
contentData.contents = list;
|
314
|
contentData.contents = list;
|
313
|
- //console.log(list)
|
|
|
314
|
- let collocation = {};
|
|
|
315
|
-
|
|
|
316
|
- _.forEach(contentData.contents, function(value) {
|
|
|
317
|
- // console.log(value)
|
|
|
318
|
-
|
|
|
319
|
- if (value.goods) {
|
|
|
320
|
- console.log(value)
|
|
|
321
|
- // _.forEach(value.goods.data, function(data) {
|
|
|
322
|
|
315
|
|
323
|
- // _getRelatedData(51152761).then((result) => {
|
|
|
324
|
-
|
|
|
325
|
- // data = _.assign(data, result);
|
|
|
326
|
- // data = _.assign(data, {
|
|
|
327
|
- // link: `${config.siteUrl}/product/pro_${result.productId}_${data.productSkc}/${result.cnAlphabet}`
|
|
|
328
|
- // })
|
|
|
329
|
- // });
|
|
|
330
|
- // });
|
|
|
331
|
- }
|
|
|
332
|
-
|
|
|
333
|
- // if (value.goodsGroup) {
|
|
|
334
|
- // _.forEach(value.goodsGroup.data, function(data) {
|
|
|
335
|
- // //console.log(data)
|
|
|
336
|
- // _.forEach(data.list, function(value) {
|
|
|
337
|
- // // console.log(value)
|
|
|
338
|
- // _getRelatedData(51152761).then((result) => {
|
|
|
339
|
- // // console.log(result)
|
|
|
340
|
- // value = _.assign(value, result);
|
|
|
341
|
- // value = _.assign(value, {
|
|
|
342
|
- // link: `${config.siteUrl}/product/pro_${result.productId}_${value.productSkc}/${result.cnAlphabet}`
|
|
|
343
|
- // })
|
|
|
344
|
- // // console.log(value)
|
|
|
345
|
- // });
|
|
|
346
|
- // })
|
|
|
347
|
- // })
|
|
|
348
|
- // }
|
|
|
349
|
- })
|
316
|
+ // console.log(list)
|
|
|
317
|
+ // let collocation = {};
|
|
|
318
|
+
|
|
|
319
|
+ // _.forEach(contentData.contents, function(value) {
|
|
|
320
|
+ // // console.log(value)
|
|
|
321
|
+
|
|
|
322
|
+ // if (value.goods) {
|
|
|
323
|
+ // console.log(value);
|
|
|
324
|
+
|
|
|
325
|
+ // _.forEach(value.goods.data, function(data) {
|
|
|
326
|
+
|
|
|
327
|
+ // _getRelatedData(51152761).then((result) => {
|
|
|
328
|
+
|
|
|
329
|
+// data = _.assign(data, result);
|
|
|
330
|
+// data = _.assign(data, {
|
|
|
331
|
+// link: `${config.siteUrl}/product/pro_${result.id}_${data.productSkc}/${result.cnAlphabet}`
|
|
|
332
|
+// });
|
|
|
333
|
+ // });
|
|
|
334
|
+ // });
|
|
|
335
|
+ // }
|
|
|
336
|
+
|
|
|
337
|
+ // if (value.goodsGroup) {
|
|
|
338
|
+ // _.forEach(value.goodsGroup.data, function(data) {
|
|
|
339
|
+ // // console.log(data)
|
|
|
340
|
+ // _.forEach(data.list, function(value) {
|
|
|
341
|
+ // // console.log(value)
|
|
|
342
|
+// _getRelatedData(51152761).then((result) => {
|
|
|
343
|
+// // console.log(result)
|
|
|
344
|
+// value = _.assign(value, result);
|
|
|
345
|
+// value = _.assign(value, {
|
|
|
346
|
+// link: `${config.siteUrl}/product/pro_${result.id}_${value.productSkc}/${result.cnAlphabet}`
|
|
|
347
|
+// });
|
|
|
348
|
+
|
|
|
349
|
+// // console.log(value)
|
|
|
350
|
+// });
|
|
|
351
|
+ // });
|
|
|
352
|
+ // });
|
|
|
353
|
+ // }
|
|
|
354
|
+ // });
|
350
|
|
355
|
|
351
|
return contentData;
|
356
|
return contentData;
|
352
|
};
|
357
|
};
|
|
@@ -542,14 +547,14 @@ const addComment = (id, uid, comment) => { |
|
@@ -542,14 +547,14 @@ const addComment = (id, uid, comment) => { |
542
|
const shareData = () => {
|
547
|
const shareData = () => {
|
543
|
return serviceAPI.get('/guang/api/*/share/guang', {}).then((result) => {
|
548
|
return serviceAPI.get('/guang/api/*/share/guang', {}).then((result) => {
|
544
|
if (result && result.code === 200) {
|
549
|
if (result && result.code === 200) {
|
545
|
- console.log(34346)
|
550
|
+ console.log(34346);
|
546
|
return camelCase(result.data);
|
551
|
return camelCase(result.data);
|
547
|
} else {
|
552
|
} else {
|
548
|
logger.error('Related brand return code is not 200');
|
553
|
logger.error('Related brand return code is not 200');
|
549
|
return {};
|
554
|
return {};
|
550
|
}
|
555
|
}
|
551
|
});
|
556
|
});
|
552
|
-}
|
557
|
+};
|
553
|
|
558
|
|
554
|
/**
|
559
|
/**
|
555
|
* 获取详情页相关数据
|
560
|
* 获取详情页相关数据
|