define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { var wait=60; $(function(){ time(); }); $('ul.nav-tabs li').click(function(){ $(this).addClass('active').siblings().removeClass('active') }); function time() { if (wait == 0) { //执行ajax拉新数据 $.post('/admin/collect/ajaxtoday'+ Config.channelstr,{groupId:Config.groupId,authId:Config.authId},function(data){ //console.log(data); if (data){ if(Config.groupId == 3) { //渠道商 $('#agent_recharge').text('¥'+data.agent_recharge); $('#agent_benefit').text('¥'+data.agent_recharge_benefit); $('#today_pv').text('pv:'+data.pv); $('#today_uv').text('uv:'+data.uv); } if(Config.groupId == 4){ //代理商 $('#today_pv').text('pv:'+data.pv); $('#today_uv').text('uv:'+data.uv); } $('#recharge_money').text('¥'+data.recharge_money); $('#recharge_money_benefit').text('¥'+data.recharge_money_benefit); var yzf = parseInt(data.normal_recharge_orders)>0?data.normal_recharge_orders:0; var wzf = data.normal_recharge_orders_count-data.normal_recharge_orders; var html_str = "普通充值
"+ "¥"+data.normal_recharge_money+"

"+ "已支付:"+yzf+"笔
"+ "未支付:"+wzf+"笔
"+ "完成率:"+Number(data.normal_percent).toFixed(0)+"%
"; var vip_yzf = parseInt(data.vip_recharge_orders) >0 ?data.vip_recharge_orders:0; var vip_wzf = data.vip_recharge_orders_count - data.vip_recharge_orders; $('#normal_first').html(html_str); var vip_html_str = "年费VIP会员
"+ "¥"+data.vip_recharge_money+"

"+ "已支付:"+vip_yzf+"笔
"+ "未支付:"+vip_wzf+"笔
"+ "完成率:"+Number(data.vip_percent).toFixed(0)+"%
"; $('#vip_first').html(vip_html_str); } }); wait = 60; time(); } else { $('.flush').text(wait+'秒后刷新'); wait--; setTimeout(function() { time() }, 1000) } } var Controller = { index: function () { // 初始化表格参数配置 Table.api.init({ extend: { index_url: 'collect/index'+Config.channelstr, table: 'orders_collect' }, showToggle: false, showColumns: false, showExport: false, commonSearch: false, operate: false, search:false, onLoadSuccess: function (data) { $("[data-toggle='tooltip']").tooltip({trigger: 'focus hover',html : true }); } }); var table = $("#table"); if(Config.groupId < 3){ // 初始化管理员表格 table.bootstrapTable({ url: $.fn.bootstrapTable.defaults.extend.index_url, pk: 'id', sortName: 'createdate', columns: [ [ {field: 'createdate', title: __('日期'),formatter: Controller.api.formatter.createtime}, {field: 'pv', title: __('PV')}, {field: 'uv', title: __('UV')}, {field: 'recharge_money', title: __('总充值')}, {field: 'normal_recharge_money', title: __('普通充值'),formatter: Controller.api.formatter.normal_recharge_money}, {field: 'normal_recharge_orders_count', title: __('普通充值订单数'),formatter: Controller.api.formatter.normal_recharge_orders_count }, {field: 'vip_recharge_money', title: __('年度VIP会员'),formatter: Controller.api.formatter.vip_recharge_money}, {field: 'vip_recharge_orders_count', title: __('年度VIP会员订单数'),formatter: Controller.api.formatter.vip_recharge_orders_count}, {field: 'recharge_money_benefit', title: __('渠道商分成收益')}, {field: 'normal_recharge_orders', title: __('总分成收益'),formatter: Controller.api.formatter.normal_recharge_orders} ] ] }); }else if(Config.groupId == 3){ // 初始化渠道商表格 table.bootstrapTable({ url: $.fn.bootstrapTable.defaults.extend.index_url, pk: 'id', sortName: 'createdate', columns: [ [ {field: 'createdate', title: __('日期'),formatter: Controller.api.formatter.createtime}, {field: 'pv', title: __('PV')}, {field: 'uv', title: __('UV')}, {field: 'recharge_money', title: __('总充值')}, {field: 'normal_recharge_money', title: __('普通充值'),formatter: Controller.api.formatter.normal_recharge_money}, {field: 'normal_recharge_orders_count', title: __('普通充值订单数'),formatter: Controller.api.formatter.normal_recharge_orders_count }, {field: 'vip_recharge_money', title: __('年度VIP会员'),formatter: Controller.api.formatter.vip_recharge_money}, {field: 'vip_recharge_orders_count', title: __('年度VIP会员订单数'),formatter: Controller.api.formatter.vip_recharge_orders_count}, {field: 'self_recharge', title: __('充值'),formatter: Controller.api.formatter.total_benefit}, {field: 'self_recharge_benefit', title: __('分成收益'),formatter: Controller.api.formatter.total_benefit}, {field: 'agent_recharge', title: __('代理商充值'),formatter: Controller.api.formatter.total_benefit}, {field: 'agent_benefit', title: __('代理商分成收益'),formatter: Controller.api.formatter.total_benefit}, {field: 'total_benefit', title: __('实际收益'),formatter: Controller.api.formatter.total_benefit_channel} ] ] }); }else if(Config.groupId == 4){ // 初始化代理商表格 table.bootstrapTable({ url: $.fn.bootstrapTable.defaults.extend.index_url, pk: 'id', sortName: 'createdate', columns: [ [ {field: 'createdate', title: __('日期'),formatter: Controller.api.formatter.createtime}, {field: 'pv', title: __('PV')}, {field: 'uv', title: __('UV')}, {field: 'recharge_money', title: __('总充值')}, {field: 'normal_recharge_money', title: __('普通充值'),formatter: Controller.api.formatter.normal_recharge_money}, {field: 'normal_recharge_orders_count', title: __('普通充值订单数'),formatter: Controller.api.formatter.normal_recharge_orders_count }, {field: 'vip_recharge_money', title: __('年度VIP会员'),formatter: Controller.api.formatter.vip_recharge_money}, {field: 'vip_recharge_orders_count', title: __('年度VIP会员订单数'),formatter: Controller.api.formatter.vip_recharge_orders_count}, {field: 'recharge_money_benefit', title: __('总分成收益'),formatter: Controller.api.formatter.total_benefit_channel} ] ] }); } // 为表格绑定事件 Table.api.bindevent(table); }, api: { bindevent: function () { Form.api.bindevent($("form[role=form]")); },formatter: { normal_recharge_orders: function (value, row, index) { return '¥'+((row.recharge_money-row.recharge_money_benefit)* 1.00).toFixed(2) + ''; }, normal_recharge_money:function (value, row, index) { var normal_recharge_str = '

¥'+row.normal_recharge_money+'

'; if(row.normal_recharge_orders>0){ var normal_recharge_str_avg = Number(row.normal_recharge_money/row.normal_recharge_orders) * 1.00; normal_recharge_str += '成功人次:'+row.normal_recharge_orders+'
人均:¥'+ Number(normal_recharge_str_avg.toFixed(2))+'
'; }else{ normal_recharge_str +='成功人次:0
人均:¥0'+'
'; } return normal_recharge_str; }, normal_recharge_orders_count:function(value,row,index){ var normal_recharge_order_str = '

已支付:'+row.normal_recharge_orders+'笔

'; var wzf = row.normal_recharge_orders_count-row.normal_recharge_orders; if(row.normal_recharge_orders > 0){ var normal_recharge_str_order_avg = (row.normal_recharge_orders*100/row.normal_recharge_orders_count) * 1.00; normal_recharge_order_str += '

未支付:'+wzf+'笔

'; normal_recharge_order_str += '

完成率:'+ Math.floor(normal_recharge_str_order_avg)+'%'+'

'; }else{ normal_recharge_order_str += '

未支付:'+wzf+'笔

'; normal_recharge_order_str += '

完成率:0%'+'

'; } return normal_recharge_order_str; }, vip_recharge_money:function (value, row, index) { var vip_recharge_str = '

¥'+row.vip_recharge_money+'

'; if(row.vip_recharge_orders > 0){ var vip_recharge_str_avg = Number(row.vip_recharge_money/row.vip_recharge_orders) * 1.00; vip_recharge_str += '成功人次:'+row.vip_recharge_orders+'
人均:¥'+ Number(vip_recharge_str_avg.toFixed(2))+'
'; }else{ vip_recharge_str +='成功人次:0
人均:¥0'+'
'; } return vip_recharge_str; }, vip_recharge_orders_count:function(value,row,index){ var vip_recharge_order_str = '

已支付:'+row.vip_recharge_orders+'笔

'; var vipwzf = row.vip_recharge_orders_count-row.vip_recharge_orders; if(row.vip_recharge_orders > 0){ if(row.vip_recharge_orders_count){ var vip_recharge_str_order_avg = (row.vip_recharge_orders*100/row.vip_recharge_orders_count) * 1.00; }else{ var vip_recharge_str_order_avg = 0; } vip_recharge_order_str += '

未支付:'+vipwzf+'笔

'; vip_recharge_order_str += '

完成率:'+ Math.floor(vip_recharge_str_order_avg)+'%'+'

'; }else{ vip_recharge_order_str += '

未支付:'+vipwzf+'笔

'; vip_recharge_order_str += '

完成率:0%'+'

'; } return vip_recharge_order_str; }, total_benefit:function(value,row,index){ return '¥'+value; }, total_benefit_channel:function(value,row,index) { return '¥' + Number(value).toFixed(2) + ''; }, createtime:function(value,row,index){ return value.substring(0,4)+'-'+ value.substring(4,6)+'-'+value.substring(6,8); }, } } }; return Controller; });