Authored by zhangxiaoru

editorial

... ... @@ -15,15 +15,19 @@ const brand = require('../models/brand');
const index = (req, res, next) => {
let channel = req.cookies._Channel || 'men';
let contentCode = '';
let name = '';
if(channel === 'women') {
if (channel === 'women') {
contentCode = '527079e6c46d0f125eb46b835968971b';
} else if (channel === 'lifestyle'){
name = 'WOMEN首页';
} else if (channel === 'lifestyle') {
contentCode = '94b5ed607b6d565ffc29c2c04be121dc';
name = 'LIFT STYLE首页';
} else {
contentCode = '81886aaa5e82e3741bc1ba1e04ec7706';
name = 'MEN首页';
}
let appType = 1;
brand.getListData(contentCode, channel, appType).then((result) => {
... ... @@ -34,9 +38,9 @@ const index = (req, res, next) => {
brand: {
nav: [
{
link: '//guang.yohobuy.com/index/index?type=0',
link: 'www.yohobuy.com',
pathTitle: '首页',
name: 'MEN首页'
name: name
},
{
link: '',
... ...
... ... @@ -27,7 +27,7 @@ const _processListData = (list) => {
let listKey = [];
_.forEach(list.data.allList, function(value, index) {
_.forEach(value, function(data) {
data.brandDomain = `${config.siteUrl}/product/shop/${data.brandDomain}`;
});
... ... @@ -35,20 +35,27 @@ const _processListData = (list) => {
if (index === '0~9') {
index = '0-9';
} else {
listKey.push(index)
listKey.push(index);
}
// listData.push({
// key: index,
// brands: value
// });
});
listKey.sort();
listKey.push('0-9');
_.forEach(listKey, function(key) {
listData.push({
key: key,
brands: list.data.allList[key]
});
});
});
//console.log(listData)
return listData;
};
... ...
... ... @@ -17,12 +17,11 @@ const md5 = require('md5');
const index = (req, res, next) => {
let pageNum = req.query.page || 1;
let limit = req.query.limit || 20;
let type = req.query.type || 0;
let appType = 1;
// let gender = req.query.brand || 1;
editorialModel.getIndexData(type, pageNum, limit, appType).then((result) => {
editorialModel.getIndexData(pageNum, limit, appType).then((result) => {
// console.log(result.msg)
res.display('index', {
module: 'editorial',
... ... @@ -40,12 +39,11 @@ const index = (req, res, next) => {
name: 'Editorial资讯'
}
],
msgTypes: result.msgTypes,
msg: result.msg.tabs,
msg: result.tabs,
paginationOpts: {
page: pageNum,
limit: 20,
total: result.msg.total,
total: result.total,
queryParams: req.query
}
},
... ... @@ -127,7 +125,7 @@ const detail = (req, res, next) => {
editorialDetail: {
nav: [
{
link: '/editorial?type=0',
link: '#',
pathTitle: '首页',
name: 'MEN首页'
},
... ...
... ... @@ -73,27 +73,11 @@ const _processListData = (list) => {
});
listData.tabs = list.list.artList;
// console.log(listData)
return listData;
};
/**
* 资讯首页tab
* @param type
*/
const _getResources = (type, appType) => {
return serviceAPI.get('guang/api/v1/category/get', {
app_type: appType
}).then((result) => {
if (result && result.code === 200) {
return _processNavData(result.data, type);
} else {
logger.error('Information page navigation data return code is not 200');
return {};
}
});
};
/**
* 首页、列表页列表相关
... ... @@ -102,9 +86,8 @@ const _getResources = (type, appType) => {
* @param limit
* @returns {*}
*/
const _getBreakingSort = (type, pageNum, limit, appType) => {
const getIndexData = (pageNum, limit, appType) => {
return serviceAPI.get('guang/api/*/article/getList', {
sort_id: type,
page: pageNum,
limit: limit,
app_type: appType
... ... @@ -119,23 +102,6 @@ const _getBreakingSort = (type, pageNum, limit, appType) => {
};
/**
* 首页接口
* @param type
* @param pageNum
* @param limit
* @returns {*}
*/
const getIndexData = (type, pageNum, limit, appType) => {
return Promise.all([_getResources(type, appType), _getBreakingSort(type, pageNum, limit, appType)])
.then((result) => {
return {
msgTypes: result[0],
msg: result[1]
};
});
};
/**
* 列表页接口
* @param type
* @param pageNum
... ... @@ -265,10 +231,9 @@ const _processHeadData = (list) => {
* @param id
* @returns {*}
*/
const _getRelatedData = () => {
// console.log(idList);
const _getRelatedData = (idList) => {
return api.get('', {
qurey: '51162882',
query: '51121528,51191714,51176742,51176744,51188385,',
method: 'app.search.li'
}).then((result) => {
let productList = [];
... ... @@ -276,16 +241,15 @@ const _getRelatedData = () => {
if (result && result.code === 200) {
_.forEach(result.data.product_list, function(data) {
console.log(data.product_name)
// productList.push({
// name: data.product_name,
// price: data.sales_price,
// id: data.product_id,
// cnAlphabet: data.cn_alphabet
// });
productList.push({
name: data.product_name,
price: data.sales_price,
id: data.product_id,
cnAlphabet: data.cn_alphabet
});
});
console.log(productList)
return productList;
} else {
logger.error('推荐商品 cood 不是 200');
... ... @@ -304,8 +268,7 @@ const _processContentData = (list) => {
list = camelCase(list);
let contentData = {
contents: [],
collecation: []
contents: []
};
_.forEach(list, function(value) {
... ... @@ -325,8 +288,12 @@ const _processContentData = (list) => {
contentData.contents = list;
let idList = '';
let sknList = '';
let formatData = [];
let recoLength = '';
let related = {
relatedReco: [],
relatedGroup: []
}
_.forEach(contentData.contents, function(value) {
... ... @@ -335,42 +302,56 @@ const _processContentData = (list) => {
_.forEach(value.goods.data, function(data) {
idList += data.id + ',';
// idList = '51152761';
formatData.push(data);
related.relatedReco.push(data);
});
}
//console.log(idList)
recoLength = idList.length/9;
if (value.goodsGroup) {
// _.forEach(value.goodsGroup.data, function(data) {
// // console.log(data)
// // _.forEach(data.list, function(value) {
// // sknList += value.id + ',';
_.forEach(value.goodsGroup.data, function(data) {
// // formatData.push(value);
_.forEach(data.list, function(value) {
idList += value.id + ',';
// // });
// });
related.relatedGroup.push(value);
});
});
}
});
// console.log(idList)
_getRelatedData().then((result) => {
//console.log(result)
_getRelatedData(idList).then((result) => {
// console.log(result)
_.forEach(formatData, function(data, index) {
// console.log(formatData)
if (related.relatedReco) {
_.forEach(related.relatedReco, function(data, index) {
data[index] = _.assign(result[index]);
data= _.assign(data, result[index]);
//result.remove(index)
});
});
}
if (related.relatedGroup) {
_.forEach(related.relatedGroup, function(data, index) {
data= _.assign(data, result[index]);
// console.log(formatData)
return formatData;
});
}
// console.log(related)
return related;
}).then(() => {
contentData.contents.push({
related: related
});
console.log(contentData)
return contentData;
});
return contentData;
... ... @@ -473,6 +454,19 @@ const _getRelateBrand = (id) => {
});
};
const _getArticlePre = (id) => {
// return serviceAPI.get('guang/api/*/article/getArticlePre', {
// id: id
// }).then((result) => {
// if (result && result.code === 200) {
// console.log(result)
// return result;
// } else {
// logger.error('上一篇不是200');
// return {};
// }
// });
};
/**
* 资讯收藏
* @param uid
... ... @@ -567,7 +561,6 @@ const addComment = (id, uid, comment) => {
const shareData = () => {
return serviceAPI.get('/guang/api/*/share/guang', {}).then((result) => {
if (result && result.code === 200) {
console.log(34346);
return camelCase(result.data);
} else {
logger.error('Related brand return code is not 200');
... ... @@ -587,6 +580,7 @@ const getDetailData = (id) => {
_getArticleData(id),
_getContentData(id),
_getCommentsData(id),
_getArticlePre(id),
_getRelateBrand(id)]);
let res = yield _processHeadData([result[0], result[1], result[3]]);
... ...
... ... @@ -42,8 +42,8 @@
</div>
{{/ text}}
{{# goods}}
<div class="related-reco">
{{# related}}
<div class="related-reco related-collo">
<div class="article-title">
<div class="title-line"></div>
<div class="text-center">
... ... @@ -53,16 +53,17 @@
</div>
</div>
<div class="related-goods">
{{# data}}
<div class="related-goods collocation">
{{# relatedReco}}
{{> related-goods}}
{{/ data}}
{{/ relatedReco}}
</div>
</div>
{{/ goods}}
{{!-- {{# goodsGroup}}
<div class="related-reco">
{{!-- {{#if relatedGroup}} --}}
<div class="related-reco related-group">
<div class="article-title">
<div class="title-line"></div>
<div class="text-center">
... ... @@ -72,15 +73,13 @@
</div>
</div>
<div class="related-goods">
{{# data}}
{{# list}}
{{> related-goods}}
{{/ list}}
{{/ data}}
<div class="related-goods goods">
{{# relatedGroup}}
{{> related-goods}}
{{/ relatedGroup}}
</div>
</div>
{{/ goodsGroup}} --}}
{{/ related}}
{{/ content}}
{{#if brands}}
... ...
... ... @@ -3,13 +3,8 @@
{{> path-nav}}
<div class="index-content">
<ul class="msg-nav">
{{# msgTypes}}
<li data-type="{{id}}" {{#if isActive}}class="active"{{/if}}>
<a class="pjax-link" href="{{url}}">{{name}}</a>
</li>
{{/ msgTypes}}
</ul>
<span class="nav-title inline-block"><b>最新</b>资讯</span>
<div id="msg-list" class="msg-list">
{{# msg}}
... ...
<div class="article-title">
<div class="title-line"></div>
<div class="text-center">
<div class="text">
<span>{{relatedTitle}}</span>
</div>
</div>
</div>
\ No newline at end of file
<div class="content-msg clearfix" data-id="{{id}}">
<div class="msg-left">{{categoryName}}</div>
<div class="msg-left"><i class="iconfont">&#xe606;</i> <b class="time-word">{{publishTime}}</b></div>
<div class="msg-right">
<a class="msg-title" href="/editorial/{{id}}.html" target="_blank">{{title}}</a>
<a href="/editorial/{{id}}.html" target="_blank">
... ... @@ -7,10 +7,6 @@
</a>
<div class="content">{{intro}}</div>
<div class="msg-app">
<span class="time">
<i class="iconfont">&#xe606;</i>
<b class="time-word">{{publishTime}}</b>
</span>
<span class="like-comment">
<i class="iconfont like-icon{{#if isPraise}}liked{{/if}}">&#xe60e;</i>
<b class="like-num">{{praiseNum}}</b>
... ...
<div class="goods-info" data-skn="{{skn}}">
<div class="good-info" data-skn="{{skn}}">
<a href="{{link}}" target="_blank">
<img class="thumb" src="{{image src 219 295}}">
</a>
... ...
... ... @@ -185,3 +185,11 @@ $('#comment-info').trigger('keyup');
if (tag === 0) {
$('.article-tag').hide();
}
if($('.collocation').find('.good-info').length === 0) {
$('.related-collo').hide();
}
if($('.goods').find('.good-info').length === 0) {
$('.related-group').hide();
}
\ No newline at end of file
... ...
div.blk-pagination {
width: 500px;
padding: 0;
text-align: center;
a {
display: inline-block;
... ...
... ... @@ -101,18 +101,35 @@
.related-goods {
padding-top: 60px;
}
.goods-info {
width: 219px;
margin-right: 0;
float: left;
margin-right: 20px;
img {
.good-info {
width: 219px;
height: 295px;
float: left;
margin:0 20px 15px 0;
img {
width: 219px;
height: 295px;
}
.name {
font-size: 12px;
line-height: 30px;
height: 30px;
overflow: hidden;
display: block;
text-overflow:ellipsis;
white-space:nowrap
}
.price {
display: block;
line-height: 30px;
height: 30px;
text-align: center;
}
}
}
.related-brand {
... ... @@ -431,7 +448,23 @@
}
}
.blk-pagination {
width: 400px;
.good-info {
width: 219px;
margin-right: 0;
float: left;
margin-right: 20px;
img {
width: 219px;
height: 295px;
}
.name {
font-size: 12px;
line-height: 30px;
height: 30px;
overflow: hidden;
display: block;
}
}
}
... ...
.editorial-index-page {
.msg-nav {
height: 40px;
.nav-title {
margin-top: 35px;
font-size: 14px;
font-weight: 700;
border-bottom: 1px solid #eee;
padding-left: 300px;
padding-bottom: 5px;
overflow: hidden;
li {
float: left;
height: 30px;
width: 120px;
line-height: 40px;
text-align: center;
font-size: 14px;
display: list-item;
list-style-type: none;
color: #999;
a {
display: block;
height: 100%;
width: 100%;
text-decoration: none;
color: #999;
}
width: 100%;
height: 30px;
&.active {
a {
color: #000;
}
}
b {
font-size: 18px;
margin-right: 5px;
}
}
... ... @@ -44,4 +24,5 @@
@import "msg";
@import "list";
@import "detail";
@import "related-goods";
@import "article-related";
... ...
... ... @@ -11,6 +11,7 @@
line-height: 30px;
text-align: center;
border-bottom: 1px solid #bbb;
color: #a0a0a0;
}
.msg-right {
... ... @@ -74,7 +75,6 @@
}
.like-comment {
margin-left: 40px;
color: #a6a6a6;
cursor: pointer;
font-size: 14px;
... ...
.good-info {
width: 219px;
margin-right: 0;
float: left;
margin-right: 20px;
img {
width: 219px;
height: 295px;
}
.name {
font-size: 12px;
line-height: 30px;
height: 30px;
overflow: hidden;
display: block;
}
}
... ...