123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form','bootstrap-daterangepicker'], function ($, undefined, Backend, Table, Form) {
- var Controller = {
- index: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'vip/admin/collect/index?ids='+Config.ids,
- index_month_url: 'vip/admin/collect/index?ids='+Config.ids+'&type=month',
- add_url: 'vip/admin/collect/add',
- edit_url: 'vip/admin/collect/edit',
- del_url: 'vip/admin/collect/del',
- multi_url: 'vip/admin/collect/multi',
- table: 'vip/admin_collect',
- recharge_new: 'vip/admin/collect/recharge_new',
- },
- 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 startDate, endDate;
- if (data['begin_date']) {
- startDate = data['begin_date'];
- } else {
- startDate = Moment().subtract(1, 'day');
- }
- if (data['end_date']) {
- endDate = data['end_date'];
- } else {
- endDate = Moment().subtract(1, 'day');
- }
- $('#rangeday').daterangepicker({
- // autoUpdateInput: false,
- startDate: startDate,
- endDate: endDate,
- maxDate: Moment().subtract(1, 'day'),
- minDate: Moment().subtract(12, 'month'),
- locale: {
- format: 'YYYY-MM-DD',
- applyLabel: '确认',
- cancelLabel: '取消',
- fromLabel: '从',
- toLabel: '到',
- weekLabel: 'W',
- customRangeLabel: '选择时间',
- daysOfWeek: ["日", "一", "二", "三", "四", "五", "六"],
- monthNames: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
- }
- });
- }
- });
- //#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
- $(document).on('click', '.flush', function () {
- window.location.reload();
- });
- $(document).on('click','.layer-open',function () {
- Fast.api.open($(this).attr('href'), $(this).data('title')?$(this).data('title'):'查看渠道明细', {});
- return false;
- });
- },
- table: {
- first: function () {
- var table = $("#table");
- // 初始化渠道商表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'id',
- sortName: 'createdate',
- columns: [
- [
- {field: 'wx_nickname', title: __('公众号')},
- {field: 'increase', title: __('今日新增')},
- {field: 'increase_fllow', title: __('主号关注'),operate:false,formatter: Controller.api.formatter.follow},
- //{field: 'guide_follow_num', title: __('导粉关注'),formatter: Controller.api.formatter.guide},
- {field: 'unfollow_num', title: __('主号取关'),formatter: Controller.api.formatter.unfollow},
- {field: 'net_follow_num', title: __('净关注'),formatter: Controller.api.formatter.netfollow},
- {field: 'increase_recharge', title: __('已付费'),operate:false,formatter: Controller.api.formatter.recharge},
- {field: 'day_recharge_user_count', title: __('新增用户的充值人数'),operate:false},
- {field: 'day_recharge_user_money', title: __('新增用户的充值金额'),operate:false},
- {field: 'increase_m', title: __('男性')},
- {field: 'increase_f', title: __('女性')},
- ]
- ]
- });
- // 为表格1绑定事件
- Table.api.bindevent(table);
- Controller.api.bindevent();
- },
- second: function () {
- var table2 = $("#table2");
- // 初始化渠道商表格
- table2.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_month_url,
- pk: 'id',
- sortName: 'createdate',
- columns: [
- [
- {field: 'createdate', title: __('日期')},
- {field: 'increase', title: __('新增数量')},
- {field: 'increase_fllow', title: __('主号关注'),operate:false,formatter: Controller.api.formatter.follow},
- {field: 'unfollow_num', title: __('主号取关'),formatter: Controller.api.formatter.unfollow},
- {field: 'net_follow_num', title: __('净关注'),formatter: Controller.api.formatter.netfollow},
- {field: 'increase_recharge', title: __('已付费'),operate:false,formatter: Controller.api.formatter.recharge},
- {field: 'day_recharge_user_count', title: __('新增用户的充值人数'),operate:false},
- {field: 'day_recharge_user_money', title: __('新增用户的充值金额'),operate:false},
- {field: 'increase_m', title: __('男性')},
- {field: 'increase_f', title: __('女性')},
- ]
- ]
- });
- // 为表格1绑定事件
- Table.api.bindevent(table2);
- Controller.api.bindevent();
- },
- three: function () {
- var table5 = $("#table3");
- $.fn.bootstrapTable.defaults.commonSearch = true
- $.fn.bootstrapTable.defaults.searchFormVisible = false
- $.fn.bootstrapTable.defaults.showExport = false
- // 初始化表格
- table5.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.recharge_new,
- sortName: 'reg_date',
- columns: [
- [
- {field: 'reg_date', title: '日期', operate: 'RANGE', id: 'rangeday', formatter: function(value){
- return value.substr(0,4)+'-'+value.substr(4,2)+'-'+value.substr(6,2);
- }},
- {field: 'new', title: '新增用户', operate: false},
- {
- field: 'recharge_total',
- title: '累计充值',
- operate: false,
- formatter: function (value, row) {
- var sum = 0;
- for (var index in row) {
- if (index.indexOf('day') != -1 && row[index]) {
- sum += parseFloat(row[index])
- }
- }
- return sum.toFixed(2);
- }
- },
- {
- field: 'cost', title: '成本', operate: false
- },
- {
- field: 'recover_rate', title: '回本率', operate: false, formatter: function (value, row) {
- if (row.cost) {
- var sum = 0;
- for (var index in row) {
- if (index.indexOf('day') != -1 && row[index]) {
- sum += parseFloat(row[index])
- }
- }
- return (sum / row.cost * 100).toFixed(2) + '%';
- } else{
- return '-';
- }
- }
- },
- {field: 'day1', title: '第1日充值', operate: false},
- {field: 'day2', title: '第2日充值', operate: false},
- {field: 'day3', title: '第3日充值', operate: false},
- {field: 'day4', title: '第4日充值', operate: false},
- {field: 'day5', title: '第5日充值', operate: false},
- {field: 'day6', title: '第6日充值', operate: false},
- {field: 'day7', title: '第7日充值', operate: false},
- {field: 'day8', title: '第8日充值', operate: false},
- {field: 'day9', title: '第9日充值', operate: false},
- {field: 'day10', title: '第10日充值', operate: false},
- {field: 'day11', title: '第11日充值', operate: false},
- {field: 'day12', title: '第12日充值', operate: false},
- {field: 'day13', title: '第13日充值', operate: false},
- {field: 'day14', title: '第14日充值', operate: false},
- {field: 'day15', title: '第15日充值', operate: false},
- {field: 'day16', title: '第16日充值', operate: false},
- {field: 'day17', title: '第17日充值', operate: false},
- {field: 'day18', title: '第18日充值', operate: false},
- {field: 'day19', title: '第19日充值', operate: false},
- {field: 'day20', title: '第20日充值', operate: false},
- {field: 'day21', title: '第21日充值', operate: false},
- {field: 'day22', title: '第22日充值', operate: false},
- {field: 'day23', title: '第23日充值', operate: false},
- {field: 'day24', title: '第24日充值', operate: false},
- {field: 'day25', title: '第25日充值', operate: false},
- {field: 'day26', title: '第26日充值', operate: false},
- {field: 'day27', title: '第27日充值', operate: false},
- {field: 'day28', title: '第28日充值', operate: false},
- {field: 'day29', title: '第29日充值', operate: false},
- {field: 'day30', title: '第30日充值', operate: false},
- {
- field: 'operate',
- title: __('Operate'),
- formatter: function (value, row, index) {
- return '<a href="/admin/vip/admin/collect/recharge_detail/reg_date/'+row.reg_date+'" class="btn btn-xs btn-success btn-editone layer-open" data-title="查看渠道明细">查看渠道明细</a>';
- }
- }
- ]
- ]
- });
- Table.api.bindevent(table5);
- Controller.api.bindevent();
- }
- },
- add: function () {
- Controller.api.bindevent();
- },
- edit: function () {
- Controller.api.bindevent();
- },
- recharge_detail: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- recharge_detail: 'vip/admin/collect/recharge_detail?reg_date='+Config.reg_date,
- },
- search: false,
- commonSearch: false,
- searchFormVisible: false,
- showExport: false,
- });
- var recharge_detail = $("#recharge_detail");
- // 初始化表格
- recharge_detail.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.recharge_detail,
- pk: 'reg_date',
- sortName: 'reg_date',
- columns: [
- [
- {field: 'reg_date', title: '日期', operate: false, formatter: function(value){
- return value.substr(0,4)+'-'+value.substr(4,2)+'-'+value.substr(6,2);
- }},
- {field: 'nickname', title: '公众号名称', operate: false},
- {field: 'new', title: '新增用户', operate: false},
- {
- field: 'recharge_total',
- title: '累计充值',
- operate: false,
- formatter: function (value, row) {
- var sum = 0;
- for (var index in row) {
- if (index.indexOf('day') != -1 && row[index]) {
- sum += parseFloat(row[index])
- }
- }
- return sum.toFixed(2);
- }
- },
- {
- field: 'cost', title: '成本', operate: false
- },
- {
- field: 'recover_rate', title: '回本率', operate: false, formatter: function (value, row) {
- if (row.cost) {
- var sum = 0;
- for (var index in row) {
- if (index.indexOf('day') != -1 && row[index]) {
- sum += parseFloat(row[index])
- }
- }
- return (sum / row.cost * 100).toFixed(2) + '%';
- } else {
- return '-';
- }
- }
- },
- {field: 'day1', title: '第1日充值', operate: false},
- {field: 'day2', title: '第2日充值', operate: false},
- {field: 'day3', title: '第3日充值', operate: false},
- {field: 'day4', title: '第4日充值', operate: false},
- {field: 'day5', title: '第5日充值', operate: false},
- {field: 'day6', title: '第6日充值', operate: false},
- {field: 'day7', title: '第7日充值', operate: false},
- {field: 'day8', title: '第8日充值', operate: false},
- {field: 'day9', title: '第9日充值', operate: false},
- {field: 'day10', title: '第10日充值', operate: false},
- {field: 'day11', title: '第11日充值', operate: false},
- {field: 'day12', title: '第12日充值', operate: false},
- {field: 'day13', title: '第13日充值', operate: false},
- {field: 'day14', title: '第14日充值', operate: false},
- {field: 'day15', title: '第15日充值', operate: false},
- {field: 'day16', title: '第16日充值', operate: false},
- {field: 'day17', title: '第17日充值', operate: false},
- {field: 'day18', title: '第18日充值', operate: false},
- {field: 'day19', title: '第19日充值', operate: false},
- {field: 'day20', title: '第20日充值', operate: false},
- {field: 'day21', title: '第21日充值', operate: false},
- {field: 'day22', title: '第22日充值', operate: false},
- {field: 'day23', title: '第23日充值', operate: false},
- {field: 'day24', title: '第24日充值', operate: false},
- {field: 'day25', title: '第25日充值', operate: false},
- {field: 'day26', title: '第26日充值', operate: false},
- {field: 'day27', title: '第27日充值', operate: false},
- {field: 'day28', title: '第28日充值', operate: false},
- {field: 'day29', title: '第29日充值', operate: false},
- {field: 'day30', title: '第30日充值', operate: false}
- ]
- ]
- });
- },
- api: {
- bindevent: function () {
- Form.api.bindevent($("form[role=form]"));
- },formatter: {
- follow: function (value, row, index) {
- return value;
- },
- recharge: function (value, row, index) {
- return value;
- },
- unfollow: function (value, row, index) {
- return value;
- },
- netfollow: function (value, row, index) {
- return value;
- },
- createtime:function(value,row,index){
- return value.substring(0,4)+'-'+ value.substring(4,6)+'-'+value.substring(6,8);
- },
- }
- }
- };
- return Controller;
- });
|