vipcustomurl.js 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. showCols:function(table){
  4. var cols = new Array();
  5. cols.push({field: 'id', title: __('推广id'), operate: false});
  6. cols.push({field: 'custom.id', title: __('推广id'), visible: false, operate: "="});
  7. //VIP显示公众号昵称
  8. if (Config.group == 7 || Config.group == 8) {
  9. cols.push({field: 'official_account_name', title: __('公众号名称'), operate: false, formatter: function(value, row){
  10. return row['collect'][0].official_account_name;
  11. }});
  12. cols.push({field: 'custom_url.official_account_name', title: __('公众号名称'), operate: "LIKE %...%", visible: false});
  13. }
  14. cols.push({field: 'title', title: __('客服消息标题'), operate: false});
  15. cols.push({field: 'custom.title', title: '客服消息标题', operate: "LIKE %...%", visible: false});
  16. cols.push({field: 'ltitle', title: '推广标题' , align: 'left',operate:false, formatter:function(value,row,index){
  17. var l = [];
  18. var length = 15
  19. for (var i in row.collect){
  20. var title = row.collect[i].title
  21. if (title.length > length) {
  22. title = title.substr(0, length) + '...';
  23. }
  24. l.push('<span style="width:260px;line-height:1.5;white-space: nowrap;" title="'+row.collect[i].title+'">'+ title +'</span>')
  25. }
  26. return l.join('<br>')
  27. }});
  28. cols.push({field: 'username', title: __('渠道商账号')});
  29. cols.push({
  30. field: 'custom_url.book_name', title: __('书籍名称'), align: 'left', operate: false,
  31. formatter: function (value, row, index) {
  32. var l = [];
  33. for (var i in row.collect){
  34. if (row.collect[i].type == 0) {
  35. l.push('<a href="/admin/referral/book/info?id=' + row.collect[i].book_id + '">' + row.collect[i].book_name + '</a>');
  36. } else {
  37. l.push('-')
  38. }
  39. }
  40. return l.join('<br>')
  41. }
  42. });
  43. cols.push({field: 'custom_url.book_name', title: __('书籍名称'), visible:false, operate:"LIKE %...%"});
  44. cols.push({field: 'idx', title: __('推广位置'),formatter:function(value,row,index){
  45. var l = [];
  46. for (var i in row.collect){
  47. l.push('第' + row.collect[i].idx + '条')
  48. }
  49. return l.join('<br>')
  50. },operate:false});
  51. cols.push({field: 'type_text', width:100, title: __('推广类型'), operate:false, formatter: function(value, row){
  52. var e = {
  53. "0": "书籍",
  54. "1": "活动",
  55. "2": "继续阅读",
  56. "3": "菜单",
  57. "4": "没有url的文案",
  58. "5": "其他",
  59. "6": "自定义链接",
  60. "7": "自动签到",
  61. "8": "常用链接",
  62. "9": "自定义活动"
  63. };
  64. var l = [];
  65. for (var i in row.collect){
  66. if (e[row.collect[i].type]) {
  67. l.push(e[row.collect[i].type])
  68. } else {
  69. l.push('-')
  70. }
  71. }
  72. return l.join('<br>')
  73. }});
  74. cols.push({field: 'send_num', title: __('发送人数'), operate:false});
  75. cols.push({field: 'uv', title: 'UV(总/今日)', operate:false,formatter:function(value,row,index){
  76. var l = [];
  77. for (var i in row.collect){
  78. var v = row.collect[i]
  79. l.push(v.uv + "(" + v.day_uv + ")")
  80. }
  81. return l.join('<br>')
  82. }});
  83. cols.push({field: 'recharge_money', title:'充值金额(总/今日)', operate:false,formatter:function(value,row,index){
  84. var l = [];
  85. for (var i in row.collect){
  86. var v = row.collect[i]
  87. l.push(v.recharge_money + "(" + v.day_recharge_money + ")")
  88. }
  89. return l.join('<br>')
  90. }});
  91. cols.push({field: 'custom.sendtime', title: __('推送时间'), operate:'RANGE', addclass:'datetimerange', visible: false});
  92. cols.push({field: 'sendtime', title: __('推送时间'), operate:false, addclass:'datetimerange', formatter: Table.api.formatter.datetime});
  93. /*cols.push({field: 'operate', title: __('Operate'), table: table,formatter:function (value,row,index) {
  94. return '<a href="/admin/orders/index?mark=' + row.mark + '&push_id=' + row.custom_id + '&push_idx=' + row.idx + '" class="btn btn-dialog btn-xs btn-success btn-editone book_but">订单详情</a>';
  95. }});*/
  96. return cols;
  97. },
  98. index: function () {
  99. // 初始化表格参数配置
  100. Table.api.init({
  101. extend: {
  102. index_url: 'vipcustomurl/index?message_type='+$(".message_type").val()+Config.path,
  103. export_url: '/admin/vipcustomurl/export?message_type='+$(".message_type").val()+Config.path,
  104. table: 'custom_url',
  105. }
  106. });
  107. var table = $("#table");
  108. // 初始化表格
  109. table.bootstrapTable({
  110. url: $.fn.bootstrapTable.defaults.extend.index_url,
  111. pk: 'id',
  112. sortName: 'id',
  113. showToggle: false,
  114. visible: false,
  115. searchFormVisible:true,
  116. search:false,
  117. onLoadSuccess: function (data) {
  118. if (data.msg) {
  119. Toastr.error(data.msg);
  120. }
  121. },
  122. columns: [Controller.showCols(table)]
  123. });
  124. // 为表格绑定事件
  125. Table.api.bindevent(table);
  126. },
  127. add: function () {
  128. Controller.api.bindevent();
  129. },
  130. edit: function () {
  131. Controller.api.bindevent();
  132. },
  133. api: {
  134. bindevent: function () {
  135. Form.api.bindevent($("form[role=form]"));
  136. }
  137. }
  138. };
  139. return Controller;
  140. });