12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934 |
- 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: '<div class="short_chain_box">\
- <div class="short_input_box">\
- <strong>腾讯短链</strong>\
- <div class="short_input"><input type="text" value="' + urlqq + '" /></div>\
- <a href="javascript:;" class="copy" data-clipboard-text="' + urlqq + '">复制腾讯短链</a>\
- </div>\
- <div class="short_input_box">\
- <strong>腾讯短链</strong>\
- <div class="short_input"><input type="text" value="' + urlweibo + '" /></div>\
- <a href="javascript:;" class="copy" data-clipboard-text="' + urlweibo + '">复制新浪短链</a>\
- </div>\
- </div>'
- });
- });
- 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 + ")" + "<br> 关注率 "+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 +' <br>('+ 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) + "<br>回本率 " + 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 '<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>';
- }
- },
- ]
- ],
- 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 + ")" + "<br> 关注率 "+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 +' <br>('+ 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) + "<br>回本率 " + 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 '<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>';
- }
- },
- ]
- ],
- });
- // 为表格绑定事件
- 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('<img style="display: block;margin: 0;padding: 0;border: 0;height: 160px;width: 160px;" src="' + $('#erweima canvas')[0].toDataURL("image/png") + '" />');
- $('#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 '<a href="javascript:;" class="btn btn-danger btn-chooseone btn-xs"><i class="fa fa-check"></i> ' + __('Choose') + '</a>';
- }
- }
- ]
- ]
- });
- // 为表格绑定事件
- 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 ? '<b>认证公众号</b>' : '<b>未认证公众号</b>'));
- 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('<div class="link_txt">公众号阅读原文必选</div><div class="url_text">' + value);
- 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>');
- } else {
- if (row.state == "1") {
- html.push('<div class="link_txt">公众号阅读原文必选</div><div class="url_text">' + value + ' <i class="fa fa-copy copy" data-clipboard-text="' + value + '"></i> <i class="fa fa-qrcode qrcode" data-qrcode="' + value + '"></i>');
- html.push('<a href="javascript:;" class="short_link_but">点击显示短链</a><div class="short_link"><strong>腾讯短链:</strong> ' + row.short_url_qq + ' <i class="fa fa-copy copy" data-clipboard-text="' + row.short_url_qq + '"></i> <i class="fa fa-qrcode qrcode" data-qrcode="' + row.short_url_qq + '"></i>');
- html.push('<strong>微博短链:</strong> ' + row.short_url_weibo + ' <i class="fa fa-copy copy" data-clipboard-text="' + row.short_url_weibo + '"></i> <i class="fa fa-qrcode qrcode" data-qrcode="' + row.short_url_weibo + '"></i></div></div>');
- } else {
- html.push('<div class="link_txt">当前链接已失效,请禁止使用</div><div class="url_text">' + value + '</div>');
- }
- }
- return html.join('<br>');
- },
- entry_page: function (value, row, index) {
- var html = [];
- if (row.type == 1) {
- html.push('<a href="/admin/referral/book/info?id=' + row.book_id + '">' + row.book.name + '</a>');
- 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('<a href="/admin/referral/book/info?id=' + row.book_id + '">' + row.book.name + '</a>');
- 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('<br>');
- }
- }
- };
- } 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 '<span style="font-size:18px;color:#f33;white-space: nowrap;">' + value+' <span style="font-size:18px;color:#00f;">('+row.dayuv+')</span></span>';
- }},
- {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 + ")" + "<br> 关注率 "+percent+"("+daypercent+")";
- /*return '<span style="font-size:18px;color:#f33;white-space: nowrap;">' + value+' <span style="font-size:18px;color:#00f;">('+row.dayut+')</span></span><br><span style="font-size:18px;color:#f33;white-space: nowrap;">'+percent+'% <span style="font-size:18px;color:#00f;">('+daypercent+'%)</span></span>';*/
- }},
- {
- field: 'net_follow_num',
- title: '总净关注人数(今日)',
- operate: false,
- formatter: function (value, row, index) {
- return '<span style="font-size:18px;color:#f33;white-space: nowrap;">' + value+' <span style="font-size:18px;color:#00f;">('+row.dayjt+')</span></span>';
- //return value + "(" + row.dayjt + ")";
- }
- },
- // {
- // field: 'guide_follow_num',
- // title: '承接功能关注人数(今日)',
- // operate: false,
- // formatter: function (value, row, index) {
- // return '<span style="font-size:18px;color:#f33;white-space: nowrap;">' + value+' <span style="font-size:18px;color:#00f;">('+row.daydt+')</span></span>';
- // //return value + "(" + row.daydt + ")";
- // }
- // },
- {field: 'money', title: '总充值金额(今日)', operate:false,formatter:function(value,row,index){
- return '<span style="font-size:18px;color:#f33;white-space: nowrap;">' + value+' <span style="font-size:18px;color:#00f;">('+row.daymt+')</span></span>';
- }},
- {
- 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 +' <br>('+ 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) + "<br>回本率 " + 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 ? "<span style='color: green;'>正常</span>" : "<span style='color: red;'>禁用</span>";
- }
- },
- {field: 'share_title',title:'分享标题', operate:false},
- {field: 'share_image', title: '分享图片', operate: false,
- formatter: function (value, row, index) {
- if(value){
- return '<img style="width:80px; height:auto" src=' + value + '>';
- }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 += '<div class="opshare copy" data-clipboard-text="' + share_title + '"><div>';
- html += '<img style="width: 32px;height: auto; margin: 0 auto; display: block" src="../../assets/img/s_link.png"></div>';
- html += '<div style="text-align: center">复制链接</div></div>';
- html += '<div class="opshare sharebtn" data-id="'+row.id+'" data-type="s_chat">';
- html += '<div><img style="width: 32px;height: auto; margin: 0 auto; display: block" src="../../assets/img/s_chat.png"></div>';
- html += '<div style="text-align: center">分享群聊</div></div>';
- html += '<div class="opshare sharebtn" data-id="'+row.id+'" data-type="s_friends">';
- html += '<div><img style="width: 32px;height: auto; margin: 0 auto; display: block" src="../../assets/img/s_friends.png"></div>';
- html += '<div style="text-align: center">朋友圈</div></div>';
- html += '<div class="opshare sharepic" data-id="' + row.id + '">';
- html += '<div><img style="width: 32px;height: auto; margin: 0 auto; display: block" src="../../assets/img/s_pic.png"></div>';
- html += '<div style="text-align: center">分享图片</div></div>';
- html += '<div class="opshare changeTeleTxt" data-id="'+row.id+'"><div>';
- html += '<img style="width: 32px;height: auto; margin: 0 auto; display: block" src="../../assets/img/s_change.png"></div>';
- html += '<div style="text-align: center">更换图文</div></div>';
- 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 '<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>';
- }
- }
- ]
- ],
- });
- }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 + ")" + "<br> 关注率 "+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 +' <br>('+ 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) + "<br>回本率 " + 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 ? "<span style='color: green;'>正常</span>" : "<span style='color: red;'>禁用</span>";
- }
- },
- {
- 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 = '<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> ';
- btn += '<a style="float:left;margin-left: 10%" href="/admin/referral/referral/daydata?ids=' + row.id + '" class="btn btn-xs btn-success btn-editone book_history">历史数据</a>';
- 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 + ")" + "<br> 关注率 "+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 +' <br>('+ 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) + "<br>回本率 " + 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 ? "<span style='color: green;'>正常</span>" : "<span style='color: red;'>禁用</span>";
- }
- },
- {
- field: 'tongji',
- title: __("统计"),
- operate: false,
- formatter: function (value, row, index) {
- var btn = ' <a href="/admin/orders/index?ids=' + row.id + '" class="btn btn-xs btn-success btn-editone book_but">订单详情</a>';
- btn +=' <a href="/admin/referral/referral/daydata?ids=' + row.id + '" class="btn btn-xs btn-success btn-editone book_history">历史数据</a>';
- 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 + ")" + "<br> 关注率 "+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 +' <br>('+ 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) + "<br>回本率 " + 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 = '<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> ';
- btn += '<a style="float:left;margin-left: 10%" href="/admin/referral/referral/daydata?ids=' + row.id + '" class="btn btn-xs btn-success btn-editone book_history">查看历史</a>';
- 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('<img style="display: block;margin: 0;padding: 0;border: 0;height: 160px;width: 160px;" src="' + $('#erweima canvas')[0].toDataURL("image/png") + '" />');
- $('#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 '<a href="javascript:;" class="btn btn-danger btn-chooseone btn-xs"><i class="fa fa-check"></i> ' + __('Choose') + '</a>';
- }
- }
- ]
- ]
- });
- // 为表格绑定事件
- 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('<div style="margin-top:10px;font-size:18px;color:#000;text-align: left;">'+row.name+'('+push_name+')</div>');
- html.push('<div class="url_text">' + value + ' <br/><a href="javascript:;" style="margin:5px 0;background-color:#169bd5;" class="btn btn-success btn-xs copy" data-clipboard-text="'+value+'">复制链接</a> <a href="javascript:;" style="margin:5px 0;background-color:#169bd5;" class="btn btn-success btn-xs qrcode" data-qrcode="'+value+'">获取二维码</a><a href="javascript:;" style="margin:5px;background-color:#169bd5;" data-url-weibo="' + row.short_url_weibo + '" data-url-qq="' + row.short_url_qq +'" class="btn btn-success btn-xs short_link_butt">获取短链</a>');
- html.push('<div style="margin-bottom:10px;text-align: left;">创建时间:'+UnixToDate(row.createtime,true,8) + '</div>');
- html.push('</div>');
- return html.join('<br>');
- },
- source_admin_url: function (value, row, index) {
- var html = [];
- if(parseInt(row.is_collect) == 0){
- html.push((row.wx_type == 1 ? '<b>认证公众号</b></i>' : '<b>未认证公众号</b></i>'));
- }else{
- html.push((row.wx_type == 1 ? '<b>认证公众号</b><i class="btn-collect fa fa-star" rid="'+row.id+'" style="cursor:pointer;float:right;font-size:20px;color:gold;"></i>' : '<b>未认证公众号</b><i class="btn-collect fa fa-star" rid="'+row.id+'" style="cursor:pointer;float:right;font-size:20px;color:gold;"></i>'));
- }
- 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('<div class="link_txt">公众号阅读原文必选</div><div class="url_text">' + value);
- 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>');
- } else {
- if (row.state == "1") {
- html.push('<div class="link_txt">公众号阅读原文必选</div><div class="url_text">' + value + ' <i class="fa fa-copy copy" data-clipboard-text="' + value + '"></i> <i class="fa fa-qrcode qrcode" data-qrcode="' + value + '"></i>');
- html.push('<a href="javascript:;" class="short_link_but">点击显示短链</a><div class="short_link"><strong>腾讯短链:</strong> ' + row.short_url_qq + ' <i class="fa fa-copy copy" data-clipboard-text="' + row.short_url_qq + '"></i> <i class="fa fa-qrcode qrcode" data-qrcode="' + row.short_url_qq + '"></i>');
- html.push('<strong>微博短链:</strong> ' + row.short_url_weibo + ' <i class="fa fa-copy copy" data-clipboard-text="' + row.short_url_weibo + '"></i> <i class="fa fa-qrcode qrcode" data-qrcode="' + row.short_url_weibo + '"></i></div></div>');
- } else {
- html.push('<div class="link_txt">当前链接已失效,请禁止使用</div><div class="url_text">' + value + '</div>');
- }
- }
- return html.join('<br>');
- },
- source_url: function (value, row, index) {
- var html = [];
- if(parseInt(row.is_collect) == 0){
- html.push((row.wx_type == 1 ? '<b>认证公众号</b><i class="btn-collect fa fa-star-o" rid="'+row.id+'" style="cursor:pointer;float:right;font-size:20px;color:gold;"></i>' : '<b>未认证公众号</b><i class="btn-collect fa fa-star-o" rid="'+row.id+'" style="cursor:pointer;float:right;font-size:20px;color:gold;"></i>'));
- }else{
- html.push((row.wx_type == 1 ? '<b>认证公众号</b><i class="btn-collect fa fa-star" rid="'+row.id+'" style="cursor:pointer;float:right;font-size:20px;color:gold;"></i>' : '<b>未认证公众号</b><i class="btn-collect fa fa-star" rid="'+row.id+'" style="cursor:pointer;float:right;font-size:20px;color:gold;"></i>'));
- }
- 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('<div class="link_txt">公众号阅读原文必选</div><div class="url_text">' + value);
- 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>');
- } else {
- if (row.state == "1") {
- html.push('<div class="link_txt">公众号阅读原文必选</div><div class="url_text">' + value + ' <i class="fa fa-copy copy" data-clipboard-text="' + value + '"></i> <i class="fa fa-qrcode qrcode" data-qrcode="' + value + '"></i>');
- html.push('<a href="javascript:;" class="short_link_but">点击显示短链</a><div class="short_link"><strong>腾讯短链:</strong> ' + row.short_url_qq + ' <i class="fa fa-copy copy" data-clipboard-text="' + row.short_url_qq + '"></i> <i class="fa fa-qrcode qrcode" data-qrcode="' + row.short_url_qq + '"></i>');
- html.push('<strong>微博短链:</strong> ' + row.short_url_weibo + ' <i class="fa fa-copy copy" data-clipboard-text="' + row.short_url_weibo + '"></i> <i class="fa fa-qrcode qrcode" data-qrcode="' + row.short_url_weibo + '"></i></div></div>');
- } else {
- html.push('<div class="link_txt">当前链接已失效,请禁止使用</div><div class="url_text">' + value + '</div>');
- }
- }
- return html.join('<br>');
- },
- 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('<a href="/admin/referral/book/info?id=' + row.book_id + '">' + row.book.name + '</a>');
- }
- 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('<a href="/admin/referral/book/info?id=' + row.book_id + '">' + row.book.name + '</a>');
- }
- 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('<br>');
- }
- }
- };
- }
- return Controller;
- });
|