vipagentreferral.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'qrcode'], function ($, undefined, Backend, Table, Form) {
  2. $(document).on("click", '.qrcode', function () {
  3. var qrUrl = $(this).data("qrcode");
  4. $('#tong').html("");
  5. $('#tong').qrcode(qrUrl);
  6. layer.open({
  7. type: 1,
  8. title: false,
  9. area: '258px',
  10. skin: 'layui-layer-nobg', //没有背景色
  11. shadeClose: true,
  12. content: $('#tong')
  13. });
  14. });
  15. $(document).on('click', '.short_link_but', function () {
  16. var $this = $(this);
  17. $this.hide().siblings('.short_link').show();
  18. });
  19. $(document).on('click', '.book_but', function () {
  20. Fast.api.open($(this).attr('href'), '订单详情', {});
  21. return false;
  22. });
  23. var Controller = {
  24. index: function () {
  25. Table.api.init({
  26. extend: {
  27. index_url: 'referral/vipagentreferral/index',
  28. export_url: '/admin/referral/vipagentreferral/export',
  29. table: 'vip_admin_bind',
  30. },
  31. searchFormVisible: true,
  32. showExport: false,
  33. search: false,
  34. });
  35. var table = $("#table");
  36. // 初始化表格
  37. table.bootstrapTable({
  38. url: $.fn.bootstrapTable.defaults.extend.index_url,
  39. pk: 'id',
  40. sortName: 'id',
  41. columns: [
  42. [
  43. {field: 'qds_id', title: '渠道商ID', operate: false},
  44. {field: 'qds_admin.id', title: '渠道商ID', visible: false},
  45. {field: 'qds_username', title: '渠道商账号',operate: false},
  46. {field: 'qds_admin.username', title: '渠道商账号',visible:false},
  47. {field: 'qds_nickname', title: '渠道商昵称',operate: false},
  48. {field: 'qds_admin.nickname', title: '渠道商昵称',visible:false,operate: 'LIKE %...%'},
  49. {field: 'wx_nickname', title: '公众号', operate: false},
  50. {field: 'id', title: '推广ID', operate: false},
  51. {field: 'source_url', title: '推广链接', formatter: Controller.api.source_url, operate: false},
  52. {field: 'entry_page', title: '入口页面', formatter: Controller.api.entry_page, operate: false},
  53. {field: 'username', title: '代理商账号',operate: false},
  54. {field: 'dls_admin.username', title: '代理商账号',visible:false},
  55. {field: 'name', title: '派单渠道', operate: false},
  56. {field: 'book.name', title: '书籍名称', visible: false, operate: 'LIKE %...%'},
  57. {
  58. field: 'uv',
  59. title: '累计阅读人数(今日阅读人数)',
  60. operate: false,
  61. formatter: function (value, row, index) {
  62. return value + "(" + row.dayuv + ")";
  63. }
  64. },
  65. {
  66. field: 'follow',
  67. title: '累计关注人数(今日关注人数)',
  68. operate: false,
  69. formatter: function (value, row, index) {
  70. var percent = daypercent= '0.0%';
  71. if (row.uv > 0) {
  72. percent = (value/row.uv) * 100;
  73. percent = percent.toFixed(1)+'%';
  74. }
  75. if (row.dayuv > 0) {
  76. daypercent = (row.dayut/row.dayuv) * 100;
  77. daypercent = daypercent.toFixed(1)+'%';
  78. }
  79. if (percent == '0.0%') {
  80. return value + "(" + row.dayut + ")";
  81. }
  82. return str = value + "(" + row.dayut + ")" + "<br> 关注率 "+percent+"("+daypercent+")";
  83. }
  84. },
  85. {
  86. field: 'net_follow_num',
  87. title: '累计净关注人数(今日净关注人数)',
  88. operate: false,
  89. formatter: function (value, row, index) {
  90. return value + "(" + row.dayjt + ")";
  91. }
  92. },
  93. {
  94. field: 'money',
  95. title: '总充值金额(今日)',
  96. operate: false,
  97. formatter: function (value, row, index) {
  98. return value + "(" + row.daymt + ")";
  99. }
  100. },
  101. {
  102. field: 'order_nums',
  103. title: '充值笔数/充值比例(今日)',
  104. operate: false,
  105. formatter: function (value, row, index) {
  106. var percent = daypercent= '0.0%';
  107. if (row.follow > 0) {
  108. percent = (value/row.follow) * 100;
  109. percent = percent.toFixed(1)+'%';
  110. }
  111. if (row.dayut > 0) {
  112. daypercent = (row.day_order_nums/row.dayut) * 100;
  113. daypercent = daypercent.toFixed(1)+'%';
  114. }
  115. return ''+ value + ' 笔/'+ percent +' <br>('+ row.day_order_nums+ ' 笔/'+daypercent+')';
  116. }
  117. },
  118. {field: 'cost', title: '推广成本', operate: false},
  119. {
  120. field: 'money',
  121. title: '利润',
  122. operate: false,
  123. formatter: function (value, row, index) {
  124. if (row.cost >0) {
  125. var lirun = value-row.cost;
  126. var percent = '0.00%';
  127. if (value > 0) {
  128. var percent = (value/row.cost) * 100;
  129. percent = percent.toFixed(2)+'%';
  130. }
  131. return lirun.toFixed(2) + "<br>回本率 " + percent;
  132. }
  133. return '-';
  134. }
  135. },
  136. {
  137. field: 'createtime',
  138. title: '创建时间',
  139. operate: false,
  140. addclass: 'datetimerange',
  141. formatter: Table.api.formatter.datetime
  142. },
  143. {
  144. field: 'tongji',
  145. title: __("操作"),
  146. operate: false,
  147. formatter: function (value, row, index) {
  148. return '<a style="float:left;margin-left: 10%" href="/admin/viporders/index?ids=' + row.id + '" class="btn btn-xs btn-success btn-editone book_but">订单详情</a>';
  149. }
  150. },
  151. ]
  152. ]
  153. });
  154. // 为表格绑定事件
  155. Table.api.bindevent(table);
  156. },
  157. api: {
  158. bindevent: function () {
  159. Form.api.bindevent($("form[role=form]"));
  160. },
  161. source_url: function (value, row, index) {
  162. var html = [];
  163. html.push((row.wx_type == 1 ? '<b>认证公众号</b>' : '<b>未认证公众号</b>'));
  164. if (row.short_id > 0) {
  165. value = row.short_url;
  166. } else {
  167. if (Config.url_referral) {
  168. value = Config.url_referral + '/t/' + row.id;
  169. } else {
  170. value = row.url_referral;
  171. }
  172. }
  173. if (row.limited == 1) {
  174. html.push('<div class="link_txt">公众号阅读原文必选</div><div class="url_text">' + value);
  175. html.push('<div class="link_txt" style="padding:0 10px;background-color:red;color:#fff;font-weight:normal;display:inline-block;height:auto;">该链接对新用户已失效,无法进行推广</div></div>');
  176. } else {
  177. if (row.state == "1") {
  178. html.push('<div class="link_txt">公众号阅读原文必选</div><div class="url_text">' + value + '&nbsp;<i class="fa fa-copy copy" data-clipboard-text="' + value + '"></i>&nbsp;&nbsp;<i class="fa fa-qrcode qrcode" data-qrcode="' + value + '"></i>');
  179. html.push('<a href="javascript:;" class="short_link_but">点击显示短链</a><div class="short_link"><strong>腾讯短链:</strong>&nbsp;' + row.short_url_qq + '&nbsp;<i class="fa fa-copy copy" data-clipboard-text="' + row.short_url_qq + '"></i>&nbsp;&nbsp;<i class="fa fa-qrcode qrcode" data-qrcode="' + row.short_url_qq + '"></i>');
  180. html.push('<strong>微博短链:</strong>&nbsp;' + row.short_url_weibo + '&nbsp;<i class="fa fa-copy copy" data-clipboard-text="' + row.short_url_weibo + '"></i>&nbsp;&nbsp;<i class="fa fa-qrcode qrcode" data-qrcode="' + row.short_url_weibo + '"></i></div></div>');
  181. } else {
  182. html.push('<div class="link_txt">当前链接已失效,请禁止使用</div><div class="url_text">' + value + '</div>');
  183. }
  184. }
  185. return html.join('<br>');
  186. },
  187. entry_page: function (value, row, index) {
  188. var html = [];
  189. if (row.type == 1) {
  190. html.push('<span>' + row.book_name + '</span>');
  191. html.push(row.chapter_name);
  192. if (row.guide_chapter_idx) {
  193. html.push('关注章节:' + row.guide_chapter_idx);
  194. } else {
  195. html.push('关注章节:默认');
  196. }
  197. } else if (row.type == 3) {
  198. html.push('落地页推广');
  199. html.push('<span>' + row.book_name + '</span>');
  200. html.push(row.chapter_name);
  201. if (row.guide_chapter_idx) {
  202. html.push('关注章节:' + row.guide_chapter_idx);
  203. } else {
  204. html.push('关注章节:默认');
  205. }
  206. } else {
  207. html.push('书城首页推广');
  208. }
  209. return html.join('<br>');
  210. }
  211. }
  212. };
  213. return Controller;
  214. });