Authored by 刘传洋

Merge branch 'feature/guang' of http://git.yoho.cn/fe/yohobuy-node into feature/guang

... ... @@ -287,8 +287,10 @@ exports.detail = (req, res, next) => {
exports.listDynamicData = (req, res) => {
let ids = req.query.ids;
guangModel.getDynamicDataByIds(ids).then(ret => {
res.status(200).send(ret);
let udid = ghelper.getUdid(req, res);
guangModel.getDynamicDataByIds(ids, udid, req.user.uid).then(ret => {
res.send(ret);
});
};
... ...
... ... @@ -842,17 +842,19 @@ const getDynamicDataById = id => {
* @param ids
* @returns {Promise.<T>|*}
*/
const getDynamicDataByIds = ids => {
return serviceApi.get('', {
ids: ids
}).then(res => {
const getDynamicDataByIds = (ids, udid, uid) => {
let params = {
ids: ids,
udid: udid
};
if (res && res.code === 200 && res.data) {
return res.data;
}
if (uid) {
_.assign(params, {
uid: uid
});
}
return Promise.reject('获取失败');
});
return serviceApi.get('', params, {cache: true});
};
module.exports = {
... ...
... ... @@ -22,7 +22,7 @@
</span>
<span class="page-view">
<i class="iconfont">&#xe627;</i>
{{pView}}
<em>{{pView}}</em>
</span>
</p>
<p class="content">{{content}}</p>
... ... @@ -40,7 +40,7 @@
<span class="comment">
<i class="iconfont">&#xe624;</i>
{{# comment}}
({{.}})
(<em>{{.}}</em>)
{{/ comment}}
</span>
</div>
... ...
... ... @@ -5,31 +5,51 @@
*/
var $ = require('yoho-jquery');
var $msgs = $('#msg-list');
function getDynamicByIds(ids) {
'use strict';
var param = {
return_type: 'jsonp',
ids: ids
};
return $.getJSON('//guang.yohobuy.com/guang/info/listData?callback=?', param);
return $.ajax({
type: 'GET',
url: '/guang/info/listData',
data: {
ids: ids
}
});
}
function renderData(data) {
'use strict';
var i, it, $it;
var i,
it,
$it;
var list;
if (data && data.code === 200 && (list = data.artList)) {
for (i = 0; i < list.length; i++) {
it = list[i];
if (data && data.code === 200 && data.list) {
for (i = 0; i < data.list.length; i++) {
it = data.list[i];
if (it && it.id) {
$it = $('#msg-list .msg-content[data-id=' + it.id + ']');
$it = $('.msg-content[data-id=' + it.id + ']', $msgs);
// 浏览数目
$it.find('.page-view em').text(it.views_num);
// 点赞状态
if (it.isPraise === 'Y') {
$it.find('.like-icon').addClass('liked');
} else {
$it.find('.like-icon').removeClass('liked');
}
// 点赞数目
$it.find('.like .num').text(it.praise_num);
$it.find('.page-view');
$it.find('.like-num');
$it.find('.comment');
// 评论数目
$it.find('.comment em').text(it.comment_num);
}
}
}
... ... @@ -40,15 +60,15 @@ function refreshData() {
var idArr = [];
$('#msg-list .msg-content').each(function() {
var id = $(this).attr('data-id');
$msgs.children('.msg-content').each(function() {
var id = $(this).data('id');
if (id) {
idArr.push(id);
}
});
getDynamicByIds(idArr.join(',')).done(renderData);
getDynamicByIds(idArr.join(',')).then(renderData);
}
refreshData();
... ...