define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'qrcode'], function ($, undefined, Backend, Table, Form) {
$(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')
});
});
$(document).on('click', '.short_link_but', function () {
var $this = $(this);
$this.hide().siblings('.short_link').show();
});
$(document).on('click', '.book_but', function () {
Fast.api.open($(this).attr('href'), '订单详情', {});
return false;
});
var Controller = {
index: function () {
Table.api.init({
extend: {
index_url: 'referral/vipagentreferral/index',
export_url: '/admin/referral/vipagentreferral/export',
table: 'vip_admin_bind',
},
searchFormVisible: true,
showExport: false,
search: false,
});
var table = $("#table");
// 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'id',
columns: [
[
{field: 'qds_id', title: '渠道商ID', operate: false},
{field: 'qds_admin.id', title: '渠道商ID', visible: false},
{field: 'qds_username', title: '渠道商账号',operate: false},
{field: 'qds_admin.username', title: '渠道商账号',visible:false},
{field: 'qds_nickname', title: '渠道商昵称',operate: false},
{field: 'qds_admin.nickname', title: '渠道商昵称',visible:false,operate: 'LIKE %...%'},
{field: 'wx_nickname', title: '公众号', operate: false},
{field: 'id', title: '推广ID', operate: false},
{field: 'source_url', title: '推广链接', formatter: Controller.api.source_url, operate: false},
{field: 'entry_page', title: '入口页面', formatter: Controller.api.entry_page, operate: false},
{field: 'username', title: '代理商账号',operate: false},
{field: 'dls_admin.username', title: '代理商账号',visible:false},
{field: 'name', title: '派单渠道', operate: false},
{field: 'book.name', title: '书籍名称', visible: false, operate: 'LIKE %...%'},
{
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: false,
addclass: 'datetimerange',
formatter: Table.api.formatter.datetime
},
{
field: 'tongji',
title: __("操作"),
operate: false,
formatter: function (value, row, index) {
return '订单详情';
}
},
]
]
});
// 为表格绑定事件
Table.api.bindevent(table);
},
api: {
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('