作者 景龙
1 个管道 的构建 通过 耗费 0 秒

修复点赞收藏功能

... ... @@ -3,20 +3,32 @@ $(function(){
// 点赞
$('.likes').click(function() {
if ($(this).children('img').attr('src') == host+'/themes/simpleboot3/public/assets/starImg/bicon_02.png') {
operation('/portal/star/like');
var login = operation('/portal/star/like');
if(login == 0){
return false;
}
$(this).children('img').attr('src', host+'/themes/simpleboot3/public/assets/starImg/bicon_15.png');
} else {
operation('/portal/star/cancelLike');
var login = operation('/portal/star/cancelLike');
if(login == 0){
return false;
}
$(this).children('img').attr('src', host+'/themes/simpleboot3/public/assets/starImg/bicon_02.png');
}
});
//收藏
$('.collections').click(function() {
if ($(this).children('img').attr('src') == host+'/themes/simpleboot3/public/assets/starImg/bicon_03.png') {
operation('/portal/star/collection');
var login = operation('/portal/star/collection');
if(login == 0){
return false;
}
$(this).children('img').attr('src', host+'/themes/simpleboot3/public/assets/starImg/bicon_16.png');
} else {
operation('/portal/star/cancelCollection');
var login = operation('/portal/star/cancelCollection');
if(login == 0){
return false;
}
$(this).children('img').attr('src', host+'/themes/simpleboot3/public/assets/starImg/bicon_03.png');
}
});
... ... @@ -120,6 +132,7 @@ $(function(){
//点赞收藏
function operation(url){
var article_id = getUrlParam('id');
var is_login = 1;
$.ajax({
type: 'POST',
url: url,
... ... @@ -127,14 +140,17 @@ function operation(url){
'article_id':article_id,
},
dataType: 'json',
async : false,
success: function (data) {
if (data.code == 1) {
mask(data.msg);
} else {
mask(data.msg);
is_login = data.code;
}
}
});
return is_login;
}
//弹框
function mask(msg) {
... ...