X1内页动态收藏数量
更新于:2021-08-19 22:56<span><li class="scqun" data-id="{$info.id}"><i class="icon iconfont icon-shoucang"></i><span class="favnum">{:fun("count@info",'qb_fav',['aid'=>$id])}</span><div class="sfav">收藏</div></li></span>
<script type="text/javascript">
$(document).ready(function () {
$(".scqun").each(function(){
var id = $(this).data('id');
var that = this;
if("{$userdb.uid}"==""){ //判断登录
$(this).click(function(){
if(check_login()!==true)
return;
});
}else{
//检查是否已关注
$.get("{:purl('fav/api/check')}?type={:config('system_dirname')}&id="+id,function(res){
if(res.code==1){ //还没收藏
$(that).click(function(){ //添加收藏点击事件
$.get("{:purl('fav/api/add')}?type={:config('system_dirname')}&id="+id,function(res){
if(res.code==1){ //收藏失败
layer.msg(res.msg);
}else if(res.code==0){ //收藏成功
var num = $(that).find('.favnum').html();
num++;
$('.favnum').html(num);
$(that).find('.sfav').html('已收藏');
$(that).find('.icon').addClass('col1');
$(that).find('.sfav').addClass('col1');
layer.msg('收藏成功');
}
});
});
}else if(res.code==0){
$(that).click(function(){ //已收藏
layer.msg('您已收藏啦');
});
$(that).find('.sfav').html('已收藏');
$(that).find('.icon').addClass('col1');
$(that).find('.sfav').addClass('col1 w800');
}
});
}
});
});
</script>