mirror of
https://gitee.com/koogua/course-tencent-cloud.git
synced 2025-06-22 19:44:02 +08:00
32 lines
1.0 KiB
JavaScript
32 lines
1.0 KiB
JavaScript
layui.use(['jquery', 'helper'], function () {
|
|
|
|
var $ = layui.jquery;
|
|
var helper = layui.helper;
|
|
|
|
$('body').on('click', '.answer-like', function () {
|
|
var $this = $(this);
|
|
var $likeCount = $this.prev();
|
|
var likeCount = $likeCount.data('count');
|
|
helper.checkLogin(function () {
|
|
$.ajax({
|
|
type: 'POST',
|
|
url: $this.data('url'),
|
|
success: function () {
|
|
if ($this.hasClass('liked')) {
|
|
$this.attr('title', '点赞支持').text('点赞').removeClass('liked');
|
|
likeCount--;
|
|
} else {
|
|
$this.attr('title', '取消点赞').text('已赞').addClass('liked');
|
|
likeCount++;
|
|
}
|
|
$likeCount.data('count', likeCount).text(likeCount);
|
|
}
|
|
});
|
|
});
|
|
});
|
|
|
|
$('body').on('click', '.answer-edit', function () {
|
|
window.location.href = $(this).data('url');
|
|
});
|
|
|
|
}); |