layui.use(['layer'], function() { var form = layui.form, layer = parent.layer === undefined ? layui.layer : top.layer, $ = layui.jquery; $(document).on("click",".buybtn",function(){ var buyid = $(this).attr('art-id'); var _this = $(this); swal({ title: '确定购买?', text: '', type: 'question', showCancelButton: true, confirmButtonColor: '#1E9FFF', confirmButtonText: '确定', }).then((result) => { if (result.value) { var load = layer.load(); $.getJSON(bloghost+'zb_users/plugin/LayCenter/PublicCMD.php?act=buy&id='+buyid,function(result){ if (result.code == 1) { $('.boxbody').html(result.paidcontent).css('border','solid 1px #ff5722'); swal(result.msg,'','success'); }else if (result.code == 2){ swal({ title: '余额不足', text: '', type: 'error', showCancelButton: true, confirmButtonColor: '#1E9FFF', confirmButtonText: '立即充值', }).then((result) => { if (result.value) { window.location.href = bloghost+"MemberCenter#Price"; } }) }else{ swal(result.msg,'','error'); } layer.close(load); }); } }) }) var artid = $('[art-id]').attr('art-id'); $(document).on("click",".lcFavBtn",function(){ var btn = $(this); $.getJSON(bloghost+'zb_users/plugin/LayCenter/PublicCMD.php?act=favbtn&id='+artid,function(result){ if (result.code == 1) { swal('已收藏','收藏的文章可在用户中心中查看','success'); btn.html('已收藏'); }else if (result.code == 2){ swal('已取消','','success'); btn.html('收藏'); }else{ swal(result.msg,'','info'); } }); }) $.getJSON(bloghost+'zb_users/plugin/LayCenter/PublicCMD.php?act=favcheck&id='+artid,function(result){ if (result.code == 1) { var t = '已收藏'; }else{ var t = '收藏'; } try{ $('.shoucang').before(''+t+''); }catch(d){ } }); }) function CountDown() { if (leftTime >= 0) { days = Math.floor(leftTime/60/60/24); hours = Math.floor(leftTime/60/60%24); minutes = Math.floor(leftTime/60%60); seconds = Math.floor(leftTime % 60); $("#days").html(days); $("#hours").html(hours); $("#minutes").html(minutes); $("#seconds").html(seconds); --leftTime; } else{ if (timer !== undefined){ clearInterval(timer); try{ $("#lefttime").html(endmsg); }catch(d){ } } } } CountDown(); var timer = setInterval("CountDown()", 1000);