referral.js 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'qrcode'], function ($, undefined, Backend, Table, Form, Qrcode) {
  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. //book_but
  16. $(document).on('click','.book_but',function () {
  17. Fast.api.open($(this).attr('href'), '订单详情', {});
  18. return false;
  19. });
  20. $(document).on('click','.btn-look',function(){
  21. layer.open({
  22. type: 2,
  23. title: '查看代理商推广链接',
  24. maxmin: true,
  25. area: ['90%', '90%'],
  26. shadeClose: true, //点击遮罩关闭层
  27. content: 'referral/lookAgentReferral'
  28. });
  29. });
  30. $(document).on('click','.short_link_but',function(){
  31. var $this = $(this);
  32. $this.hide().siblings('.short_link').show();
  33. })
  34. if(Config.rtype == 1){
  35. var Controller = {
  36. index: function () {
  37. // 初始化表格参数配置
  38. Table.api.init({
  39. extend: {
  40. index_url: Config.referralUrl,
  41. add_url: 'referral/referral/add?type=2',
  42. export_url: 'referral/export',
  43. edit_url: 'referral/referral/edit',
  44. del_url: 'referral/referral/del',
  45. multi_url: 'referral/referral/multi',
  46. table: 'referral',
  47. },
  48. showToggle: false,
  49. showColumns: false,
  50. visible: false,
  51. commonSearch: true,
  52. showExport: true,
  53. searchFormVisible: true,
  54. search:false
  55. });
  56. var table = $("#table");
  57. // 初始化表格
  58. table.bootstrapTable({
  59. url: $.fn.bootstrapTable.defaults.extend.index_url,
  60. pk: 'id',
  61. sortName: 'id',
  62. columns: [
  63. [
  64. //{field: 'id', title: 'ID'},
  65. {field: 'source_url', title: '推广链接',formatter:Controller.api.source_url, operate:false},
  66. {field: 'entry_page', title: '入口页面',formatter:Controller.api.entry_page, operate:false},
  67. {field: 'book_id', title: '书籍ID', visible:false},
  68. {field: 'book.name', title: '书籍名称', visible:false,operate: 'LIKE %...%'},
  69. {field: 'chapter_idx', title: '章节序号', visible:false, operate:false},
  70. {field: 'admin_id', title: __('Admin_id'), visible:false, operate:false},
  71. {field: 'name', title: __('Name'),operate: 'LIKE %...%'},
  72. {field: 'wx_type', title: __('Wx_type'), visible:false, searchList: {"wx_type 1":__('Wx_type 1'),"wx_type 2":__('Wx_type 2')}, operate:false},
  73. {field: 'wx_type_text', title: __('Wx_type'), visible:false, operate:false},
  74. {field: 'type', title: __('Type'), visible:false, searchList: {"type 1":'阅读页推广',"type 2":'首页推广'}, operate:false},
  75. {field: 'type_text', title: __('Type'), visible:false, operate:false},
  76. {field: 'uv', title: '累计阅读人数(今日阅读人数)', operate:false,formatter:function(value,row,index){
  77. return value+"("+row.dayuv+")";
  78. }},
  79. {field: 'follow', title: '累计关注人数(今日关注人数)', operate:false,formatter:function(value,row,index){
  80. return value+"("+row.dayut+")";
  81. }},
  82. {field: 'cost',title:'推广成本', operate:false},
  83. {field: 'money', title: '累计充值金额(今日充值金额)', operate:false,formatter:function(value,row,index){
  84. return value+"("+row.daymt+")";
  85. }},
  86. {field: 'createtime', title: '创建时间', operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
  87. {field: 'updatetime', title: '更新时间', visible:false, operate:false, addclass:'datetimerange', formatter: Table.api.formatter.datetime},
  88. {
  89. field: 'tongji', title: __("统计"), operate: false, formatter: function (value, row, index) {
  90. return '<a style="float:left;margin-left: 10%" href="/admin/orders/index?ids=' + row.id + '" class="btn btn-xs btn-success btn-editone book_but">订单详情</a>';
  91. }
  92. },
  93. ]
  94. ],
  95. exportOptions: {
  96. type: 'excel',
  97. fileName:'推广链接',
  98. ignoreColumn: [8,9],
  99. onMsoNumberFormat: function(cell, row, col) {
  100. return (row > 0 && col == 1) ? '\\@' : '';
  101. }}
  102. });
  103. // 为表格绑定事件
  104. Table.api.bindevent(table);
  105. },
  106. lookagentreferral:function(){
  107. // 初始化表格参数配置
  108. Table.api.init({
  109. extend: {
  110. look_url: "referral/referral/lookAgentReferral",
  111. table: 'referral',
  112. },
  113. showColumns:false,
  114. showToggle:false,
  115. searchFormVisible: true,
  116. search:false,
  117. });
  118. var table = $("#table");
  119. // 初始化表格
  120. table.bootstrapTable({
  121. url: $.fn.bootstrapTable.defaults.extend.look_url,
  122. pk: 'id',
  123. sortName: 'id',
  124. columns: [
  125. [
  126. //{checkbox: true},
  127. //{field: 'id', title: 'ID'},
  128. {field: 'source_url', title: '推广链接',formatter:Controller.api.source_url, operate:false},
  129. {field: 'entry_page', title: '入口页面',formatter:Controller.api.entry_page, operate:false},
  130. {field: 'book_id', title: '书籍ID', visible:false},
  131. {field: 'book.name', title: '书籍名称', visible:false,operate: 'LIKE %...%'},
  132. {field: 'chapter_idx', title: '章节序号', visible:false, operate:false},
  133. {field: 'admin_id', title: '代理商',formatter: Controller.api.formatter.agent_text,searchList: Controller.api.formatter.agent_select()},
  134. {field: 'wx_type', title: __('Wx_type'), visible:false, searchList: {"wx_type 1":__('Wx_type 1'),"wx_type 2":__('Wx_type 2')}, operate:false},
  135. {field: 'wx_type_text', title: __('Wx_type'), visible:false, operate:false},
  136. {field: 'type', title: __('Type'), visible:false, searchList: {"type 1":'阅读页推广',"type 2":'首页推广'}, operate:false},
  137. {field: 'type_text', title: __('Type'), visible:false, operate:false},
  138. {field: 'uv', title: '阅读人数', operate:false},
  139. {field: 'follow', title: '关注人数', operate:false},
  140. {field: 'cost',title:'推广成本', operate:false},
  141. {field: 'money', title: '充值金额', operate:false},
  142. {field: 'createtime', title: '创建时间', operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
  143. {field: 'updatetime', title: '更新时间', visible:false, operate:false, addclass:'datetimerange', formatter: Table.api.formatter.datetime},
  144. {field: 'operate', title: '操作', table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate},
  145. {
  146. field: 'tongji', title: __("统计"), operate: false, formatter: function (value, row, index) {
  147. return '<a style="float:left;margin-left: 10%" href="/admin/orders/index?ids=' + row.id + '" class="btn btn-xs btn-success btn-editone book_but">订单详情</a>';
  148. }
  149. },
  150. ]
  151. ],
  152. });
  153. // 为表格绑定事件
  154. Table.api.bindevent(table);
  155. },
  156. add: function () {
  157. Form.api.bindevent($("form[role=form]"), function (data) {
  158. Toastr.success('添加成功');
  159. $('.url_txt').eq(0).text(data.jmp_url);
  160. $('.url_txt').eq(1).text(data.short_url_weibo);
  161. $('.url_txt').eq(2).text(data.short_url_qq);
  162. $('.copy').eq(0).attr('data-clipboard-text',data.jmp_url);
  163. $('.copy').eq(1).attr('data-clipboard-text',data.short_url_weibo);
  164. $('.copy').eq(2).attr('data-clipboard-text',data.short_url_qq);
  165. $('#erweima').html("");
  166. $('#erweima').qrcode(data.jmp_url);
  167. $('#erweima').html('<img style="display: block;margin: 0;padding: 0;border: 0;height: 160px;width: 160px;" src="' + $('#erweima canvas')[0].toDataURL("image/png") + '" />');
  168. $('#add-form').hide();
  169. $('#add-dialog').show();
  170. return false;
  171. });
  172. $(document).on('click','.btn-close',function () {
  173. Fast.api.close();
  174. })
  175. },
  176. edit: function () {
  177. Controller.api.bindevent();
  178. },
  179. select: function () {
  180. // 初始化表格参数配置
  181. Table.api.init({
  182. extend: {
  183. index_url: 'referral/referral/index',
  184. },
  185. showColumns:false,
  186. showToggle:false,
  187. showExport:false,
  188. searchFormVisible: false,
  189. search:false,
  190. });
  191. var table = $("#table");
  192. // 初始化表格
  193. table.bootstrapTable({
  194. url: $.fn.bootstrapTable.defaults.extend.index_url,
  195. pk: 'id',
  196. sortName: 'id',
  197. columns: [
  198. [
  199. {checkbox: true},
  200. //{field: 'id', title: __('Id')},
  201. {field: 'source_url', title: '推广链接',formatter:Controller.api.source_url, operate:false},
  202. {field: 'entry_page', title: '入口页面',formatter:Controller.api.entry_page, operate:false},
  203. {field: 'book_id', title: __('Book_id'), visible:false},
  204. {field: 'book.name', title: '书籍名称', visible:false,operate: 'LIKE %...%'},
  205. {field: 'chapter_idx', title: __('Chapter_idx'), visible:false, operate:false},
  206. {field: 'admin_id', title: __('Admin_id'), visible:false, operate:false},
  207. {field: 'name', title: __('Name'), visible:false,operate: 'LIKE %...%'},
  208. {field: 'wx_type', title: __('Wx_type'), visible:false, searchList: {"wx_type 1":__('Wx_type 1'),"wx_type 2":__('Wx_type 2')}, operate:false},
  209. {field: 'wx_type_text', title: __('Wx_type'), visible:false, operate:false},
  210. {field: 'type', title: __('Type'), visible:false, searchList: {"type 1":'阅读页推广',"type 2":'首页推广'}},
  211. {field: 'type_text', title: __('Type'), visible:false, operate:false},
  212. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
  213. {field: 'updatetime', title: __('Updatetime'), visible:false, operate:false, addclass:'datetimerange', formatter: Table.api.formatter.datetime},
  214. {field: 'operate', title: __('Operate'), events: {
  215. 'click .btn-chooseone': function (e, value, row, index) {
  216. Fast.api.close([row]);
  217. },
  218. }, formatter: function () {
  219. return '<a href="javascript:;" class="btn btn-danger btn-chooseone btn-xs"><i class="fa fa-check"></i> ' + __('Choose') + '</a>';
  220. }}
  221. ]
  222. ]
  223. });
  224. // 为表格绑定事件
  225. Table.api.bindevent(table);
  226. //获取选中数据
  227. $(document).on('click', "#btn-chooseone", function () {
  228. Fast.api.close(table.bootstrapTable('getSelections'));
  229. });
  230. },
  231. api: {
  232. formatter:{
  233. agent_text:function(value, row, index){
  234. var name = '';
  235. $.each( Config.adminExtend, function( key, val ) {
  236. if(row.admin_id == val.admin_id){
  237. name = val.card_holder;
  238. return ;
  239. }
  240. } );
  241. return name;
  242. },
  243. agent_select:function(){
  244. var data = {};
  245. $.each( Config.adminExtend, function( key, val ) {
  246. data[val.admin_id] = val.card_holder;
  247. } );
  248. return data;
  249. },
  250. },
  251. bindevent: function () {
  252. Form.api.bindevent($("form[role=form]"));
  253. },
  254. source_url: function (value, row, index) {
  255. var html = [];
  256. html.push((row.wx_type == 1 ? '<b>认证公众号</b>' : '<b>未认证公众号</b>'));
  257. if(Config.url_referral){
  258. value = Config.url_referral + '/t/' + row.id;
  259. }
  260. 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>');
  261. 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>');
  262. 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>');
  263. return html.join('<br>');
  264. },
  265. entry_page: function (value, row, index) {
  266. var html = [];
  267. if(row.type == 1){
  268. html.push('<a href="/admin/referral/book/info?id='+row.book_id+'">'+row.book.name+'</a>');
  269. html.push(row.chapter_name);
  270. if (row.guide_chapter_idx) {
  271. html.push('关注章节:' + row.guide_chapter_idx);
  272. } else {
  273. html.push('关注章节:默认');
  274. }
  275. }else{
  276. html.push('书城首页推广');
  277. }
  278. return html.join('<br>');
  279. }
  280. }
  281. };
  282. }else{
  283. var Controller = {
  284. index: function () {
  285. // 初始化表格参数配置
  286. Table.api.init({
  287. extend: {
  288. index_url: Config.referralUrl,
  289. add_url: 'referral/referral/add?type=2',
  290. export_url: 'referral/export',
  291. edit_url: 'referral/referral/edit',
  292. del_url: 'referral/referral/del',
  293. multi_url: 'referral/referral/multi',
  294. table: 'referral',
  295. },
  296. showColumns:false,
  297. showToggle:false,
  298. searchFormVisible: true,
  299. search:false,
  300. });
  301. var table = $("#table");
  302. // 初始化表格
  303. table.bootstrapTable({
  304. url: $.fn.bootstrapTable.defaults.extend.index_url,
  305. pk: 'id',
  306. sortName: 'id',
  307. columns: [
  308. [
  309. //{checkbox: true},
  310. //{field: 'id', title: 'ID'},
  311. {field: 'source_url', title: '推广链接',formatter:Controller.api.source_url, operate:false},
  312. {field: 'entry_page', title: '入口页面',formatter:Controller.api.entry_page, operate:false},
  313. {field: 'book_id', title: '书籍ID', visible:false},
  314. {field: 'book.name', title: '书籍名称', visible:false,operate: 'LIKE %...%'},
  315. {field: 'chapter_idx', title: '章节序号', visible:false, operate:false},
  316. {field: 'admin_id', title: __('Admin_id'), visible:false, operate:false},
  317. {field: 'name', title: __('Name'),operate: 'LIKE %...%'},
  318. {field: 'wx_type', title: __('Wx_type'), visible:false, searchList: {"wx_type 1":__('Wx_type 1'),"wx_type 2":__('Wx_type 2')}, operate:false},
  319. {field: 'wx_type_text', title: __('Wx_type'), visible:false, operate:false},
  320. {field: 'type', title: __('Type'), visible:false, searchList: {"type 1":'阅读页推广',"type 2":'首页推广'}, operate:false},
  321. {field: 'type_text', title: __('Type'), visible:false, operate:false},
  322. {field: 'uv', title: '累计阅读人数(今日阅读人数)', operate:false,formatter:function(value,row,index){
  323. return value+"("+row.dayuv+")";
  324. }},
  325. {field: 'follow', title: '累计关注人数(今日关注人数)', operate:false,formatter:function(value,row,index){
  326. return value+"("+row.dayut+")";
  327. }},
  328. {field: 'cost',title:'推广成本', operate:false},
  329. {field: 'money', title: '累计充值金额(今日充值金额)', operate:false,formatter:function(value,row,index){
  330. return value+"("+row.daymt+")";
  331. }},
  332. {field: 'createtime', title: '创建时间', operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
  333. {field: 'updatetime', title: '更新时间', visible:false, operate:false, addclass:'datetimerange', formatter: Table.api.formatter.datetime},
  334. {field: 'operate', title: '操作', table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate},
  335. {
  336. field: 'tongji', title: __("统计"), operate: false, formatter: function (value, row, index) {
  337. return '<a style="float:left;margin-left: 10%" href="/admin/orders/index?ids=' + row.id + '" class="btn btn-xs btn-success btn-editone book_but">订单详情</a>';
  338. }
  339. },
  340. ]
  341. ],
  342. });
  343. // 为表格绑定事件
  344. Table.api.bindevent(table);
  345. },
  346. lookagentreferral:function(){
  347. // 初始化表格参数配置
  348. Table.api.init({
  349. extend: {
  350. look_url: "referral/referral/lookAgentReferral",
  351. table: 'referral',
  352. },
  353. showColumns:false,
  354. showToggle:false,
  355. searchFormVisible: true,
  356. search:false,
  357. });
  358. var table = $("#table");
  359. // 初始化表格
  360. table.bootstrapTable({
  361. url: $.fn.bootstrapTable.defaults.extend.look_url,
  362. pk: 'id',
  363. sortName: 'id',
  364. columns: [
  365. [
  366. //{checkbox: true},
  367. //{field: 'id', title: 'ID'},
  368. {field: 'source_url', title: '推广链接',formatter:Controller.api.source_url, operate:false},
  369. {field: 'entry_page', title: '入口页面',formatter:Controller.api.entry_page, operate:false},
  370. {field: 'book_id', title: '书籍ID', visible:false},
  371. {field: 'book.name', title: '书籍名称', visible:false,operate: 'LIKE %...%'},
  372. {field: 'chapter_idx', title: '章节序号', visible:false, operate:false},
  373. {field: 'admin_id', title: '代理商',formatter: Controller.api.formatter.agent_text,searchList: Controller.api.formatter.agent_select()},
  374. {field: 'wx_type', title: __('Wx_type'), visible:false, searchList: {"wx_type 1":__('Wx_type 1'),"wx_type 2":__('Wx_type 2')}, operate:false},
  375. {field: 'wx_type_text', title: __('Wx_type'), visible:false, operate:false},
  376. {field: 'type', title: __('Type'), visible:false, searchList: {"type 1":'阅读页推广',"type 2":'首页推广'}, operate:false},
  377. {field: 'type_text', title: __('Type'), visible:false, operate:false},
  378. {field: 'uv', title: '阅读人数', operate:false},
  379. {field: 'follow', title: '关注人数', operate:false},
  380. {field: 'cost',title:'推广成本', operate:false},
  381. {field: 'money', title: '充值金额', operate:false},
  382. {field: 'createtime', title: '创建时间', operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
  383. {field: 'updatetime', title: '更新时间', visible:false, operate:false, addclass:'datetimerange', formatter: Table.api.formatter.datetime},
  384. {field: 'operate', title: '操作', table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate},
  385. {
  386. field: 'tongji', title: __("统计"), operate: false, formatter: function (value, row, index) {
  387. return '<a style="float:left;margin-left: 10%" href="/admin/orders/index?ids=' + row.id + '" class="btn btn-xs btn-success btn-editone book_but">订单详情</a>';
  388. }
  389. },
  390. ]
  391. ],
  392. });
  393. // 为表格绑定事件
  394. Table.api.bindevent(table);
  395. },
  396. add: function () {
  397. Form.api.bindevent($("form[role=form]"), function (data) {
  398. Toastr.success('添加成功');
  399. $('.url_txt').eq(0).text(data.jmp_url);
  400. $('.url_txt').eq(1).text(data.short_url_weibo);
  401. $('.url_txt').eq(2).text(data.short_url_qq);
  402. $('.copy').eq(0).attr('data-clipboard-text',data.jmp_url);
  403. $('.copy').eq(1).attr('data-clipboard-text',data.short_url_weibo);
  404. $('.copy').eq(2).attr('data-clipboard-text',data.short_url_qq);
  405. $('#erweima').html("");
  406. $('#erweima').qrcode(data.jmp_url);
  407. $('#erweima').html('<img style="display: block;margin: 0;padding: 0;border: 0;height: 160px;width: 160px;" src="' + $('#erweima canvas')[0].toDataURL("image/png") + '" />');
  408. $('#add-form').hide();
  409. $('#add-dialog').show();
  410. return false;
  411. });
  412. $(document).on('click','.btn-close',function () {
  413. Fast.api.close();
  414. })
  415. },
  416. edit: function () {
  417. Controller.api.bindevent();
  418. },
  419. select: function () {
  420. // 初始化表格参数配置
  421. Table.api.init({
  422. extend: {
  423. index_url: 'referral/referral/index',
  424. },
  425. showColumns:false,
  426. showToggle:false,
  427. showExport:false,
  428. searchFormVisible: false,
  429. search:false,
  430. });
  431. var table = $("#table");
  432. // 初始化表格
  433. table.bootstrapTable({
  434. url: $.fn.bootstrapTable.defaults.extend.index_url,
  435. pk: 'id',
  436. sortName: 'id',
  437. columns: [
  438. [
  439. {checkbox: true},
  440. // {field: 'id', title: __('Id')},
  441. {field: 'source_url', title: '推广链接',formatter:Controller.api.source_url, operate:false},
  442. {field: 'entry_page', title: '入口页面',formatter:Controller.api.entry_page, operate:false},
  443. {field: 'book_id', title: __('Book_id'), visible:false},
  444. {field: 'book.name', title: '书籍名称', visible:false,operate: 'LIKE %...%'},
  445. {field: 'chapter_idx', title: __('Chapter_idx'), visible:false, operate:false},
  446. {field: 'admin_id', title: __('Admin_id'), visible:false, operate:false},
  447. {field: 'name', title: __('Name'),operate: 'LIKE %...%'},
  448. {field: 'wx_type', title: __('Wx_type'), visible:false, searchList: {"wx_type 1":__('Wx_type 1'),"wx_type 2":__('Wx_type 2')}, operate:false},
  449. {field: 'wx_type_text', title: __('Wx_type'), visible:false, operate:false},
  450. {field: 'type', title: __('Type'), visible:false, searchList: {"type 1":'阅读页推广',"type 2":'首页推广'}, operate:false},
  451. {field: 'type_text', title: __('Type'), visible:false, operate:false},
  452. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
  453. {field: 'updatetime', title: __('Updatetime'), visible:false, operate:false, addclass:'datetimerange', formatter: Table.api.formatter.datetime},
  454. {field: 'operate', title: __('Operate'), events: {
  455. 'click .btn-chooseone': function (e, value, row, index) {
  456. Fast.api.close([row]);
  457. },
  458. }, formatter: function () {
  459. return '<a href="javascript:;" class="btn btn-danger btn-chooseone btn-xs"><i class="fa fa-check"></i> ' + __('Choose') + '</a>';
  460. }}
  461. ]
  462. ]
  463. });
  464. // 为表格绑定事件
  465. Table.api.bindevent(table);
  466. //获取选中数据
  467. $(document).on('click', "#btn-chooseone", function () {
  468. Fast.api.close(table.bootstrapTable('getSelections'));
  469. });
  470. },
  471. api: {
  472. formatter:{
  473. agent_text:function(value, row, index){
  474. var name = '';
  475. $.each( Config.adminExtend, function( key, val ) {
  476. if(row.admin_id == val.admin_id){
  477. name = val.nickname;
  478. return ;
  479. }
  480. } );
  481. return name;
  482. },
  483. agent_select:function(){
  484. var data = {};
  485. $.each( Config.adminExtend, function( key, val ) {
  486. data[val.admin_id] = val.nickname;
  487. } );
  488. return data;
  489. },
  490. },
  491. bindevent: function () {
  492. Form.api.bindevent($("form[role=form]"));
  493. },
  494. source_url: function (value, row, index) {
  495. var html = [];
  496. html.push((row.wx_type == 1 ? '<b>认证公众号</b>' : '<b>未认证公众号</b>'));
  497. if(Config.url_referral){
  498. value = Config.url_referral + '/t/' + row.id;
  499. }else{
  500. value = row.url_referral;
  501. }
  502. 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>');
  503. 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>');
  504. 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>');
  505. return html.join('<br>');
  506. },
  507. entry_page: function (value, row, index) {
  508. var html = [];
  509. if(row.type == 1){
  510. html.push('<a href="/admin/referral/book/info?id='+row.book_id+'">'+row.book.name+'</a>');
  511. html.push(row.chapter_name);
  512. if (row.guide_chapter_idx) {
  513. html.push('关注章节:' + row.guide_chapter_idx);
  514. } else {
  515. html.push('关注章节:默认');
  516. }
  517. }else{
  518. html.push('书城首页推广');
  519. }
  520. return html.join('<br>');
  521. }
  522. }
  523. };
  524. }
  525. return Controller;
  526. });