Authored by 2586703@qq.com

评论插件修改

... ... @@ -431,6 +431,7 @@ exports.init = function() {
attitudeWtfNum = $('.stats-btn .wtf').find('span');
if (wow == 0) {
attitudeWowNum.removeClass('hasNum');
attitudeWowNum.text('');
} else {
attitudeWowNum.addClass('hasNum');
attitudeWowNum.text(wow);
... ... @@ -438,6 +439,7 @@ exports.init = function() {
if (zzz == 0) {
attitudeZzzNum.removeClass('hasNum');
attitudeZzzNum.text('');
} else {
attitudeZzzNum.addClass('hasNum');
attitudeZzzNum.text(zzz);
... ... @@ -445,6 +447,7 @@ exports.init = function() {
if (wtf == 0) {
attitudeWtfNum.removeClass('hasNum');
attitudeWtfNum.text('');
} else {
attitudeWtfNum.addClass('hasNum');
attitudeWtfNum.text(wtf);
... ...
... ... @@ -28,19 +28,21 @@ require("./login");
publishUrl: '/writer/default/publish',
deleteUrl: '/writer/default/delete',
commentNum: $(".comment-num"),
commentItemTpl: '<li class="clearfix">' +
commentItemTpl: '\{{# comment}}' +
'<li class="clearfix">' +
'<div class="userimg">' +
'<img src="\{{userimg}}" alt="">' +
'<img src="\{{headpic}}" alt="">' +
'<i class="\{{partnerType}}"></i>' +
'</div>' +
'<div class="userinfo">' +
'<h6>\{{username}}</h6> ' +
'<h6>\{{nick}}</h6> ' +
'<p class="comment-text">\{{content}}</p>' +
'\{{# isSelf}}' +
'<a class="delete-comment" href="javascript:;" pid="{{id}}"></a>' +
'\{{/ isSelf}} ' +
'</div>' +
'</li>',
'</li>' +
'\{{/ comment}}',
thirdLogin: false,
isEdit: false,
isMobile: false,
... ... @@ -80,7 +82,6 @@ require("./login");
dataType: 'jsonp',
jsonp: 'callback',
success: function(response) {
console.log(response);
var data = response.data, //返回数据的data
viewMoreNum = data.total - 5, //评论总数-5,除显示评论剩下的评论数量
moreString = viewMoreNum + '', //剩余评论数量转为字符串
... ... @@ -345,18 +346,32 @@ require("./login");
var url = $(this).attr("href"),
pageHtml,
pageIcon,
commentListTop;
pageList,
pageData,
commentListTop,
pageTpl = '\{{# pageList}}' +
'<a class="pager-item \{{# isChoosen}}pager-item-choosen\{{/ isChoosen}}" href="\{{link}}">\{{text}}</a>' +
'\{{/ pageList}}'; //引入评论html模板
$.ajax({
url: url,
url: url + '?id=' + that.options.cid,
dataType: 'jsonp',
jsonp: 'callback',
success: function(response) {
$(".comments-list").empty();
pageHtml = mustache.render(that.options.commentItemTpl, response.data.comment);
pageList = {
comment: response.data.comment
}
pageHtml = mustache.render(that.options.commentItemTpl, pageList);
$(".comments-list").html(pageHtml);
pageIcon = $('<div class="channel-index-pager">' + response.data.page + '</div>');
$(".comment-pager-content").html(pageIcon);
pageData = {
pageList: response.data.page
}
pageIcon = mustache.render(pageTpl, pageData);
console.log(pageIcon);
$('.channel-index-pager').html($(pageIcon));
commentListTop = $(".comments-list").offset().top - $("#minEnterprise").outerHeight();
$(window).scrollTop(commentListTop);
... ...