define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
$('#c-pay_method').change(function(){
var sval = $(this).val();
if (sval<3){ //银行卡
$('.c-card_bank').show();
$('.c-card_holder').html('* 收款人:');
$('.c-card_num').html('* 收款账号:');
}else if(sval==3){ //微信
$('.c-card_bank').hide();
$('.c-card_holder').html('* 姓名:');
$('.c-card_num').html('* 微信账号:');
$('#c-card_bank').val('');
}else if(sval==4){ //支付宝
$('.c-card_bank').hide();
$('.c-card_holder').html('* 姓名:');
$('.c-card_num').html('* 支付宝账号:');
$('#c-card_bank').val('');
}
})
//book_but
$(document).on('click','.book_but',function () {
Fast.api.open($(this).attr('href'), '查看数据', {});
return false;
});
$(document).on('click','.btn-re',function () {
var uid = $(this).data('uid');
layer.confirm("请确认你要进行重置服务号,重置后将会导致、数据清空、老用户无法访问、等等一系列你无法想象的超级严重的问题", { title: "重置服务号确认" }, function (index) {
layer.close(index);
$.post('/admin/auth/channel/re?admin_id='+uid,{},function(data){
if(data.code != 0){
Toastr.success(data.msg);
setTimeout(function() {
window.location.reload();
},2000);
}else{
Toastr.error(data.msg);
}
})
});
});
$(document).on('click','.btn-sync',function () {
var uid = $(this).data('uid');
layer.confirm("请确认你要进行微信用户同步确认", { title: "微信用户同步确认" }, function (index) {
layer.close(index);
$.post('/admin/auth/channel/sync?admin_id='+uid,{},function(data){
if(data.code != 0){
Toastr.success(data.msg);
setTimeout(function() {
window.location.reload();
},2000);
}else{
Toastr.error(data.msg);
}
})
});
});
$('#c-platform_id').change(function(){
var thisval = $(this).val();
console.log(thisval);
if(thisval){
thisval = 'p'+thisval;
$('.'+thisval)[0].checked=true;
$('.platform').removeAttr("disabled");
$('.'+thisval).attr("disabled",true);
}else{
//清空所有平台的readonly属性
$('.platform').removeAttr("disabled");
}
});
var Controller = {
index: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'auth/channel/index',
add_url: 'auth/channel/add',
edit_url: 'auth/channel/edit',
del_url: 'auth/channel/del',
multi_url: 'auth/channel/multi',
},
showToggle: false,
visible: false,
searchFormVisible:true,
search:false,
});
var table = $("#table");
// 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
columns: [
[
{field: 'admin.id', title: 'ID',operate: '=',visible:false},
{field: 'id', title: 'ID',operate: false},
{field: 'username', title: __('账号'),operate: 'LIKE %...%'},
{field: 'nickname', title: __('Nickname'),operate: 'LIKE %...%'},
{field: 'ac.appid', title: __('Appid'),visible:false,operate: 'LIKE %...%'},
{field: 'appid', title: __('Appid'),operate:false},
{field: 'admin_extend.benefit', title: __('佣金比例'), operate: false},
{field: 'admin_extend.create_by', title: __('开户人'), operate: false},
{field: 'today_recharge_money', title: __('今日充值'), operate: false},
{field: 'yesterday_recharge_money', title: __('昨日充值'), operate: false},
{field: 'recharge_money', title: __('总充值金额(不含当日)'), operate: false},
{field: 'benefit_money', title: __('结算单总额(包含当日)'), operate: false},
{field: 'no_cash_money', title: __('未提现总额(包含当日)'), operate: false},
{field: 'status', title: __("Status"), formatter: Table.api.formatter.status,searchList: {'normal': '正常', 'hidden':'隐藏'}},
{field: 'is_fouce', title: __("是否强制授权"), operate: false,formatter: function(value,row,index){return value==1?"强制":"不强制";}},
{field: 'platforms', title: __("域名系统"), operate: false,formatter: function(value,row,index){return $('
').html(value).text();}},
{field: 'ac.platform_id', title: __("默认平台"), visible:false, searchList:Controller.api.formatter.platforms()},
{field: 'ophost', title: __("业务域名(主)"), operate: 'LIKE %...%'},
{field: 'wxpay', title: __("支付服务号(主)"), operate: false},
{field: 'menuophost', title: __("业务域名(菜单)"), operate: 'LIKE %...%'},
{field: 'menuwxpay_host', title: __("支付服务号(菜单)"), operate: false},
{field: 'entryhost', title: __("入口域名"), operate: false},
{field: 'admin_extend.can_distribute', title: __("配号状态"), searchList: {'0': '关闭', '1':'开启'},formatter: function(value,row,index){return value==1?"开启":"关闭";}},
{field: 'admin_extend.reward_state', title: __('赏金开关'),formatter:function(value,row,index){return value==1?"已开启":"未开启";}, searchList: {'0': '未开启', '1':'已开启'}},
{
field: 'admin_extend.createtime',
title: __('注册时间'),
formatter: Table.api.formatter.datetime,
operate: false
},
{
field: 'tongji', visible:(Config.group>=2), title: __("统计"), operate: false, formatter: function (value, row, index) {
return '' +
' ' +
'' +
'
';
}
},
{
field: 'operate',
title: __('Operate'),
table: table,
events: Table.api.events.operate,
formatter: function (value, row, index) {
if (row.id == Config.admin.id) {
return '';
}
return Table.api.formatter.operate.call(this, value, row, index);
}
},
//{field: 'id', title: __('统计'), table: table, buttons: [
// {name: 'collect', text: '数据统计', title: '数据统计', icon: 'fa fa-list', classname: 'btn btn-xs btn-primary btn-dialog', url: '/admin/auth/channel/collect', callback:function(data){}},
// {name: 'more', text: '更多', title: '更多', icon: 'fa fa-flash', classname: 'btn btn-xs btn-primary btn-dialog', url: '/admin/auth/channel/more'}
//], operate:false, formatter: Table.api.formatter.buttons}
]
]
});
// 为表格绑定事件
Table.api.bindevent(table);
},
add: function () {
Form.api.bindevent($("form[role=form]"));
$("#c-platform_id").change(function(){
var id = $(this).val();
var url = "auth/channel/ajaxgetlistbyplatformid?platform_id=" + id;
$.get(url,function(data){
if(data.code == 0){
// var oplist = "";
// var wxlist = "";
$("#c-ophost_id").html("");
// if(data.data.ophostList){
for(var key1 in data.data.ophostList){
$("#c-ophost_id").append("
");
// oplist += "
";
}
$("#c-menuophost_id").html("");
for(var key1 in data.data.ophostList) {
$("#c-menuophost_id").append("
");
}
// }
// $("#c-ophost_id").html(oplist);
// if(data.data.wxpayList){
$("#c-wxpay_id").html("");
for(var key2 in data.data.wxpayList){
$("#c-wxpay_id").append("
");
// wxlist += "
";
}
$("#c-menuwxpay_id").html("");
for(var key2 in data.data.wxpayList) {
$("#c-menuwxpay_id").append("
");
}
// }
// $("#c-wxpay_id").html(wxlist);
}
});
})
$('.checkbox_plat input').change(function(){
var $this = $(this);
var txt = $this.attr('textinfo');
var id = $this.attr('value');
// var wxopurl = "auth/channel/ajaxgetlistbyplatformid?platform_id=" + id ;
if($this.is(":checked")){
$('#c-platform_id').append($(''));
/*$.get(wxopurl,function(data){
if(data.code == 0){
for(var key1 in data.data.ophostList){
$("#c-menuophost_id").append($(''));
}
for(var key2 in data.data.wxpayList){
$("#c-menuwxpay_id").append($(''));
}
}
});*/
}else{
$('.rem_' + id).remove();
}
$("#c-platform_id" ).selectpicker('refresh');
// alert(txt + '=====' +id + '=====' +$this.is(":checked"));
});
},
edit: function () {
$('.checkbox_plat input').change(function(){
var $this = $(this);
var id = $this.attr('value');
var url = "auth/channel/checkplatformauth?platform_id=" + id +'&channel_id='+Config.rowid;
// var wxopurl = "auth/channel/ajaxgetlistbyplatformid?platform_id=" + id ;
var txt = $this.attr('textinfo');
if($this.is(":checked")){
if(Config.is_exists_auth){
$.get(url,function(data){
if(data.code){
$('#c-platform_id').append($(''));
}
});
// $.get(wxopurl,function(data){
// if(data.code == 0){
// for(var key1 in data.data.ophostList){
// $("#c-menuophost_id").append($(''));
// }
// for(var key2 in data.data.wxpayList){
// $("#c-menuwxpay_id").append($(''));
// }
// }
// });
}else{
$('#c-platform_id').append($(''));
}
}else{
$('.rem_' + id).remove();
}
// $("#c-platform_id" ).selectpicker('refresh');
})
$("#c-platform_id").change(function(){
var id = $(this).val();
var url = "auth/channel/ajaxgetlistbyplatformid?platform_id=" + id;
$.get(url,function(data){
if(data.code == 0){
// var oplist = "";
// var wxlist = "";
$("#c-ophost_id").html("");
// if(data.data.ophostList){
for(var key1 in data.data.ophostList){
$("#c-ophost_id").append("
");
// oplist += "
";
}
$("#c-menuophost_id").html("");
for(var key1 in data.data.ophostList) {
$("#c-menuophost_id").append("
");
}
// }
// $("#c-ophost_id").html(oplist);
// if(data.data.wxpayList){
$("#c-wxpay_id").html("");
for(var key2 in data.data.wxpayList){
$("#c-wxpay_id").append("
");
// wxlist += "
";
}
$("#c-menuwxpay_id").html("");
for(var key2 in data.data.wxpayList) {
$("#c-menuwxpay_id").append("
");
}
// }
// $("#c-wxpay_id").html(wxlist);
}
});
})
Form.api.bindevent($("form[role=form]"));
},
api:{
formatter: {
tongji: function (value, row, index) {
return '' + row.useragent.split(" ")[0] + '';
},
platforms: function(){
var list = {};
for(var val in Config.platforms){
list[Config.platforms[val].id] = Config.platforms[val].name;
}
return list;
},
},
}
};
return Controller;
});