define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { var wait=60; $(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+'('+data.follow+'%)'); $('#increase_recharge').text(data.increase_recharge+'('+data.recharge+'%)'); } }); 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, 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 table = $("#table"); // 初始化表格 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: 'increase_recharge', title: __('已付费(付费占比)'),operate:false,formatter: Controller.api.formatter.recharge}, {field: 'increase_m', title: __('男性')}, {field: 'increase_f', title: __('女性')}, ] ] }); // 为表格绑定事件 Table.api.bindevent(table); }, 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+'('+(row.follow*1.00).toFixed(2)+'%)'; }, recharge: function (value, row, index) { return value+'('+(row.recharge*1.00).toFixed(2)+'%)'; }, createtime:function(value,row,index){ return value.substring(0,4)+'-'+ value.substring(4,6)+'-'+value.substring(6,8); }, } } }; return Controller; });