Authored by biao

debounce the like click on guang page

... ... @@ -21,6 +21,8 @@ var $loading = $(''),
var searching = false;
var mySwiper = {};
var isLoading = false;
ellipsis.init();
if ($loadMoreInfo.length > 0) {
... ... @@ -82,13 +84,16 @@ function initInfosEvt($container) {
//点赞
$btn = $this.closest('.like-btn');
if ($btn.length > 0) {
if ($btn.length > 0 && !isLoading) {
e.preventDefault();
if ($btn.hasClass('like')) {
opt = 'cancel';
}
$info = $this.closest('.guang-info');
isLoading = true;
$.ajax({
type: 'POST',
url: '/guang/opt/praiseArticle',
... ... @@ -99,6 +104,7 @@ function initInfosEvt($container) {
success: function(data) {
var code = data.code;
if (code === 200) {
$btn.next('.like-count').text(data.data);
... ... @@ -108,6 +114,9 @@ function initInfosEvt($container) {
},
error: function() {
tip.show('网络断开连接了~');
},
complete: function() {
isLoading = false;
}
});
return;
... ... @@ -233,4 +242,4 @@ exports.mySwiper = mySwiper;
exports.initSwiper = initSwiper;
exports.initInfosEvt = initInfosEvt;
exports.setLazyLoadAndMellipsis = setLazyLoadAndMellipsis;
exports.loadMore = loadMore;
\ No newline at end of file
exports.loadMore = loadMore;
... ...