1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-23 03:50:56 +08:00
2024-01-22 12:37:58 +08:00

41 lines
1.3 KiB
JavaScript

layui.use(['jquery', 'helper'], function () {
var $ = layui.jquery;
var helper = layui.helper;
var $commentList = $('#comment-list');
if ($commentList.length > 0) {
helper.ajaxLoadHtml($commentList.data('url'), $commentList.attr('id'));
}
$('.icon-praise').on('click', function () {
var $this = $(this);
var $parent = $this.parent();
var $likeCount = $parent.next();
var likeCount = $likeCount.data('count');
helper.checkLogin(function () {
$.ajax({
type: 'POST',
url: $parent.data('url'),
success: function () {
if ($this.hasClass('active')) {
$this.removeClass('active');
$parent.attr('title', '点赞支持');
likeCount--;
} else {
$this.addClass('active');
$parent.attr('title', '取消点赞');
likeCount++;
}
$likeCount.data('count', likeCount).text(likeCount);
}
});
});
});
$('.icon-reply').on('click', function () {
$('html').scrollTop($('#comment-anchor').offset().top);
});
});