collect.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var wait=60;
  3. $(function(){
  4. time();
  5. });
  6. $('ul.nav-tabs li').click(function(){
  7. $(this).addClass('active').siblings().removeClass('active')
  8. });
  9. function time() {
  10. if (wait == 0) {
  11. //执行ajax拉新数据
  12. $.post('/admin/collect/ajaxtoday'+ Config.channelstr,{groupId:Config.groupId,authId:Config.authId},function(data){
  13. //console.log(data);
  14. if (data){
  15. if(Config.groupId == 3) { //渠道商
  16. $('#agent_recharge').text('¥'+data.agent_recharge);
  17. $('#agent_benefit').text('¥'+data.agent_recharge_benefit);
  18. $('#today_pv').text('pv:'+ (parseInt(data.pv)+parseInt(data.guide_pv)) );
  19. $('#today_uv').text('uv:'+ (parseInt(data.uv)+parseInt(data.guide_uv)) );
  20. }
  21. if(Config.groupId == 4){ //代理商
  22. $('#today_pv').text('pv:'+ (parseInt(data.pv)+parseInt(data.guide_pv)) );
  23. $('#today_uv').text('uv:'+ (parseInt(data.uv)+parseInt(data.guide_uv)) );
  24. }
  25. $('#recharge_money').text('¥'+data.recharge_money);
  26. $('#recharge_money_benefit').text('¥'+data.recharge_money_benefit);
  27. var yzf = parseInt(data.normal_recharge_orders)>0?data.normal_recharge_orders:0;
  28. var wzf = data.normal_recharge_orders_count-data.normal_recharge_orders;
  29. var html_str = "普通充值<br/>"+
  30. "<span id = 'normal_recharge_money'>¥"+data.normal_recharge_money+"</span><br/><br/>"+
  31. "已支付:"+yzf+"笔<br/>"+
  32. "未支付:"+wzf+"笔<br/>"+
  33. "完成率:"+Number(data.normal_percent).toFixed(0)+"%<br/>";
  34. var vip_yzf = parseInt(data.vip_recharge_orders) >0 ?data.vip_recharge_orders:0;
  35. var vip_wzf = data.vip_recharge_orders_count - data.vip_recharge_orders;
  36. $('#normal_first').html(html_str);
  37. var vip_html_str = "年费VIP会员<br/>"+
  38. "<span>¥"+data.vip_recharge_money+"</span><br/><br/>"+
  39. "已支付:"+vip_yzf+"笔<br/>"+
  40. "未支付:"+vip_wzf+"笔<br/>"+
  41. "完成率:"+Number(data.vip_percent).toFixed(0)+"%<br/>";
  42. $('#vip_first').html(vip_html_str);
  43. }
  44. });
  45. wait = 60;
  46. time();
  47. } else {
  48. $('.flush').text(wait+'秒后刷新');
  49. wait--;
  50. setTimeout(function() {
  51. time()
  52. }, 1000)
  53. }
  54. }
  55. var Controller = {
  56. index: function () {
  57. // 初始化表格参数配置
  58. Table.api.init({
  59. extend: {
  60. index_url: 'collect/index'+Config.channelstr,
  61. table: 'orders_collect'
  62. },
  63. showToggle: false,
  64. showColumns: false,
  65. showExport: false,
  66. commonSearch: false,
  67. operate: false,
  68. search:false,
  69. onLoadSuccess: function (data) {
  70. $("[data-toggle='tooltip']").tooltip({trigger: 'focus hover',html : true });
  71. }
  72. });
  73. var table = $("#table");
  74. table.bootstrapTable({
  75. url: $.fn.bootstrapTable.defaults.extend.index_url,
  76. pk: 'id',
  77. sortName: 'createdate',
  78. columns: [Controller.api.showColumns()]
  79. });
  80. // 为表格绑定事件
  81. Table.api.bindevent(table);
  82. },
  83. api: {
  84. showColumns:function(){
  85. var cols = new Array();
  86. cols.push({field: 'createdate', title: __('日期'),formatter: Controller.api.formatter.createtime});
  87. cols.push({field: 'pv', title: __('PV'),formatter:Controller.api.formatter.format_pv});
  88. cols.push({field: 'uv', title: __('UV'),formatter:Controller.api.formatter.format_uv});
  89. cols.push({field: 'recharge_money', title: __('总充值')});
  90. cols.push({field: 'normal_recharge_money', title: __('普通充值'),formatter: Controller.api.formatter.normal_recharge_money});
  91. cols.push({field: 'normal_recharge_orders_count', title: __('普通充值订单数'),formatter: Controller.api.formatter.normal_recharge_orders_count });
  92. cols.push({field: 'vip_recharge_money', title: __('年度VIP会员'),formatter: Controller.api.formatter.vip_recharge_money});
  93. cols.push({field: 'vip_recharge_orders_count', title: __('年度VIP会员订单数'),formatter: Controller.api.formatter.vip_recharge_orders_count});
  94. if(Config.groupId < 3){
  95. cols.push({field: 'recharge_money_benefit', title: __('渠道商分成收益')});
  96. cols.push({field: 'normal_recharge_orders', title: __('总分成收益'),formatter: Controller.api.formatter.normal_recharge_orders});
  97. }
  98. if(Config.groupId == 3){
  99. cols.push({field: 'self_recharge', title: __('充值'),formatter: Controller.api.formatter.total_benefit});
  100. cols.push({field: 'self_recharge_benefit', title: __('分成收益'),formatter: Controller.api.formatter.total_benefit});
  101. cols.push({field: 'agent_recharge', title: __('代理商充值'),formatter: Controller.api.formatter.total_benefit});
  102. cols.push({field: 'agent_benefit', title: __('代理商分成收益'),formatter: Controller.api.formatter.total_benefit});
  103. cols.push({field: 'total_benefit', title: __('实际收益'),formatter: Controller.api.formatter.total_benefit_channel});
  104. }
  105. if(Config.groupId == 4){
  106. cols.push({field: 'recharge_money_benefit', title: __('总分成收益'),formatter: Controller.api.formatter.total_benefit_channel});
  107. }
  108. return cols;
  109. },
  110. bindevent: function () {
  111. Form.api.bindevent($("form[role=form]"));
  112. },formatter: {
  113. format_pv:function(value,row,index){
  114. return parseInt(row.pv)+parseInt(row.guide_pv);
  115. },
  116. format_uv:function(value,row,index){
  117. return parseInt(row.uv)+parseInt(row.guide_uv);
  118. },
  119. normal_recharge_orders: function (value, row, index) {
  120. return '<span style="color:#e74c3c">¥'+((row.recharge_money-row.recharge_money_benefit)* 1.00).toFixed(2) + '</span>';
  121. },
  122. normal_recharge_money:function (value, row, index) {
  123. var normal_recharge_str = '<p>¥'+row.normal_recharge_money+'</p>';
  124. if(row.normal_recharge_orders>0){
  125. var normal_recharge_str_avg = Number(row.normal_recharge_money/row.normal_recharge_orders) * 1.00;
  126. normal_recharge_str += '<i>成功人次:'+row.normal_recharge_orders+'<br/>人均:¥'+ Number(normal_recharge_str_avg.toFixed(2))+'</i>';
  127. }else{
  128. normal_recharge_str +='<i>成功人次:0<br/>人均:¥0'+'</i>';
  129. }
  130. return normal_recharge_str;
  131. },
  132. normal_recharge_orders_count:function(value,row,index){
  133. var normal_recharge_order_str = '<p>已支付:'+row.normal_recharge_orders+'笔</p>';
  134. var wzf = row.normal_recharge_orders_count-row.normal_recharge_orders;
  135. if(row.normal_recharge_orders > 0){
  136. if (row.kandian_recharge_orders_count >0) {
  137. var normal_recharge_str_order_avg = (row.kandian_recharge_orders*100/row.kandian_recharge_orders_count) * 1.00;
  138. } else {
  139. var normal_recharge_str_order_avg = (row.normal_recharge_orders*100/row.normal_recharge_orders_count) * 1.00;
  140. }
  141. normal_recharge_order_str += '<p>未支付:'+wzf+'笔</p>';
  142. normal_recharge_order_str += '<p>完成率:'+ Math.floor(normal_recharge_str_order_avg)+'%'+'</p>';
  143. }else{
  144. normal_recharge_order_str += '<p>未支付:'+wzf+'笔</p>';
  145. normal_recharge_order_str += '<p>完成率:0%'+'</p>';
  146. }
  147. return normal_recharge_order_str;
  148. },
  149. vip_recharge_money:function (value, row, index) {
  150. var vip_recharge_str = '<p>¥'+row.vip_recharge_money+'</p>';
  151. if(row.vip_recharge_orders > 0){
  152. var vip_recharge_str_avg = Number(row.vip_recharge_money/row.vip_recharge_orders) * 1.00;
  153. vip_recharge_str += '<i>成功人次:'+row.vip_recharge_orders+'<br/>人均:¥'+ Number(vip_recharge_str_avg.toFixed(2))+'</i>';
  154. }else{
  155. vip_recharge_str +='<i>成功人次:0<br/>人均:¥0'+'</i>';
  156. }
  157. return vip_recharge_str;
  158. },
  159. vip_recharge_orders_count:function(value,row,index){
  160. var vip_recharge_order_str = '<p>已支付:'+row.vip_recharge_orders+'笔</p>';
  161. var vipwzf = row.vip_recharge_orders_count-row.vip_recharge_orders;
  162. if(row.vip_recharge_orders > 0){
  163. if(row.vip_recharge_orders_count){
  164. var vip_recharge_str_order_avg = (row.vip_recharge_orders*100/row.vip_recharge_orders_count) * 1.00;
  165. }else{
  166. var vip_recharge_str_order_avg = 0;
  167. }
  168. vip_recharge_order_str += '<p>未支付:'+vipwzf+'笔</p>';
  169. vip_recharge_order_str += '<p>完成率:'+ Math.floor(vip_recharge_str_order_avg)+'%'+'</p>';
  170. }else{
  171. vip_recharge_order_str += '<p>未支付:'+vipwzf+'笔</p>';
  172. vip_recharge_order_str += '<p>完成率:0%'+'</p>';
  173. }
  174. return vip_recharge_order_str;
  175. },
  176. total_benefit:function(value,row,index){
  177. return '¥'+value;
  178. },
  179. total_benefit_channel:function(value,row,index) {
  180. return '<span style="color:#e74c3c">¥' + Number(value).toFixed(2) + '</span>';
  181. },
  182. createtime:function(value,row,index){
  183. return value.substring(0,4)+'-'+ value.substring(4,6)+'-'+value.substring(6,8);
  184. },
  185. }
  186. }
  187. };
  188. return Controller;
  189. });