Authored by zhangxiaoru

editorial

... ... @@ -55,10 +55,10 @@ const index = (req, res, next) => {
// }
const list = (req, res) => {
let pageNum = req.query.page || 1;
let limit = req.query.limit || 20;
let tag = req.params.tag || '暗黑';
let authorId = req.params.authorId || 0;
let pageNum = req.query.page;
let limit = req.query.limit;
let tag = req.params.tag;
let authorId = req.params.authorId;
// let curChannel = getChannelData(req.channel, req.query.query);
... ... @@ -102,13 +102,14 @@ const list = (req, res) => {
};
const detail = (req, res, next) => {
let id = req.params.id || 52571;
let id = req.params.id;
console.log(id)
editorialModel.getDetailData(id).then((result) => {
res.display('detail', {
module: 'editorial',
page: 'detail',
title: '资讯详情',
title: result.head.title,
editorialDetail: {
nav: [
{
... ... @@ -201,7 +202,7 @@ const detail = (req, res, next) => {
let setCollect = (req, res, next) => {
let uid = req.user.uid;
let id = req.params.id || 52571;
let id = req.params.id;
editorialModel.setCollect(id, uid).then((result) => {
res.json(result);
... ... @@ -210,7 +211,7 @@ let setCollect = (req, res, next) => {
let cancelCollect = (req, res, next) => {
let uid = req.user.uid;
let id = req.params.id || 52571;
let id = req.params.id;
editorialModel.setCollect(id, uid).then((result) => {
res.json(result);
... ... @@ -220,7 +221,7 @@ let cancelCollect = (req, res, next) => {
// 点赞
let setPraise = (req, res, next) => {
let udid = req.user.uid;
let id = req.params.id || 52571;
let id = req.params.id;
editorialModel.setPraise(id, udid).then((result) => {
res.json(result);
... ... @@ -229,7 +230,7 @@ let setPraise = (req, res, next) => {
let cancelPraise = (req, res, next) => {
let udid = req.user.uid;
let id = req.params.id || 52571;
let id = req.params.id;
editorialModel.cancelPraise(id, udid).then((result) => {
res.json(result);
... ... @@ -238,7 +239,7 @@ let cancelPraise = (req, res, next) => {
let addComment = (req, res, next) => {
let uid = req.user.uid;
let id = req.params.id || 52571;
let id = req.params.id;
let content = req.body.content;
editorialModel.setCollect(id, uid, content).then((result) => {
... ...
... ... @@ -198,63 +198,6 @@ const _processHeadData = (list) => {
})();
};
// const _getGoodsSort = (skn) => {
// return api.get('', {
// product_skn: 51137901,
// method: 'h5.product.data'
// }).then((result) => {
// if (result && result.code === 200) {
// console.log(result)
// return result;
// } else {
// logger.error('数据返回 code 不是 200');
// return {};
// }
// });
// };
const _processContentData = (list) => {
list = list || [];
list = camelCase(list);
_.forEach(list, function(data) {
if (data.text) {
data.text.data.text = data.text.data.text.replace(/<.*?>/ig, '');
}
// if (data.goods) {
// console.log(data.goods)
// _.forEach(data.goods, function(data, index) {
// console.log(index)
// _.forEach(data, function(value) {
// // console.log(value)
// // // _getGoodsSort(value.id);
// });
// });
// }
});
return list;
};
// // const _processCommentsData = (list) => {
// // list = list || [];
// // list = camelCase(list);
// // //let commentNum = list.list.length;
// // console.log(list)
// // }
// // head数据
const _getHeadData = (id) => {
... ... @@ -276,7 +219,7 @@ const _getContentData = (id) => {
article_id: id
}).then((result) => {
if (result && result.code === 200) {
return _processContentData(result.data);
return camelCase(result.data);
} else {
logger.error('资讯详情内容数据返回 code 不是 200');
return {};
... ...
... ... @@ -37,12 +37,12 @@
{{# text}}
<div class="article-text block">
{{# data}}
<p>{{text}}</p>
<p>{{{text}}}</p>
{{/ data}}
</div>
{{/ text}}
{{# goodsGroup}}
{{!-- {{# goodsGroup}}
<div class="related-reco">
<div class="article-title">
<div class="title-line"></div>
... ... @@ -71,7 +71,7 @@
{{/ goods}}
</div>
</div>
{{/ relatedGoods}}
{{/ relatedGoods}} --}}
{{/ content}}
{{#if brands}}
... ... @@ -122,7 +122,7 @@
<div class="article-tag">
<i class="tag-icon iconfont">&#xe648;</i>
<ul>
<ul id="tags">
{{# tags}}
<li>
<a href="{{url}}" target="_blank">{{name}}</a>
... ...
... ... @@ -20,7 +20,8 @@ module.exports = {
cookieDomain: 'yohobuy.com',
domains: {
api: 'http://devapi.yoho.cn:58078/', // devapi.yoho.cn:58078 testapi.yoho.cn:28078 devapi.yoho.cn:58078
service: 'http://testservice.yoho.cn:28077/', // testservice.yoho.cn:28077 devservice.yoho.cn:58077
//service: 'http://testservice.yoho.cn:28077/', // testservice.yoho.cn:28077 devservice.yoho.cn:58077
service: 'http://service.yoho.cn/',
search: 'http://192.168.102.216:8080/yohosearch/'
},
useOneapm: false,
... ...
... ... @@ -17,6 +17,7 @@ var $commentList = $commentArea.find('.comments-wrap'),
$commentBtn = $('#comment-btn'),
MAX_COMMENTS_WORDS = 100,
$wordCountTip = $('#word-count-tip'),
tag = $('#tags').find("li").length,
_alert = dialog.Alert;
require('../plugins/share');
... ... @@ -86,32 +87,10 @@ $('#collect-btn').click(function() {
}
}).then(function(data) {
switch (data.code) {
// case 401:
// // 防止从已有col的页面再次进行跳转后出错的情况
// if (/\?col=(1|0)/.test(location.href)) {
// hrefUrl = location.href.replace(/\?col=(1|0)/, '?col=' + col);
// } else {
// hrefUrl = location.href + '?col=' + col;
// }
// location.href = '//www.yohobuy.com/signin.html?refer=' + encodeURI(hrefUrl);
// break;
case 400:
new _alert(data.message).show();
break;
case 200:
if (/\?col=(1|0)/.test(location.href)) {
// 如果页面url中含有col,为了防止页面刷新时收藏或者取消收藏会根据col来的问题,进行页面跳转拿掉参数
location.href = location.href.replace(/\?col=(1|0)/, '');
} else {
$this.toggleClass('collected');
}
break;
default:
break;
if (data.code === 200) {
new _alert('收藏成功').show();
}else {
new _alert(data.message).show();
}
collecting = false;
});
... ... @@ -136,7 +115,7 @@ function comment() {
var commentInfo = $('#comment-info').val();
if (commentInfo === '') {
new _alert('评论不能为空');
new _alert('评论不能为空').show();
return false;
}
commenting = true;
... ... @@ -148,29 +127,18 @@ function comment() {
},
type: 'post',
success: function(data) {
switch (data.code) {
// case 401:
// locating = true;
// location.href = '//www.yohobuy.com/signin.html?refer=' +
// window.escape(location.href + '#comment-info');
// break;
case 400:
new _alert(data.message).show();
break;
case 200:
if (data.data) {
$commentList.html(data.data.content);
$commentNum.html(data.data.count);
showComment();
// clear comment-text
$('#comment-info').val('').keyup();
}
break;
default:
break;
if (data.code === 200) {
$commentList.html(data.data.content);
$commentNum.html(data.data.count);
showComment();
// clear comment-text
$('#comment-info').val('').keyup();
}else {
new _alert(data.message).show();
}
commenting = false;
}
});
... ... @@ -210,5 +178,8 @@ $('#comment-info').keyup(function() {
$wordCountTip.html(showTxt);
});
// init
$('#comment-info').trigger('keyup');
if (tag === 0) {
$('.article-tag').hide();
}
... ...
... ... @@ -29,8 +29,6 @@ $('.editorial-index-page').on('click', '.like-icon', function() {
// }
// prising = msgId;
$this.toggleClass('liked');
if ($this.hasClass('liked')) {
url = '/editorial/info/cancelPraise';
} else {
... ... @@ -45,10 +43,9 @@ $('.editorial-index-page').on('click', '.like-icon', function() {
}
}).then(function(data) {
if (data.code === 200) {
console.log(data);
$this.toggleClass('liked');
$this.next('b').html(data.data);
}
if (data.code === 500) {
}else{
new _alert(data.message).show();
}
... ...
... ... @@ -15,7 +15,6 @@ $('.editorial-list-page').on('click', '.like-icon', function() {
msgId = $this.closest('.msg-content').data('id'),
url;
$this.toggleClass('liked');
if ($this.hasClass('liked')) {
url = '/editorial/info/cancelPraise';
} else {
... ... @@ -30,21 +29,11 @@ $('.editorial-list-page').on('click', '.like-icon', function() {
}
}).then(function(data) {
if (data.code === 200) {
$this.next('b').removeClass('num-0').children('.num').html(data.data);
}
if (data.code === 500) {
$this.toggleClass('liked');
$this.next('b').html(data.data);
}else {
new _alert(data.message).show();
}
// if (data.code === 200) {
// if (data.data * 1 === 0) {
// $this.next('b').addClass('num-0').children('.num').html('0'); // 隐藏数字显示
// } else {
// console.log(data.data)
// $this.next('b').removeClass('num-0').children('.num').html(data.data);
// }
// }
// prising = false;
});
}).on('mouseenter mouseleave', '.like-icon', function() {
... ...
... ... @@ -3,6 +3,8 @@
height: 50px;
line-height: 50px;
color: #666;
width: 100%;
overflow: hidden;
a {
text-decoration: none;
... ...