define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
var wait=60;
// $(function(){
// time();
// });
function time() {
// if (wait == 0) {
//执行ajax拉新数据
$.post('/admin/vipindex/ajaxtoday'+ Config.channelstr,{groupId:Config.groupId,authId:Config.authId},function(data){
if (data){
$('#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)
// }
}
$(".flush").click(function(){
location.reload();
});
var Controller = {
index: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'vipindex/index',
thirty_url:'vipindex/orderThirtyStatistics',
table: 'orders_collect'
},
showToggle: false,
showColumns: false,
showExport: false,
commonSearch: false,
showExport: true,
operate: false,
search:false,
onLoadSuccess: function (data) {
$("[data-toggle='tooltip']").tooltip({trigger: 'focus hover',html : true });
}
});
//#region
// Tab 切换
//绑定事件
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
var panel = $($(this).attr("href"));
if (panel.size() > 0) {
Controller.table[panel.attr("id")].call(this);
$(this).on('click', function (e) {
$($(this).attr("href")).find(".btn-refresh").trigger("click");
});
}
//移除绑定的事件
$(this).unbind('shown.bs.tab');
});
//必须默认触发shown.bs.tab事件
$('ul.nav-tabs li.active a[data-toggle="tab"]').trigger("shown.bs.tab");
//#endregion
// 为表格绑定事件
Table.api.bindevent(table);
},
table: {
first: function () {
var table = $("#table");
// 初始化渠道商表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'createdate',
columns: [
[
{field: 'name', title: __('公众号'),operate:false,formatter:function(val,row,index){
return val ? val :"(未授权)";
}},
{field: 'recharge_money', title: __('充值金额'),formatter:function(val,row,index){
return row.recharge_money*1
}},
{field: 'normal_recharge_orders_count', title: __('充值笔数'),formatter:function(val,row,index){
return row.normal_recharge_orders*1+row.vip_recharge_orders*1
} },
{field: 'normal_recharge_orders', title: __('充值人均'),formatter:function(val,row,index){
var money = row.recharge_money*1;
var num = row.normal_recharge_orders*1+row.vip_recharge_orders*1;
if(money > 0){
return Math.round(money/num*100)/100
}else{
return 0;
}
}}
]
]
});
// 为表格1绑定事件
Table.api.bindevent(table);
Controller.api.bindevent();
},
second: function () {
var table2 = $("#table2");
// 初始化渠道商表格
table2.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.thirty_url,
columns: [
[
{field: 'f_date', title: __('日期'),operate:false},
{field: 'money_total', title: __('充值金额'),operate:false},
{field: 'orders_total', title: __('充值笔数')},
{field: 'normal_recharge_orders', title: __('充值人均'),formatter:function(val,row,index){
var money = row.money_total*1;
var num = row.orders_total*1;
if(num > 0){
return Math.round(money/num*100)/100
}else{
return '-';
}
}}
]
]
});
// 为表格1绑定事件
Table.api.bindevent(table2);
Controller.api.bindevent();
}
},
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+'已支付:'+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+'已支付:'+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; });