define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'qrcode'], function ($, undefined, Backend, Table, Form, Qrcode) { // 更换图文 $(document).delegate('.changeTeleTxt', 'click', function () { $.post({ url: "referral/referral/edit?ids="+$(this).data('id'), success:function (data) { $('fieldset .row .btn-success').trigger('click'); } }); }); // 分享图片 var shareImgBig11 = ''; $(document).delegate('.sharepic', 'click', function(){ $.post({ url: "/admin/referral.referral/merge_image?id="+$(this).data('id'), success:function (data) { if (data.code) { $("#t_pic").attr('src', data.data.path); shareImgBig11 = data.data.path; $(".copy_dialog").show(); } else { alert('没有可用的底图,' + data.msg); } } }); }); function touchstart(e){ window.parent.document.getElementById('bigImg111').src=shareImgBig11; window.parent.document.getElementById('showImg').click(); } function touchend(e){ // 关闭图片 window.parent.document.getElementById('hidImg').click(); } function touchcancel(e){ // 关闭图片 window.parent.document.getElementById('hidImg').click(); } // 按下事件 $('#t_pic').on('touchstart', touchstart); // 抬起事件 $('#t_pic').on('touchend', touchend); $('#t_pic').on('touchcancel', touchend); function isAndroid() { var u = navigator.userAgent; return (u.indexOf('Android') > -1 || u.indexOf('Linux') > -1); } if(isAndroid()){ var text = "长按图片 ==> 查看图片 ==> 分享图片"; $('.copy_dialog .top_p1').html(text); }else{ var text = "长按图片 ==> 分享图片"; $('.copy_dialog .top_p1').html(text); } $(document).on('click','.copy_dialog_close',function(){ $('.copy_dialog').hide(); }); $(document).on('click','.btn-collect',function(){ var rid = $(this).attr('rid'); $.get('referral/referral/collection/ids/'+rid,function(result){ if(result.code == 1){ var table = $("#table"); Toastr.success(result.msg); table.bootstrapTable('refresh'); }else{ Toastr.error(result.msg); } }); }); // 分享给好友 || 分享到朋友圈 $(document).on('click', '.sharebtn', function () { var id = $(this).data('id'); var share_type = $(this).data('type'); $.post({ url: "/admin/referral.referral/ajaxgetshare?id=" + id + "&type=" + share_type, success:function (data) { var ah = { url: data.shareLink, title: data.shareTitle, description: data.shareDesc, img_url: data.shareIcon, img_title: data.shareTitle, to_app: data.shareType, cus_txt: data.shareDesc }; try { top.browser.app.share(ah); if (typeof(top.browser) != "undefined") { if (typeof(top.browser.app) != "undefined") { top.browser.app.share(ah) } }else if (typeof(top.window) != "undefined") { if (typeof(top.window.qb) != "undefined") { top.window.qb.share(ah) } }else{ alert('请在手机端使用QQ浏览器'); } }catch (e) { //alert(e.message); alert('请在手机端使用QQ浏览器'); } } }); }); $(document).on("click", '.qrcode', function () { var qrUrl = $(this).data("qrcode"); // $('#tong').html(""); // $('#tong').qrcode(qrUrl); // layer.open({ // type: 1, // title: false, // area: '258px', // skin: 'layui-layer-nobg', //没有背景色 // shadeClose: true, // content: $('#tong') // }); Fast.api.open('referral/referral/show_tpl?url='+qrUrl, '图片二维码', {}); }); //book_but $(document).on('click', '.book_but', function () { Fast.api.open($(this).attr('href'), '订单详情', {}); return false; }); $(document).on('click', '.book_history', function () { Fast.api.open($(this).attr('href'), '历史数据', {}); return false; }); $(document).on('click', '.btn-look', function () { layer.open({ type: 2, title: '查看代理商推广链接', maxmin: true, area: ['90%', '90%'], shadeClose: true, //点击遮罩关闭层 content: $('.btn-look').data('action') }); }); $(document).on('click', '.short_link_but', function () { var $this = $(this); $this.hide().siblings('.short_link').show(); }); $(document).on('click','.short_link_butt',function(){ var $this = $(this); var urlqq = $this.data('url-qq'); var urlweibo = $this.data('url-weibo'); layer.open({ type: 1, title: '推广短链', toFixed: false, //不固定 maxmin: true, area: ['auto', 'auto'], content: '
\
\ 腾讯短链\
\ 复制腾讯短链\
\
\ 腾讯短链\
\ 复制新浪短链\
\
' }); }); function UnixToDate(unixTime, isFull, timeZone) { if (typeof (timeZone) == 'number') { unixTime = parseInt(unixTime) + parseInt(timeZone) * 60 * 60; } var time = new Date(unixTime * 1000); var ymdhis = ""; ymdhis += time.getUTCFullYear() + "-"; ymdhis += ((time.getUTCMonth()+1) < 10 ? '0' + (time.getUTCMonth()+1) : (time.getUTCMonth()+1) )+ "-"; ymdhis += (time.getUTCDate() < 10 ? '0' + time.getUTCDate() : time.getUTCDate()); if (isFull === true) { ymdhis += " " + (time.getUTCHours()<10 ? '0' + time.getUTCHours() : time.getUTCHours()) + ":"; ymdhis += (time.getUTCMinutes()<10 ? '0' + time.getUTCMinutes() : time.getUTCMinutes()) + ":"; ymdhis += (time.getUTCSeconds()<10 ? '0' + time.getUTCSeconds() : time.getUTCSeconds()) ; } return ymdhis; } if (Config.rtype == 1) { var Controller = { index: function () { // 初始化表格参数配置 Table.api.init({ extend: { index_url: Config.referralUrl, add_url: 'referral/referral/add?type=2&push='+Config.push, export_url: 'referral/export?push='+Config.push, edit_url: 'referral/referral/edit?push='+Config.push, del_url: 'referral/referral/del', multi_url: 'referral/referral/multi', table: 'referral', }, pageSize: 10, pageList: [10], showToggle: false, showColumns: false, visible: false, commonSearch: true, showExport: true, searchFormVisible: true, search: false }); var table = $("#table"); // 初始化表格 table.bootstrapTable({ url: $.fn.bootstrapTable.defaults.extend.index_url, pk: 'id', sortName: 'id', columns: [ [ //{field: 'id', title: 'ID'}, {field: 'source_url', title: '推广链接', formatter: Controller.api.source_url, operate: false}, {field: 'entry_page', title: '入口页面', formatter: Controller.api.entry_page, operate: false}, {field: 'book_id', title: '书籍ID', visible: false}, {field: 'book.name', title: '书籍名称', visible: false, operate: 'LIKE %...%'}, {field: 'chapter_idx', title: '章节序号', visible: false, operate: false}, {field: 'admin_id', title: __('Admin_id'), visible: false, operate: false}, {field: 'name', title: __('Name'), operate: 'LIKE %...%'}, { field: 'wx_type', title: __('Wx_type'), visible: false, searchList: {"wx_type 1": __('Wx_type 1'), "wx_type 2": __('Wx_type 2')}, operate: false }, {field: 'wx_type_text', title: __('Wx_type'), visible: false, operate: false}, { field: 'type', title: __('Type'), visible: false, searchList: {"type 1": '阅读页推广', "type 2": '首页推广', 'type 3': '落地页推广'}, operate: false }, {field: 'type_text', title: __('Type'), visible: false, operate: false}, { field: 'uv', title: '总阅读人数(今日)', operate: false, formatter: function (value, row, index) { return value + "(" + row.dayuv + ")"; } }, { field: 'follow', title: '总关注人数(今日)', operate: false, formatter: function (value, row, index) { var percent = daypercent= '0.0%'; if (row.uv > 0) { percent = (value/row.uv) * 100; percent = percent.toFixed(1)+'%'; } if (row.dayuv > 0) { daypercent = (row.dayut/row.dayuv) * 100; daypercent = daypercent.toFixed(1)+'%'; } if (percent == '0.0%') { return value + "(" + row.dayut + ")"; } return str = value + "(" + row.dayut + ")" + "
关注率 "+percent+"("+daypercent+")"; } }, { field: 'net_follow_num', title: '总净关注人数(今日净关注人数)', operate: false, formatter: function (value, row, index) { return value + "(" + row.dayjt + ")"; } }, // { // field: 'guide_follow_num', // title: '承接功能关注人数(今日)', // operate: false, // formatter: function (value, row, index) { // return value + "(" + row.daydt + ")"; // } // }, { field: 'money', title: '总充值金额(今日)', operate: false, formatter: function (value, row, index) { return value + "(" + row.daymt + ")"; } }, { field: 'order_nums', title: '充值笔数/充值比例(今日)', operate: false, formatter: function (value, row, index) { var percent = daypercent= '0.0%'; if (row.follow > 0) { percent = (value/row.follow) * 100; percent = percent.toFixed(1)+'%'; } if (row.dayut > 0) { daypercent = (row.day_order_nums/row.dayut) * 100; daypercent = daypercent.toFixed(1)+'%'; } return ''+ value + ' 笔/'+ percent +'
('+ row.day_order_nums+ ' 笔/'+daypercent+')'; } }, {field: 'cost', title: '推广成本', operate: false}, { field: 'money', title: '利润', operate: false, formatter: function (value, row, index) { if (row.cost >0) { var lirun = value-row.cost; var percent = '0.00%'; if (value > 0) { var percent = (value/row.cost) * 100; percent = percent.toFixed(2)+'%'; } return lirun.toFixed(2) + "
回本率 " + percent; } return '-'; } }, { field: 'createtime', title: '创建时间', operate: 'RANGE', addclass: 'datetimerange', formatter: Table.api.formatter.datetime }, { field: 'updatetime', title: '更新时间', visible: false, operate: false, addclass: 'datetimerange', formatter: Table.api.formatter.datetime }, { field: 'tongji', title: __("统计"), operate: false, formatter: function (value, row, index) { return '订单详情'; } }, ] ], exportOptions: { type: 'excel', fileName: '推广链接', ignoreColumn: [8, 9], onMsoNumberFormat: function (cell, row, col) { return (row > 0 && col == 1) ? '\\@' : ''; } } }); // 为表格绑定事件 Table.api.bindevent(table); }, lookagentreferral: function () { // 初始化表格参数配置 Table.api.init({ extend: { look_url: "referral/referral/lookAgentReferral", table: 'referral', }, pageSize: 10, pageList: [10], showColumns: false, showToggle: false, searchFormVisible: true, search: false, }); var table = $("#table"); // 初始化表格 table.bootstrapTable({ url: $.fn.bootstrapTable.defaults.extend.look_url, pk: 'id', sortName: 'id', columns: [ [ //{checkbox: true}, //{field: 'id', title: 'ID'}, {field: 'source_url', title: '推广链接', formatter: Controller.api.source_url, operate: false}, {field: 'entry_page', title: '入口页面', formatter: Controller.api.entry_page, operate: false}, {field: 'book_id', title: '书籍ID', visible: false}, {field: 'book.name', title: '书籍名称', visible: false, operate: 'LIKE %...%'}, {field: 'chapter_idx', title: '章节序号', visible: false, operate: false}, { field: 'admin_id', title: '代理商', formatter: Controller.api.formatter.agent_text, searchList: Controller.api.formatter.agent_select() }, { field: 'wx_type', title: __('Wx_type'), visible: false, searchList: {"wx_type 1": __('Wx_type 1'), "wx_type 2": __('Wx_type 2')}, operate: false }, {field: 'wx_type_text', title: __('Wx_type'), visible: false, operate: false}, { field: 'type', title: __('Type'), visible: false, searchList: {"type 1": '阅读页推广', "type 2": '首页推广', 'type 3': '落地页推广'}, operate: false }, {field: 'type_text', title: __('Type'), visible: false, operate: false}, { field: 'uv', title: '总阅读人数(今日)', operate: false, formatter: function (value, row, index) { return value + "(" + row.dayuv + ")"; } }, { field: 'follow', title: '总关注人数(今日)', operate: false, formatter: function (value, row, index) { var percent = daypercent= '0.0%'; if (row.uv > 0) { percent = (value/row.uv) * 100; percent = percent.toFixed(1)+'%'; } if (row.dayuv > 0) { daypercent = (row.dayut/row.dayuv) * 100; daypercent = daypercent.toFixed(1)+'%'; } if (percent == '0.0%') { return value + "(" + row.dayut + ")"; } return str = value + "(" + row.dayut + ")" + "
关注率 "+percent+"("+daypercent+")"; } }, { field: 'net_follow_num', title: '总净关注人数(今日)', operate: false, formatter: function (value, row, index) { return value + "(" + row.dayjt + ")"; } }, // { // field: 'guide_follow_num', // title: '承接功能关注人数(今日)', // operate: false, // formatter: function (value, row, index) { // return value + "(" + row.daydt + ")"; // } // }, { field: 'money', title: '总充值金额(今日)', operate: false, formatter: function (value, row, index) { return value + "(" + row.daymt + ")"; } }, { field: 'order_nums', title: '充值笔数/充值比例(今日)', operate: false, formatter: function (value, row, index) { var percent = daypercent= '0.0%'; if (row.follow > 0) { percent = (value/row.follow) * 100; percent = percent.toFixed(1)+'%'; } if (row.dayut > 0) { daypercent = (row.day_order_nums/row.dayut) * 100; daypercent = daypercent.toFixed(1)+'%'; } return ''+ value + ' 笔/'+ percent +'
('+ row.day_order_nums+ ' 笔/'+daypercent+')'; } }, {field: 'cost', title: '推广成本', operate: false}, { field: 'money', title: '利润', operate: false, formatter: function (value, row, index) { if (row.cost >0) { var lirun = value-row.cost; var percent = '0.00%'; if (value > 0) { var percent = (value/row.cost) * 100; percent = percent.toFixed(2)+'%'; } return lirun.toFixed(2) + "
回本率 " + percent; } return '-'; } }, { field: 'createtime', title: '创建时间', operate: 'RANGE', addclass: 'datetimerange', formatter: Table.api.formatter.datetime }, { field: 'updatetime', title: '更新时间', visible: false, operate: false, addclass: 'datetimerange', formatter: Table.api.formatter.datetime }, { field: 'operate', title: '操作', table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate }, { field: 'tongji', title: __("统计"), operate: false, formatter: function (value, row, index) { return '订单详情'; } }, ] ], }); // 为表格绑定事件 Table.api.bindevent(table); }, add: function () { Form.api.bindevent($("form[role=form]"), function (data) { Toastr.success('添加成功'); $('.url_txt').eq(0).text(data.jmp_url); $('.url_txt').eq(1).text(data.short_url_weibo); $('.url_txt').eq(2).text(data.short_url_qq); $('.copy').eq(0).attr('data-clipboard-text', data.jmp_url); $('.copy').eq(1).attr('data-clipboard-text', data.short_url_weibo); $('.copy').eq(2).attr('data-clipboard-text', data.short_url_qq); $('#erweima').html(""); $('#erweima').qrcode(data.jmp_url); $('#erweima').html(''); $('#add-form').hide(); $('#add-dialog').show(); return false; }); $(document).on('click', '.btn-close', function () { Fast.api.close(); }) }, edit: function () { Controller.api.bindevent(); }, select: function () { // 初始化表格参数配置 Table.api.init({ extend: { index_url: 'referral/referral/select', }, pageSize: 10, pageList: [10], showColumns: false, showToggle: false, showExport: false, searchFormVisible: false, search: false, }); var table = $("#table"); // 初始化表格 table.bootstrapTable({ url: $.fn.bootstrapTable.defaults.extend.index_url, pk: 'id', sortName: 'state desc,id desc', sortOrder: '', columns: [ [ {checkbox: true}, //{field: 'id', title: __('Id')}, {field: 'source_url', title: '推广链接', formatter: Controller.api.source_url, operate: false}, {field: 'entry_page', title: '入口页面', formatter: Controller.api.entry_page, operate: false}, {field: 'push', title: '内推外派', formatter:function(val,row){if(parseInt(val) == 0){return "外派";}else{return "内推";}},searchList: {"0":"外派", "1": "内推"} }, {field: 'book_id', title: __('Book_id'), visible: false}, {field: 'book.name', title: '书籍名称', visible: false, operate: 'LIKE %...%'}, {field: 'chapter_idx', title: __('Chapter_idx'), visible: false, operate: false}, {field: 'admin_id', title: __('Admin_id'), visible: false, operate: false}, {field: 'name', title: __('Name'), visible: false, operate: 'LIKE %...%'}, { field: 'wx_type', title: __('Wx_type'), visible: false, searchList: {"wx_type 1": __('Wx_type 1'), "wx_type 2": __('Wx_type 2')}, operate: false }, {field: 'wx_type_text', title: __('Wx_type'), visible: false, operate: false}, { field: 'type', title: __('Type'), visible: false, searchList: {"type 1": '阅读页推广', "type 2": '首页推广', 'type 3': '落地页推广'} }, {field: 'type_text', title: __('Type'), visible: false, operate: false}, { field: 'createtime', title: __('Createtime'), operate: 'RANGE', addclass: 'datetimerange', formatter: Table.api.formatter.datetime }, { field: 'updatetime', title: __('Updatetime'), visible: false, operate: false, addclass: 'datetimerange', formatter: Table.api.formatter.datetime }, { field: 'operate', title: __('Operate'), events: { 'click .btn-chooseone': function (e, value, row, index) { Fast.api.close([row]); }, }, formatter: function () { return ' ' + __('Choose') + ''; } } ] ] }); // 为表格绑定事件 Table.api.bindevent(table); //获取选中数据 $(document).on('click', "#btn-chooseone", function () { Fast.api.close(table.bootstrapTable('getSelections')); }); }, api: { formatter: { agent_text: function (value, row, index) { var name = ''; $.each(Config.adminExtend, function (key, val) { if (row.admin_id == val.admin_id) { name = val.card_holder; return; } }); return name; }, agent_select: function () { var data = {}; $.each(Config.adminExtend, function (key, val) { data[val.admin_id] = val.card_holder; }); return data; }, }, bindevent: function () { Form.api.bindevent($("form[role=form]")); }, source_url: function (value, row, index) { var html = []; html.push((row.wx_type == 1 ? '认证公众号' : '未认证公众号')); if (row.short_id > 0) { value = row.short_url; } else { if (Config.url_referral) { value = Config.url_referral + '/t/' + row.id; } else { value = row.url_referral; } } if (row.limited == 1) { html.push('
' + value); html.push('
'); } else { if (row.state == "1") { html.push('
' + value + '   '); html.push('点击显示短链
'); } else { html.push('
' + value + '
'); } } return html.join('
'); }, entry_page: function (value, row, index) { var html = []; if (row.type == 1) { html.push('' + row.book.name + ''); html.push(row.chapter_name); if (row.guide_chapter_idx) { html.push('关注章节:' + row.guide_chapter_idx); } else { html.push('关注章节:默认'); } } else if (row.type == 3) { html.push('落地页推广'); html.push('' + row.book.name + ''); html.push(row.chapter_name); if (row.guide_chapter_idx) { html.push('关注章节:' + row.guide_chapter_idx); } else { html.push('关注章节:默认'); } } else { html.push('书城首页推广'); } return html.join('
'); } } }; } else { var Controller = { index: function () { // 初始化表格参数配置 Table.api.init({ extend: { index_url: Config.referralUrl, add_url: 'referral/referral/add?type=2&push='+Config.push, export_url: 'referral/export?push='+Config.push, edit_url: 'referral/referral/edit?push='+Config.push, del_url: 'referral/referral/del', multi_url: 'referral/referral/multi', disable_url: 'referral/referral/disable', collection_url: 'referral/referral/collection', table: 'referral', }, pageSize: 10, pageList: [10], showColumns: false, showToggle: false, searchFormVisible: true, search: false, }); var table = $("#table"); if(Config.authGroupId == 4 && Config.authDistribute == '0' && Config.open_wechat_share == 1){ //只有代理商才有权限看 table.bootstrapTable({ url: $.fn.bootstrapTable.defaults.extend.index_url, pk: 'id', sortName: 'id', columns: [ [ //{checkbox: true}, //{field: 'id', title: 'ID'}, {field: 'id', title: '推广ID'}, {field: 'source_url', title: '推广链接',formatter:Controller.api.source_url2, operate:false}, {field: 'entry_page', title: '入口页面',formatter:Controller.api.entry_page, operate:false}, {field: 'book_id', title: '书籍ID', visible:false}, {field: 'book.name', title: '书籍名称', visible:false,operate: 'LIKE %...%'}, {field: 'chapter_idx', title: '章节序号', visible:false, operate:false}, {field: 'admin_id', title: __('Admin_id'), visible:false, operate:false}, {field: 'name', title: __('Name'),operate: 'LIKE %...%'}, {field: 'wx_type', title: __('Wx_type'), visible:false, searchList: {"wx_type 1":__('Wx_type 1'),"wx_type 2":__('Wx_type 2')}, operate:false}, {field: 'wx_type_text', title: __('Wx_type'), visible:false, operate:false}, {field: 'type', title: __('Type'), visible:false, searchList: {"type 1":'阅读页推广',"type 2":'首页推广'}, operate:false}, {field: 'type_text', title: __('Type'), visible:false, operate:false}, {field: 'uv', title: '总阅读人数(今日)', operate:false,formatter:function(value,row,index){ return '' + value+' ('+row.dayuv+')'; }}, {field: 'follow', title: '总关注人数(今日)', operate:false,formatter:function(value,row,index){ var percent = daypercent= '0.0%'; if (row.uv > 0) { percent = (value/row.uv) * 100; percent = percent.toFixed(1)+'%'; } if (row.dayuv > 0) { daypercent = (row.dayut/row.dayuv) * 100; daypercent = daypercent.toFixed(1)+'%'; } if (percent == '0.0%') { return value + "(" + row.dayut + ")"; } return str = value + "(" + row.dayut + ")" + "
关注率 "+percent+"("+daypercent+")"; /*return '' + value+' ('+row.dayut+')
'+percent+'% ('+daypercent+'%)';*/ }}, { field: 'net_follow_num', title: '总净关注人数(今日)', operate: false, formatter: function (value, row, index) { return '' + value+' ('+row.dayjt+')'; //return value + "(" + row.dayjt + ")"; } }, // { // field: 'guide_follow_num', // title: '承接功能关注人数(今日)', // operate: false, // formatter: function (value, row, index) { // return '' + value+' ('+row.daydt+')'; // //return value + "(" + row.daydt + ")"; // } // }, {field: 'money', title: '总充值金额(今日)', operate:false,formatter:function(value,row,index){ return '' + value+' ('+row.daymt+')'; }}, { field: 'order_nums', title: '充值笔数/充值比例(今日)', operate: false, formatter: function (value, row, index) { var percent = daypercent= '0.0%'; if (row.follow > 0) { percent = (value/row.follow) * 100; percent = percent.toFixed(1)+'%'; } if (row.dayut > 0) { daypercent = (row.day_order_nums/row.dayut) * 100; daypercent = daypercent.toFixed(1)+'%'; } return ''+ value + ' 笔/'+ percent +'
('+ row.day_order_nums+ ' 笔/'+daypercent+')'; } }, {field: 'cost', title: '推广成本', operate: false}, { field: 'money', title: '利润', operate: false, formatter: function (value, row, index) { if (row.cost >0) { var lirun = value-row.cost; var percent = '0.00%'; if (value > 0) { var percent = (value/row.cost) * 100; percent = percent.toFixed(2)+'%'; } return lirun.toFixed(2) + "
回本率 " + percent; } return '-'; } }, { field: 'createtime', title: '创建时间', operate: 'RANGE', addclass: 'datetimerange', formatter: Table.api.formatter.datetime }, { field: 'updatetime', title: '更新时间', visible: false, operate: false, addclass: 'datetimerange', formatter: Table.api.formatter.datetime }, { field: 'state', title: '状态', searchList: {'0': '禁用', '1': '正常'}, formatter: function (value, row, index) { return value == 1 ? "正常" : "禁用"; } }, {field: 'share_title',title:'分享标题', operate:false}, {field: 'share_image', title: '分享图片', operate: false, formatter: function (value, row, index) { if(value){ return ''; }else{ return '-'; } } }, {field: 'createtime', title: '分享操作', operate: false, formatter: function (value, row, index) { if(row.share_title){ var share_title = row.share_title + "\n"; }else{ var share_title = "她是怎么想的,有人能告诉我吗\n"; } if(row.short_url_qq){ share_title += row.short_url_qq; }else{ share_title += row.source_url; } var html = ''; html += '
'; html += '
'; html += '
复制链接
'; html += '
'; html += '
'; html += '
分享群聊
'; html += '
'; html += '
'; html += '
朋友圈
'; html += '
'; html += '
'; html += '
分享图片
'; html += '
'; html += '
'; html += '
更换图文
'; return html; } }, /*{ field: 'operate', title: '操作', table: table, events: Table.api.events.operate, buttons:[ { name: 'detail', text: '订单详情', title: '订单详情', classname: 'btn btn-xs btn-success btn-dialog btn_kuai', url: '/admin/orders/index?a=n' } ], formatter: Table.api.formatter.operate },*/ { field: 'operate', title: '操作', table: table, events: Table.api.events.operate, buttons: [ { name: 'disable', text: '', title: '禁用', icon: 'fa fa-ban', classname: 'btn btn-xs btn-danger btn-ajax btn-disable', confirm: "一旦禁用,用户将无法访问链接,确定禁用?", url: $.fn.bootstrapTable.defaults.extend.disable_url, success: function (data) { table.bootstrapTable('refresh'); } } ], formatter: Table.api.formatter.operate }, { field: 'tongji', title: __("统计"), operate: false, formatter: function (value, row, index) { return '订单详情'; } } ] ], }); }else{ // 初始化表格 table.bootstrapTable({ url: $.fn.bootstrapTable.defaults.extend.index_url, pk: 'id', sortName: 'state desc,id desc', sortOrder: '', columns: [ [ //{checkbox: true}, //{field: 'id', title: 'ID'}, {field: 'id', title: '推广ID'}, {field: 'source_url', title: '推广链接', formatter: Controller.api.source_url, operate: false}, {field: 'entry_page', title: '入口页面', formatter: Controller.api.entry_page, operate: false}, { field: 'book_id', title: '书籍', visible: false, addclass: 'selectpage', data: 'data-source="/admin/book/book/index" data-field="name"', formatter: Table.api.formatter.search }, {field: 'chapter_idx', title: '章节序号', visible: false, operate: false}, {field: 'admin_id', title: __('Admin_id'), visible: false, operate: false}, {field: 'name', title: __('Name'), operate: 'LIKE %...%'}, { field: 'wx_type', title: __('Wx_type'), visible: false, searchList: {"wx_type 1": __('Wx_type 1'), "wx_type 2": __('Wx_type 2')}, operate: false }, {field: 'wx_type_text', title: __('Wx_type'), visible: false, operate: false}, { field: 'type', title: __('Type'), visible: false, searchList: {"1": '阅读页推广', "type 2": '首页推广', 'type 3': '落地页推广'}, operate: false }, {field: 'type_text', title: __('Type'), visible: false, operate: false}, { field: 'uv', title: '总阅读人数(今日)', operate: false, formatter: function (value, row, index) { return value + "(" + row.dayuv + ")"; } }, { field: 'follow', title: '总关注人数(今日)', operate: false, formatter: function (value, row, index) { var percent = daypercent= '0.0%'; if (row.uv > 0) { percent = (value/row.uv) * 100; percent = percent.toFixed(1)+'%'; } if (row.dayuv > 0) { daypercent = (row.dayut/row.dayuv) * 100; daypercent = daypercent.toFixed(1)+'%'; } if (percent == '0.0%') { return value + "(" + row.dayut + ")"; } return str = value + "(" + row.dayut + ")" + "
关注率 "+percent+"("+daypercent+")"; } }, { field: 'net_follow_num', title: '总净关注人数(今日)', operate: false, formatter: function (value, row, index) { return value + "(" + row.dayjt + ")"; } }, // { // field: 'guide_follow_num', // title: '承接功能关注人数(今日)', // operate: false, // formatter: function (value, row, index) { // return value + "(" + row.daydt + ")"; // } // }, { field: 'money', title: '总充值金额(今日)', operate: false, formatter: function (value, row, index) { return value + "(" + row.daymt + ")"; } }, { field: 'order_nums', title: '充值笔数/充值比例(今日)', operate: false, formatter: function (value, row, index) { var percent = daypercent= '0.0%'; if (row.follow > 0) { percent = (value/row.follow) * 100; percent = percent.toFixed(1)+'%'; } if (row.dayut > 0) { daypercent = (row.day_order_nums/row.dayut) * 100; daypercent = daypercent.toFixed(1)+'%'; } return ''+ value + ' 笔/'+ percent +'
('+ row.day_order_nums+ ' 笔/'+daypercent+')'; } }, {field: 'cost', title: '推广成本', operate: false}, { field: 'money', title: '利润', operate: false, formatter: function (value, row, index) { if (row.cost >0) { var lirun = value-row.cost; var percent = '0.00%'; if (value > 0) { var percent = (value/row.cost) * 100; percent = percent.toFixed(2)+'%'; } return lirun.toFixed(2) + "
回本率 " + percent; } return '-'; } }, { field: 'createtime', title: '创建时间', operate: 'RANGE', addclass: 'datetimerange', formatter: Table.api.formatter.datetime }, { field: 'updatetime', title: '更新时间', visible: false, operate: false, addclass: 'datetimerange', formatter: Table.api.formatter.datetime }, { field: 'state', title: '状态', searchList: {'0': '禁用', '1': '正常'}, formatter: function (value, row, index) { return value == 1 ? "正常" : "禁用"; } }, { field: 'operate', title: '操作', table: table, events: Table.api.events.operate, buttons: [ { name: 'disable', text: '', title: '禁用', icon: 'fa fa-ban', classname: 'btn btn-xs btn-danger btn-ajax btn-disable', confirm: "一旦禁用,用户将无法访问链接,确定禁用?", url: $.fn.bootstrapTable.defaults.extend.disable_url, success: function (data) { table.bootstrapTable('refresh'); } }, { name: 'disable', text: '', title: '解禁', icon: 'fa fa-share', classname: 'btn btn-xs btn-success btn-ajax btn-goable', confirm: "一旦解除禁用,用户将正常访问链接,确定恢复?", url: $.fn.bootstrapTable.defaults.extend.disable_url, success: function (data) { table.bootstrapTable('refresh'); } }, ], formatter: Table.api.formatter.operate }, { field: 'tongji', title: __("统计"), operate: false, formatter: function (value, row, index) { var btn = '订单详情 '; btn += '历史数据'; return btn; } }, ] ], onPostBody: function () { //隐藏禁用操作按钮 $.each(table.bootstrapTable("getData"), function (index, row) { if (row.state == "0") { //隐藏禁用按钮 显示解禁按钮 $("a.btn-disable").eq(index).hide(); } else { //隐藏解禁按钮 显示禁用按钮 $("a.btn-goable").eq(index).hide(); } }); } }); } // 为表格绑定事件 Table.api.bindevent(table); }, admin_index: function () { // 初始化表格参数配置 Table.api.init({ extend: { admin_index: 'referral/referral/admin_index?push='+Config.push, table: 'referral', }, pageSize: 10, pageList: [10], showColumns: false, showToggle: false, searchFormVisible: true, search: false, }); var table = $("#table"); // 初始化表格 table.bootstrapTable({ url: $.fn.bootstrapTable.defaults.extend.admin_index, pk: 'id', sortName: 'referral.money', sortOrder: 'desc', columns: [ [ //{checkbox: true}, //{field: 'id', title: 'ID'}, {field: 'id', title: '推广ID'}, {field: 'source_url', title: '推广链接', formatter: Controller.api.source_admin_url, operate: false}, {field: 'entry_page', title: '入口页面', formatter: Controller.api.entry_page, operate: false}, {field: 'book_id', title: '书籍ID', visible: false}, {field: 'book.name', title: '书籍名称', visible: false, operate: 'LIKE %...%'}, {field: 'chapter_idx', title: '章节序号', visible: false, operate: false}, {field: 'admin_id', title: __('Admin_id'), visible: false, operate: false}, {field: 'name', title: __('Name'), operate: 'LIKE %...%'}, { field: 'wx_type', title: __('Wx_type'), visible: false, searchList: {"wx_type 1": __('Wx_type 1'), "wx_type 2": __('Wx_type 2')}, operate: false }, {field: 'wx_type_text', title: __('Wx_type'), visible: false, operate: false}, { field: 'type', title: __('Type'), visible: false, searchList: {"1": '阅读页推广', "type 2": '首页推广', 'type 3': '落地页推广'}, operate: false }, {field: 'type_text', title: __('Type'), visible: false, operate: false}, { field: 'uv', title: '总阅读人数(今日)', operate: false, formatter: function (value, row, index) { return value + "(" + row.dayuv + ")"; } }, { field: 'follow', title: '总关注人数(今日)', operate: false, formatter: function (value, row, index) { var percent = daypercent= '0.0%'; if (row.uv > 0) { percent = (value/row.uv) * 100; percent = percent.toFixed(1)+'%'; } if (row.dayuv > 0) { daypercent = (row.dayut/row.dayuv) * 100; daypercent = daypercent.toFixed(1)+'%'; } if (percent == '0.0%') { return value + "(" + row.dayut + ")"; } return str = value + "(" + row.dayut + ")" + "
关注率 "+percent+"("+daypercent+")"; } }, { field: 'net_follow_num', title: '总净关注人数(今日)', operate: false, formatter: function (value, row, index) { return value + "(" + row.dayjt + ")"; } }, { field: 'money', title: '总充值金额(今日)', operate: false, formatter: function (value, row, index) { return value + "(" + row.daymt + ")"; } }, { field: 'order_nums', title: '充值笔数/充值比例(今日)', operate: false, formatter: function (value, row, index) { var percent = daypercent= '0.0%'; if (row.follow > 0) { percent = (value/row.follow) * 100; percent = percent.toFixed(1)+'%'; } if (row.dayut > 0) { daypercent = (row.day_order_nums/row.dayut) * 100; daypercent = daypercent.toFixed(1)+'%'; } return ''+ value + ' 笔/'+ percent +'
('+ row.day_order_nums+ ' 笔/'+daypercent+')'; } }, {field: 'cost', title: '推广成本', operate: false}, { field: 'money', title: '利润', operate: false, formatter: function (value, row, index) { if (row.cost >0) { var lirun = value-row.cost; var percent = '0.00%'; if (value > 0) { var percent = (value/row.cost) * 100; percent = percent.toFixed(2)+'%'; } return lirun.toFixed(2) + "
回本率 " + percent; } return '-'; } }, { field: 'createtime', title: '创建时间', operate: 'RANGE', addclass: 'datetimerange', formatter: Table.api.formatter.datetime }, { field: 'updatetime', title: '更新时间', visible: false, operate: false, addclass: 'datetimerange', formatter: Table.api.formatter.datetime }, { field: 'state', title: '状态', searchList: {'0': '禁用', '1': '正常'}, formatter: function (value, row, index) { return value == 1 ? "正常" : "禁用"; } }, { field: 'tongji', title: __("统计"), operate: false, formatter: function (value, row, index) { var btn = ' 订单详情'; btn +=' 历史数据'; return btn; } }, ] ] }); // 为表格绑定事件 Table.api.bindevent(table); }, lookagentreferral: function () { // 初始化表格参数配置 Table.api.init({ extend: { look_url: Config.look_url, table: 'referral', }, pageSize: 10, pageList: [10], showColumns: false, showToggle: false, searchFormVisible: true, search: false, }); var table = $("#table"); // 初始化表格 table.bootstrapTable({ url: $.fn.bootstrapTable.defaults.extend.look_url, pk: 'id', sortName: 'id', columns: [ [ //{checkbox: true}, //{field: 'id', title: 'ID'}, {field: 'source_url', title: '推广链接', formatter: Controller.api.source_url, operate: false}, {field: 'entry_page', title: '入口页面', formatter: Controller.api.entry_page, operate: false}, {field: 'book_id', title: '书籍ID', visible: false}, {field: 'book.name', title: '书籍名称', visible: false, operate: 'LIKE %...%'}, {field: 'chapter_idx', title: '章节序号', visible: false, operate: false}, { field: 'admin_id', title: '代理商', formatter: Controller.api.formatter.agent_text, searchList: Controller.api.formatter.agent_select() }, { field: 'wx_type', title: __('Wx_type'), visible: false, searchList: {"wx_type 1": __('Wx_type 1'), "wx_type 2": __('Wx_type 2')}, operate: false }, {field: 'wx_type_text', title: __('Wx_type'), visible: false, operate: false}, { field: 'type', title: __('Type'), visible: false, searchList: {"type 1": '阅读页推广', "type 2": '首页推广', 'type 3': '落地页推广'}, operate: false }, {field: 'type_text', title: __('Type'), visible: false, operate: false}, { field: 'uv', title: '总阅读人数(今日)', operate: false, formatter: function (value, row, index) { return value + "(" + row.dayuv + ")"; } }, { field: 'follow', title: '总关注人数(今日)', operate: false, formatter: function (value, row, index) { var percent = daypercent= '0.0%'; if (row.uv > 0) { percent = (value/row.uv) * 100; percent = percent.toFixed(1)+'%'; } if (row.dayuv > 0) { daypercent = (row.dayut/row.dayuv) * 100; daypercent = daypercent.toFixed(1)+'%'; } if (percent == '0.0%') { return value + "(" + row.dayut + ")"; } return str = value + "(" + row.dayut + ")" + "
关注率 "+percent+"("+daypercent+")"; } }, { field: 'net_follow_num', title: '总净关注人数(今日)', operate: false, formatter: function (value, row, index) { return value + "(" + row.dayjt + ")"; } }, // { // field: 'guide_follow_num', // title: '承接功能关注人数(今日)', // operate: false, // formatter: function (value, row, index) { // return value + "(" + row.daydt + ")"; // } // }, { field: 'money', title: '总充值金额(今日)', operate: false, formatter: function (value, row, index) { return value + "(" + row.daymt + ")"; } }, { field: 'order_nums', title: '充值笔数/充值比例(今日)', operate: false, formatter: function (value, row, index) { var percent = daypercent= '0.0%'; if (row.follow > 0) { percent = (value/row.follow) * 100; percent = percent.toFixed(1)+'%'; } if (row.dayut > 0) { daypercent = (row.day_order_nums/row.dayut) * 100; daypercent = daypercent.toFixed(1)+'%'; } return ''+ value + ' 笔/'+ percent +'
('+ row.day_order_nums+ ' 笔/'+daypercent+')'; } }, {field: 'cost', title: '推广成本', operate: false}, { field: 'money', title: '利润', operate: false, formatter: function (value, row, index) { if (row.cost >0) { var lirun = value-row.cost; var percent = '0.00%'; if (value > 0) { var percent = (value/row.cost) * 100; percent = percent.toFixed(2)+'%'; } return lirun.toFixed(2) + "
回本率 " + percent; } return '-'; } }, { field: 'createtime', title: '创建时间', operate: 'RANGE', addclass: 'datetimerange', formatter: Table.api.formatter.datetime }, { field: 'updatetime', title: '更新时间', visible: false, operate: false, addclass: 'datetimerange', formatter: Table.api.formatter.datetime }, { field: 'operate', title: '操作', table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate }, { field: 'tongji', title: __("统计"), operate: false, formatter: function (value, row, index) { var btn = '订单详情 '; btn += '查看历史'; return btn; } }, ] ], }); // 为表格绑定事件 Table.api.bindevent(table); }, daydata: function () { // 初始化表格参数配置 Table.api.init({ extend: { index_url: "referral/referral/daydata?ids="+Config.referral_id, table: 'referral_day_collect', }, pageSize: 10, pageList: [10], showColumns: false, showToggle: false, searchFormVisible: false, search: false, commonSearch: false, pageSize: 100, pageList: [100, 200, 'All'] }); var table = $("#table"); // 初始化表格 table.bootstrapTable({ url: $.fn.bootstrapTable.defaults.extend.index_url, pk: 'id', sortName: 'id', columns: [ [ //{checkbox: true}, //{field: 'id', title: 'ID'}, {field: 'referral_id', title: '推广链接ID'}, {field: 'createdate', title: '日期'}, {field: 'uv', title: '阅读人数'}, {field: 'follow', title: '关注人数'}, {field: 'recharge_money', title: '充值金额'}, {field: 'orders_num', title: '充值笔数'}, { field: 'all_recharge_money', title: '回本率', operate: false, formatter: function (value, row, index) { if (row.cost > 0) { var percent = (value/row.cost) * 100; percent = percent.toFixed(2)+'%'; return percent; } return '-'; } } ] ], }); // 为表格绑定事件 Table.api.bindevent(table); }, add: function () { Form.api.bindevent($("form[role=form]"), function (data) { Toastr.success('添加成功'); if (data.closeTip == 1) { //延时关闭 setTimeout(function () { Fast.api.close(); }, 2000); return false; } $('.url_txt').eq(0).text(data.jmp_url); $('.url_txt').eq(1).text(data.short_url_weibo); $('.url_txt').eq(2).text(data.short_url_qq); $('.copy').eq(0).attr('data-clipboard-text', data.jmp_url); $('.copy').eq(1).attr('data-clipboard-text', data.short_url_weibo); $('.copy').eq(2).attr('data-clipboard-text', data.short_url_qq); $('#erweima').html(""); $('#erweima').qrcode(data.jmp_url); $('#erweima').html(''); $('#add-form').hide(); $('#add-dialog').show(); return false; }); $(document).on('click', '.btn-close', function () { Fast.api.close(); }); $(document).on("click", '#fachoose-guide_title', function () { Fast.api.open("/admin/manage/title/select", "落地页标题", { callback: function (data) { console.info(data); if (data.sex == "1" || data.sex == "2") { $("#c-guide_title").val(data.title); } else { Toastr.error("请选择男频或女频标题"); } } }); return false; }); }, edit: function () { Controller.api.bindevent(); }, select: function () { // 初始化表格参数配置 Table.api.init({ extend: { index_url: 'referral/referral/select', }, pageSize: 10, pageList: [10], showColumns: false, showToggle: false, showExport: false, searchFormVisible: false, search: false, }); var table = $("#table"); // 初始化表格 table.bootstrapTable({ url: $.fn.bootstrapTable.defaults.extend.index_url, pk: 'id', sortName: 'state desc,id desc', sortOrder: '', columns: [ [ {checkbox: true}, // {field: 'id', title: __('Id')}, {field: 'source_url', title: '推广链接', formatter: Controller.api.source_url, operate: false}, {field: 'entry_page', title: '入口页面', formatter: Controller.api.entry_page, operate: false}, {field: 'push', title: '内推外派', formatter:function(val,row){if(parseInt(val) == 0){return "外派";}else{return "内推";}},searchList: {"0":"外派", "1": "内推"} }, {field: 'book_id', title: __('Book_id'), visible: false}, {field: 'book.name', title: '书籍名称', visible: false, operate: 'LIKE %...%'}, {field: 'chapter_idx', title: __('Chapter_idx'), visible: false, operate: false}, {field: 'admin_id', title: __('Admin_id'), visible: false, operate: false}, {field: 'name', title: __('Name'), operate: 'LIKE %...%'}, { field: 'wx_type', title: __('Wx_type'), visible: false, searchList: {"wx_type 1": __('Wx_type 1'), "wx_type 2": __('Wx_type 2')}, operate: false }, {field: 'wx_type_text', title: __('Wx_type'), visible: false, operate: false}, { field: 'type', title: __('Type'), visible: false, searchList: {"type 1": '阅读页推广', "type 2": '首页推广', 'type 3': '落地页推广'}, operate: false }, {field: 'type_text', title: __('Type'), visible: false, operate: false}, { field: 'createtime', title: __('Createtime'), operate: 'RANGE', addclass: 'datetimerange', formatter: Table.api.formatter.datetime }, { field: 'updatetime', title: __('Updatetime'), visible: false, operate: false, addclass: 'datetimerange', formatter: Table.api.formatter.datetime }, { field: 'operate', title: __('Operate'), events: { 'click .btn-chooseone': function (e, value, row, index) { Fast.api.close([row]); }, }, formatter: function () { return ' ' + __('Choose') + ''; } } ] ] }); // 为表格绑定事件 Table.api.bindevent(table); //获取选中数据 $(document).on('click', "#btn-chooseone", function () { Fast.api.close(table.bootstrapTable('getSelections')); }); }, api: { formatter: { agent_text: function (value, row, index) { var name = ''; $.each(Config.adminExtend, function (key, val) { if (row.admin_id == val.admin_id) { name = val.nickname; return; } }); return name; }, agent_select: function () { var data = {}; $.each(Config.adminExtend, function (key, val) { data[val.admin_id] = val.nickname; }); return data; }, }, bindevent: function () { Form.api.bindevent($("form[role=form]")); }, source_url2: function (value, row, index) { var format_time = function(ns){ return new Date(parseInt(ns) * 1000).toLocaleString().replace(/年|月/g, "-").replace(/日/g, " "); }; var html = []; if(Config.open_wechat_share == 1){ value = row.skin_url; } else{ if(Config.url_referral){ value = Config.url_referral + '/t/' + row.id; }else{ value = row.url_referral; } } var push_name = row.push == 1 ? '内推' : '外派'; html.push('
'+row.name+'('+push_name+')
'); html.push('
' + value + ' 
复制链接  获取二维码获取短链'); html.push('
创建时间:'+UnixToDate(row.createtime,true,8) + '
'); html.push('
'); return html.join('
'); }, source_admin_url: function (value, row, index) { var html = []; if(parseInt(row.is_collect) == 0){ html.push((row.wx_type == 1 ? '认证公众号' : '未认证公众号')); }else{ html.push((row.wx_type == 1 ? '认证公众号' : '未认证公众号')); } if (row.short_id > 0) { value = row.short_url; } else { if (Config.url_referral) { value = Config.url_referral + '/t/' + row.id; } else { value = row.url_referral; } } if (row.limited == 1) { html.push('
' + value); html.push('
'); } else { if (row.state == "1") { html.push('
' + value + '   '); html.push('点击显示短链
'); } else { html.push('
' + value + '
'); } } return html.join('
'); }, source_url: function (value, row, index) { var html = []; if(parseInt(row.is_collect) == 0){ html.push((row.wx_type == 1 ? '认证公众号' : '未认证公众号')); }else{ html.push((row.wx_type == 1 ? '认证公众号' : '未认证公众号')); } if (row.short_id > 0) { value = row.short_url; } else { if (Config.url_referral) { value = Config.url_referral + '/t/' + row.id; } else { value = row.url_referral; } } if (row.limited == 1) { html.push('
' + value); html.push('
'); } else { if (row.state == "1") { html.push('
' + value + '   '); html.push('点击显示短链
'); } else { html.push('
' + value + '
'); } } return html.join('
'); }, entry_page: function (value, row, index) { var html = []; if (row.type == 1) { if (row.book.id == undefined) { html.push(row.book.name); }else{ html.push('' + row.book.name + ''); } html.push(row.chapter_name); if (row.guide_chapter_idx) { html.push('关注章节:' + row.guide_chapter_idx); } else { html.push('关注章节:默认'); } } else if (row.type == 3) { html.push('落地页推广'); if (row.book.id == undefined) { html.push(row.book.name); }else{ html.push('' + row.book.name + ''); } html.push(row.chapter_name); if (row.guide_chapter_idx) { html.push('关注章节:' + row.guide_chapter_idx); } else { html.push('关注章节:默认'); } } else { html.push('书城首页推广'); } return html.join('
'); } } }; } return Controller; });