
{if $gid=="" /}
<span id="ckguanzhu" class="join" onclick="joinGroup({$id})">+关注</span>
{else /}
{/if}
没有关注 就显示 关注字样,如果已关注 则显示: 已关注或者, 为空不显示, 或者退出。
只能用官方 论坛的关注 改, 不知道有没有更好的办法。
<em class="gzqun" data-id="{$info.id}">关注</em>
<script type="text/javascript">
//关注圈子
$(document).ready(function () {
$(".gzqun").each(function(){
var id = $(this).data('id');
var that = this;
if("{$userdb.uid}"==""){ //游客点关注,就直接进入对应的__QUN__
$(this).click(function(){
window.location.href = "{:urls('qun/content/show')}?id="+id;
});
}else{
//检查是否已关注
$.get("{:urls('qun/wxapp.member/ckjoin')}?id="+id,function(res){
if(res.code==1){ //还没关注
$(that).click(function(){ //添加关注点击事件
$.get("{:urls('qun/wxapp.member/join')}?id="+id,function(res){
if(res.code==1){ //关注失败
layer.alert(res.msg);
}else if(res.code==0){ //关注成功
layer.msg(','+res.msg);
$(that).html('');
$(that).click(function(){
window.location.href = "{:urls('qun/content/show')}?id="+id;
});
}
});
});
}else if(res.code==0){ //已关注
$(that).html('');
$(that).click(function(){
window.location.href = "{:urls('qun/content/show')}?id="+id;
});
}
});
}
});
});
</script>