1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-22 03:32:47 +08:00
xiaochong0302 328aea1e2d 1.优化章节列表UI
2.优化评价UI
2025-04-20 17:03:17 +08:00

52 lines
1.5 KiB
JavaScript

layui.use(['jquery', 'helper'], function () {
var $ = layui.jquery;
var helper = layui.helper;
$('.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);
}
});
});
});
$('.sidebar-lesson').on('click', function () {
if ($(this).hasClass('deny')) {
return false;
}
var url = $(this).data('url');
helper.checkLogin(function () {
window.location.href = url;
});
});
$('.icon-reply').on('click', function () {
$('html').scrollTop($('#comment-anchor').offset().top);
});
var $commentList = $('#comment-list');
if ($commentList.length > 0) {
helper.ajaxLoadHtml($commentList.data('url'), $commentList.attr('id'));
}
});