Authored by zhangxiaoru

editorial

... ... @@ -5,7 +5,8 @@
*/
'use strict';
const serviceAPI = global.yoho.ServiceAPI;
const api = global.yoho.API;
// const api = global.yoho.API;
const camelCase = global.yoho.camelCase;
const _ = require('lodash');
const Promise = require('bluebird');
... ... @@ -54,7 +55,7 @@ const _processListData = (list) => {
listData = _.assign(listData, {
total: list.total
})
});
_.forEach(list.list.artList, (data, index) => {
if (index === 0) {
... ... @@ -202,7 +203,7 @@ const _processHeadData = (list) => {
if (index === 0) {
data.isPraise = data.isPraise === 'Y';
data.isFavor = data.isFavor === 'Y'
data.isFavor = data.isFavor === 'Y';
newData.headData = {
title: data.intro,
... ... @@ -257,30 +258,31 @@ const _processHeadData = (list) => {
// 推荐商品
const _getRelatedData = (id) => {
return api.get('', {
query: id,
method: 'app.search.li'
}).then((result) => {
let productList = {};
if (result && result.code === 200) {
// console.log(result);
_.forEach(result.data. product_list, function(data){
//console.log(data)
productList.name = data.product_name;
productList.price = data.sales_price;
productList.productId = data.product_id;
productList.cnAlphabet = data.cn_alphabet;
})
// console.log(productList)
return productList;
} else {
logger.error('推荐商品 cood 不是 200');
return {};
}
});
};
// const _getRelatedData = (id) => {
// return api.get('', {
// query: id,
// method: 'app.search.li'
// }).then((result) => {
// let productList = {};
// if (result && result.code === 200) {
// // console.log(result);
// _.forEach(result.data. product_list, function(data) {
// // console.log(data)
// productList.name = data.product_name;
// productList.price = data.sales_price;
// productList.id = data.product_id;
// productList.cnAlphabet = data.cn_alphabet;
// });
// // console.log(productList)
// return productList;
// } else {
// logger.error('推荐商品 cood 不是 200');
// return {};
// }
// });
// };
/**
* 详情页文章内容数据处理
... ... @@ -310,43 +312,46 @@ const _processContentData = (list) => {
});
contentData.contents = list;
//console.log(list)
let collocation = {};
_.forEach(contentData.contents, function(value) {
// console.log(value)
if (value.goods) {
console.log(value)
// _.forEach(value.goods.data, function(data) {
// _getRelatedData(51152761).then((result) => {
// data = _.assign(data, result);
// data = _.assign(data, {
// link: `${config.siteUrl}/product/pro_${result.productId}_${data.productSkc}/${result.cnAlphabet}`
// })
// });
// });
}
// if (value.goodsGroup) {
// _.forEach(value.goodsGroup.data, function(data) {
// //console.log(data)
// _.forEach(data.list, function(value) {
// // console.log(value)
// _getRelatedData(51152761).then((result) => {
// // console.log(result)
// value = _.assign(value, result);
// value = _.assign(value, {
// link: `${config.siteUrl}/product/pro_${result.productId}_${value.productSkc}/${result.cnAlphabet}`
// })
// // console.log(value)
// });
// })
// })
// }
})
// console.log(list)
// let collocation = {};
// _.forEach(contentData.contents, function(value) {
// // console.log(value)
// if (value.goods) {
// console.log(value);
// _.forEach(value.goods.data, function(data) {
// _getRelatedData(51152761).then((result) => {
// data = _.assign(data, result);
// data = _.assign(data, {
// link: `${config.siteUrl}/product/pro_${result.id}_${data.productSkc}/${result.cnAlphabet}`
// });
// });
// });
// }
// if (value.goodsGroup) {
// _.forEach(value.goodsGroup.data, function(data) {
// // console.log(data)
// _.forEach(data.list, function(value) {
// // console.log(value)
// _getRelatedData(51152761).then((result) => {
// // console.log(result)
// value = _.assign(value, result);
// value = _.assign(value, {
// link: `${config.siteUrl}/product/pro_${result.id}_${value.productSkc}/${result.cnAlphabet}`
// });
// // console.log(value)
// });
// });
// });
// }
// });
return contentData;
};
... ... @@ -542,14 +547,14 @@ const addComment = (id, uid, comment) => {
const shareData = () => {
return serviceAPI.get('/guang/api/*/share/guang', {}).then((result) => {
if (result && result.code === 200) {
console.log(34346)
console.log(34346);
return camelCase(result.data);
} else {
logger.error('Related brand return code is not 200');
return {};
}
});
}
};
/**
* 获取详情页相关数据
... ...
... ... @@ -42,7 +42,7 @@
</div>
{{/ text}}
{{# goods}}
{{!-- {{# goods}}
<div class="related-reco">
<div class="article-title">
<div class="title-line"></div>
... ... @@ -80,7 +80,7 @@
{{/ data}}
</div>
</div>
{{/ goodsGroup}}
{{/ goodsGroup}} --}}
{{/ content}}
{{#if brands}}
... ...
<div class="goods-info" data-skn="{{skn}}">
<a href="{{link}}" target="_blank">
<img class="thumb" src="{{image src 219 295}}">
</a>
<div class="desc">
<a class="name" href="{{link}}" target="_blank">{{name}}</a>
<p class="price">{{price}}</p>
</div>
</div>
\ No newline at end of file
... ...
... ... @@ -32,10 +32,10 @@ $('#prise-btn').click(function() {
if ($this.hasClass('liked')) {
// 点赞
url = '/editorial/info/cancelPraise';
url = '/editorial/info/cancelPraise';
} else {
// 取消点赞
url = '/editorial/info/praise';
url = '/editorial/info/praise';
}
prising = true;
$.ajax({
... ...