collect.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var wait=60;
  3. $(function(){
  4. time();
  5. });
  6. //$('#ajaxkandian').click(function(){
  7. // $.post('/index/book/ajaxFee',{userId:1,bookId:30,chapter_id:50,chapter_name:"下啊是事实"},function(data){
  8. // console.log(data);
  9. // })
  10. //});
  11. function time() {
  12. if (wait == 0) {
  13. //执行ajax拉新数据
  14. $.post('/admin/user/collect/ajaxtoday',{ids:Config.ids},function(data){
  15. //console.log(data);
  16. if (data){
  17. $('#increase_m').text(data.increase_m);
  18. $('#increase_f').text(data.increase_f);
  19. $('#increase').text(data.increase);
  20. $('#increase_fllow').text(data.increase_fllow+'('+data.follow+'%)');
  21. $('#increase_recharge').text(data.increase_recharge+'('+data.recharge+'%)');
  22. }
  23. });
  24. wait = 60;
  25. time();
  26. } else {
  27. $('.flush').text(wait+'秒后刷新');
  28. wait--;
  29. setTimeout(function() {
  30. time()
  31. }, 1000)
  32. }
  33. }
  34. var Controller = {
  35. index: function () {
  36. // 初始化表格参数配置
  37. Table.api.init({
  38. extend: {
  39. index_url: 'user/collect/index?ids='+Config.ids,
  40. add_url: 'user/collect/add',
  41. edit_url: 'user/collect/edit',
  42. del_url: 'user/collect/del',
  43. multi_url: 'user/collect/multi',
  44. table: 'user_collect',
  45. },
  46. showToggle: false,
  47. showColumns: false,
  48. showExport: false,
  49. commonSearch: false,
  50. operate: false,
  51. search:false,
  52. onLoadSuccess: function (data) {
  53. $("[data-toggle='tooltip']").tooltip({trigger: 'focus hover',html : true});
  54. }
  55. });
  56. var table = $("#table");
  57. // 初始化表格
  58. table.bootstrapTable({
  59. url: $.fn.bootstrapTable.defaults.extend.index_url,
  60. pk: 'id',
  61. sortName: 'createdate',
  62. columns: [
  63. [
  64. {field: 'createdate', title: __('日期'),formatter: Controller.api.formatter.createtime},
  65. {field: 'increase', title: __('新增用户')},
  66. {field: 'increase_fllow', title: __('已关注(关注占比)'),operate:false,formatter: Controller.api.formatter.follow},
  67. {field: 'increase_recharge', title: __('已付费(付费占比)'),operate:false,formatter: Controller.api.formatter.recharge},
  68. {field: 'increase_m', title: __('男性')},
  69. {field: 'increase_f', title: __('女性')},
  70. ]
  71. ]
  72. });
  73. // 为表格绑定事件
  74. Table.api.bindevent(table);
  75. },
  76. add: function () {
  77. Controller.api.bindevent();
  78. },
  79. edit: function () {
  80. Controller.api.bindevent();
  81. },
  82. api: {
  83. bindevent: function () {
  84. Form.api.bindevent($("form[role=form]"));
  85. },formatter: {
  86. follow: function (value, row, index) {
  87. return value+'('+(row.follow*1.00).toFixed(2)+'%)';
  88. },
  89. recharge: function (value, row, index) {
  90. return value+'('+(row.recharge*1.00).toFixed(2)+'%)';
  91. },
  92. createtime:function(value,row,index){
  93. return value.substring(0,4)+'-'+ value.substring(4,6)+'-'+value.substring(6,8);
  94. },
  95. }
  96. }
  97. };
  98. return Controller;
  99. });