vipchannelreferral.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  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/vipchannelreferral/index',
  28. export_url: '/admin/referral/vipchannelreferral/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: 'referral.admin_id', title: '渠道商ID', visible: false},
  44. {field: 'admin_id', title: '渠道商ID', operate: false},
  45. {field: 'username', title: '渠道商账号'},
  46. {field: 'nickname', title: '渠道商昵称', operate: 'LIKE %...%'},
  47. {field: 'wx_nickname', title: '公众号', operate: false},
  48. {field: 'id', title: '推广ID', operate: false},
  49. {field: 'source_url', title: '推广链接', formatter: Controller.api.source_url, operate: false},
  50. {field: 'entry_page', title: '入口页面', formatter: Controller.api.entry_page, operate: false},
  51. {field: 'referral.name', title: '派单渠道', visible: false,operate: 'LIKE %...%'},
  52. {field: 'name', title: '派单渠道',operate: false },
  53. {field: 'book.name', title: '书籍名称', visible: false, operate: 'LIKE %...%'},
  54. {
  55. field: 'uv',
  56. title: '累计阅读人数(今日阅读人数)',
  57. operate: false,
  58. formatter: function (value, row, index) {
  59. return value + "(" + row.dayuv + ")";
  60. }
  61. },
  62. {
  63. field: 'follow',
  64. title: '累计关注人数(今日关注人数)',
  65. operate: false,
  66. formatter: function (value, row, index) {
  67. var percent = daypercent= '0.0%';
  68. if (row.uv > 0) {
  69. percent = (value/row.uv) * 100;
  70. percent = percent.toFixed(1)+'%';
  71. }
  72. if (row.dayuv > 0) {
  73. daypercent = (row.dayut/row.dayuv) * 100;
  74. daypercent = daypercent.toFixed(1)+'%';
  75. }
  76. if (percent == '0.0%') {
  77. return value + "(" + row.dayut + ")";
  78. }
  79. return str = value + "(" + row.dayut + ")" + "<br> 关注率 "+percent+"("+daypercent+")";
  80. }
  81. },
  82. {
  83. field: 'net_follow_num',
  84. title: '累计净关注人数(今日净关注人数)',
  85. operate: false,
  86. formatter: function (value, row, index) {
  87. return value + "(" + row.dayjt + ")";
  88. }
  89. },
  90. {
  91. field: 'money',
  92. title: '总充值金额(今日)',
  93. operate: false,
  94. formatter: function (value, row, index) {
  95. return value + "(" + row.daymt + ")";
  96. }
  97. },
  98. {
  99. field: 'order_nums',
  100. title: '充值笔数/充值比例(今日)',
  101. operate: false,
  102. formatter: function (value, row, index) {
  103. var percent = daypercent= '0.0%';
  104. if (row.follow > 0) {
  105. percent = (value/row.follow) * 100;
  106. percent = percent.toFixed(1)+'%';
  107. }
  108. if (row.dayut > 0) {
  109. daypercent = (row.day_order_nums/row.dayut) * 100;
  110. daypercent = daypercent.toFixed(1)+'%';
  111. }
  112. return ''+ value + ' 笔/'+ percent +' <br>('+ row.day_order_nums+ ' 笔/'+daypercent+')';
  113. }
  114. },
  115. {field: 'cost', title: '推广成本', operate: false},
  116. {
  117. field: 'money',
  118. title: '利润',
  119. operate: false,
  120. formatter: function (value, row, index) {
  121. if (row.cost >0) {
  122. var lirun = value-row.cost;
  123. var percent = '0.00%';
  124. if (value > 0) {
  125. var percent = (value/row.cost) * 100;
  126. percent = percent.toFixed(2)+'%';
  127. }
  128. return lirun.toFixed(2) + "<br>回本率 " + percent;
  129. }
  130. return '-';
  131. }
  132. },
  133. {
  134. field: 'createtime',
  135. title: '创建时间',
  136. operate: false,
  137. addclass: 'datetimerange',
  138. formatter: Table.api.formatter.datetime
  139. },
  140. {
  141. field: 'tongji',
  142. title: __("操作"),
  143. operate: false,
  144. formatter: function (value, row, index) {
  145. 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>';
  146. }
  147. },
  148. ]
  149. ]
  150. });
  151. // 为表格绑定事件
  152. Table.api.bindevent(table);
  153. },
  154. api: {
  155. bindevent: function () {
  156. Form.api.bindevent($("form[role=form]"));
  157. },
  158. source_url: function (value, row, index) {
  159. var html = [];
  160. html.push((row.wx_type == 1 ? '<b>认证公众号</b>' : '<b>未认证公众号</b>'));
  161. if (row.short_id > 0) {
  162. value = row.short_url;
  163. } else {
  164. if (Config.url_referral) {
  165. value = Config.url_referral + '/t/' + row.id;
  166. } else {
  167. value = row.url_referral;
  168. }
  169. }
  170. if (row.limited == 1) {
  171. html.push('<div class="link_txt">公众号阅读原文必选</div><div class="url_text">' + value);
  172. 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>');
  173. } else {
  174. if (row.state == "1") {
  175. 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>');
  176. 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>');
  177. 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>');
  178. } else {
  179. html.push('<div class="link_txt">当前链接已失效,请禁止使用</div><div class="url_text">' + value + '</div>');
  180. }
  181. }
  182. return html.join('<br>');
  183. },
  184. entry_page: function (value, row, index) {
  185. var html = [];
  186. if (row.type == 1) {
  187. html.push('<span>' + row.book_name + '</span>');
  188. html.push(row.chapter_name);
  189. if (row.guide_chapter_idx) {
  190. html.push('关注章节:' + row.guide_chapter_idx);
  191. } else {
  192. html.push('关注章节:默认');
  193. }
  194. } else if (row.type == 3) {
  195. html.push('落地页推广');
  196. html.push('<span>' + row.book_name + '</span>');
  197. html.push(row.chapter_name);
  198. if (row.guide_chapter_idx) {
  199. html.push('关注章节:' + row.guide_chapter_idx);
  200. } else {
  201. html.push('关注章节:默认');
  202. }
  203. } else {
  204. html.push('书城首页推广');
  205. }
  206. return html.join('<br>');
  207. }
  208. }
  209. };
  210. return Controller;
  211. });