收费1元,仅仅是象征性的, 大家可以不花钱, 用10个积分兑换下载即可.这样就让大家可以进一步亲自体验积分的重要性与乐趣.
也可以用在CMS内容页.在内容页模板加入如下代码即可
<button type="button"><i class="si si-present give-money" data-id="{$id}">打赏</i></button> <script type="text/javascript"> //打赏积分 按钮要定义一个 give-money 类 var sys_dirname = "{:config('system_dirname')}"; var give_money_url = "{:purl('givemoney/api/give','index')}"; var count_money_url = "{:purl('givemoney/api/count','index')}"; var getlist_money_url = "{:purl('givemoney/api/getlist','index')}"; $(document).ready(function () { $(".give-money").each(function(){ var that = $(this); var id = that.data('id'); var rid = typeof(that.data('rid'))=='undefined' ? 0 : that.data('rid'); var cid = typeof(that.data('cid'))=='undefined' ? 0 : that.data('cid'); that.each(function(){ var obj = $(this); $.post(count_money_url,{'sysname':sys_dirname,'id':id,'rid':rid,'cid':cid},function(res){ if(res.code==0){ //有人打赏过了 obj.html(' '+res.data); obj.click(function(){ layer.confirm('请问你是要打赏?还是要查看打赏的用户列表',{btn:['我要打赏','查看用户']},function(){ layer.closeAll(); putnum(); },function(){ getlist(); }); }); }else{ //还没人打赏 obj.click(function(){ putnum(); }); } }); }); //显示打赏用户 var getlist = function(){ layer.closeAll(); layer.load(1); $.post(getlist_money_url,{'sysname':sys_dirname,'id':id,'rid':rid,'cid':cid},function(res){ layer.closeAll(); if(res.code==0){ var str = ''; res.data.forEach(function(rs){ str += '<div style="padding:5px;"><span style="color:blue;">' + rs.username + '</span> 打赏积分: ' + rs.money + ' 个 <span style="color:#666;">['+rs.create_time+']</span></div>'; }); layer.open({ title:'打赏用户列表', type: 1, area: '98%', content: '<div style="padding:15px;">' + str + '</div>', }); }else{ layer.alert(res.msg); } }).fail(function(){layer.closeAll();layer.alert('页面出错了!')}); } //打赏输入积分个数 var putnum = function(){ layer.prompt({ formType: 0, value: '3', title: '请输入要打赏的积分个数', //area: ['100px', '20px'] //formType:2 自定义文本域宽高 }, function(value, index, elem){ layer.close(index); postdata(value); } ); }; //打赏提交数据 var postdata = function(num){ layer.load(1); $.post(give_money_url,{'sysname':sys_dirname,'money':num,'id':id,'rid':rid,'cid':cid,'about':''},function(res){ layer.closeAll(); if(res.code==0){ layer.msg('谢谢你的打赏!'); }else{ layer.alert(res.msg); } }).fail(function(){layer.closeAll();layer.alert('页面出错了!')}); } }); }); </script>