123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form','bootstrap-daterangepicker','dateyearmonth'], function ($, undefined, Backend, Table, Form) {
- var wait=60;
- if (Config.groupId != 8) {
- $(function () {
- time();
- });
- }
- //$('#ajaxkandian').click(function(){
- // $.post('/index/book/ajaxFee',{userId:1,bookId:30,chapter_id:50,chapter_name:"下啊是事实"},function(data){
- // console.log(data);
- // })
- //});
- function time() {
- if (wait == 0) {
- //执行ajax拉新数据
- $.post('/admin/user/collect/ajaxtoday',{ids:Config.ids},function(data){
- //console.log(data);
- if (data){
- $('#increase_m').text(data.increase_m);
- $('#increase_f').text(data.increase_f);
- $('#increase').text(data.increase);
- $('#increase_fllow').text(data.increase_fllow);
- $('#increase_recharge').text(data.increase_recharge);
- $('#day_recharge_user_count').text(data.day_recharge_user_count);
- $('#guide_follow_num').text(data.guide_follow_num);
- $('#unfollow_num').text(data.unfollow_num);
- $('#net_follow_num').text(data.net_follow_num);
- $('#new_user_recharge').text(data.day_recharge_user_money);
- }
- });
- wait = 60;
- time();
- } else {
- $('.flush').text(wait+'秒后刷新');
- wait--;
- setTimeout(function() {
- time()
- }, 1000)
- }
- }
- var Controller = {
- index: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'user/collect/index?ids='+Config.ids,
- recharge_new: 'user/collect/recharge_new?ids='+Config.ids,
- add_url: 'user/collect/add',
- edit_url: 'user/collect/edit',
- del_url: 'user/collect/del',
- multi_url: 'user/collect/multi',
- table: 'user_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 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: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
- }
- });
- }
- });
- //绑定事件
- $('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).unbind('shown.bs.tab');
- });
- $(document).on('click','.layer-open',function () {
- Fast.api.open($(this).attr('href'), $(this).data('title')?$(this).data('title'):'查看渠道明细', {});
- return false;
- });
- //必须默认触发shown.bs.tab事件
- $('ul.nav-tabs li.active a[data-toggle="tab"]').trigger("shown.bs.tab");
- //#endregion
- },
- table: {
- first:function(){
- var table = $("#table1");
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'id',
- sortName: 'createdate',
- columns: [
- [
- {field: 'createdate', title: __('日期'),formatter: Controller.api.formatter.createtime},
- {field: 'increase', title: __('新增用户')},
- {field: 'increase_fllow', title: __('主号关注'),operate:false,formatter: Controller.api.formatter.follow},
- {field: 'guide_follow_num', title: __('导粉关注'), visible: false, 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: __('女性')},
- ]
- ]
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- $(document).on('click', '.flush', function () {
- window.location.reload();
- });
- },
- second: function () {
- var table = $("#table2");
- $.fn.bootstrapTable.defaults.commonSearch = true
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.recharge_new,
- pk: 'id',
- sortName: 'date',
- columns: [
- [
- {field: 'reg_date', title: '日期', operate: 'RANGE', addclass: '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, formatter: function(value, row){
- value = value == null ? '-' : value;
- return value + '<i class="fa fa-pencil edit-cost" data-cost="'+value+'" data-id="'+row.id+'" style="cursor: pointer"></i>'
- }},
- {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}
- ]
- ]
- });
- $(document).delegate('.edit-cost','click',function(){
- var cost = $(this).data('cost');
- var id = $(this).data('id');
- Layer.open({
- type: 1,
- title: '修改金额',
- maxmin: false,
- area: ['300px', '200px'],
- btn: ['确认', '取消'],
- shadeClose: true,
- resize: false,
- // skin: 'layui-layer-rim',
- content: '<input id="cost" type="text" value="'+cost+'" style="margin: 10px 10px;">',
- yes: function (index, layero) {
- $.ajax({
- url: 'user/collect/recharge_cost',
- data: {cost: $('#cost').val(), id: id},
- type: 'get',
- success: function(){
- layer.close(index);
- table.bootstrapTable('refresh');
- }
- });
- },
- btn2: function (index, node) {
- layer.close(index)
- }
- });
- })
- }
- },
- add: function () {
- Controller.api.bindevent();
- },
- edit: function () {
- Controller.api.bindevent();
- },
- api: {
- bindevent: function () {
- Form.api.bindevent($("form[role=form]"));
- },formatter: {
- follow: function (value, row, index) {
- return value;
- },
- recharge: function (value, row, index) {
- return value;
- },
- guide: 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;
- });
|