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('* 收款账号:'); if(sval == 1){ $('.c-idcard_no').hide(); $('#c-idcard_no').attr("disabled",true); }else{ $('.c-idcard_no').show(); $('#c-idcard_no').attr("disabled",false); } }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); } }) }); }); //推送开关全选 add by liues@dianzhong.com at 2018-09-05 11:01:18 Form.events.selecttips = function (form) { var all_tip = $("#c-all_tip", form); var other_tips = $(":checkbox[id$='_tip']:not('#c-all_tip')", form); var all_tip_checked = function () { var checked = (other_tips.length == other_tips.filter(":checked").length); all_tip.prop("checked", checked); }; var other_tips_checked = function () { var checked = all_tip.prop("checked"); other_tips.prop("checked", checked); }; all_tip.change(other_tips_checked); other_tips.change(all_tip_checked); all_tip_checked(); } 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', }, }); var table = $("#table"); if (Config.is_index == 1 || Config.isassociated == '2') { // 勾选,关联渠道 $('.js_assosite').on('click', function (e, data) { var ids = Table.api.selectedids(table); Layer.confirm( __('已选中条数:%s', ids.length), {icon: 3, title: __('Warning'), offset: 0, shadeClose: true}, function (index) { var strids = ($.isArray(ids) ? ids.join(",") : ids); if (Config.is_index == 1) { Fast.api.close(strids); } else { var url = 'kl/rulemanage/batchAssociate'; var options = {url: url, data: { ids: strids, kl_id:Config.kl_id, isassociated: 2, params: ''}}; Fast.api.ajax(options, function (data, ret) { table.bootstrapTable('refresh'); parent.layer.close(this); }, function (data, ret) { }); } Layer.close(index); } ); }); $('.js_assosite_all').on('click', function (e, data) { var kl_id = $(this).data('kl_id'); Layer.confirm( '确定要关联所有渠道吗', {icon: 3, title: __('Warning'), offset: 0, shadeClose: true}, function (index) { if (Config.is_index == 1) { Fast.api.close('*'); } else { $.post('/admin/kl/rulemanage/ajaxsingeassociateall', { 'kl_id': kl_id, }, function (result) { if (result.code) { layer.msg(result.msg,{icon:1,time:1000}); //layer.alert(result.msg); setTimeout(function () { var index=parent.layer.getFrameIndex(window.name); window.parent.location.reload();//刷新父页面 }, 1500) } }); } Layer.close(index); } ); }); // 初始化表格 table.bootstrapTable({ url: $.fn.bootstrapTable.defaults.extend.index_url + '?kl_id=' + Config.kl_id + '&isassociated=' + Config.isassociated + '&operate=' +Config.operate+ '&channel_ids='+ Config.channel_ids, searchFormVisible: true, search:false, columns: [ [ {field: 'state', checkbox: true, }, {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.benefit_app', title: __('APP佣金比例'), operate: false}, {field: 'admin_extend.create_by', title: __('开户人'), operate: '=', searchList:{}}, { field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: function (value, row, index) { html = ""; html += "关联"; return html; } }, ] ], onLoadSuccess: function (data) { //配置搜索栏"开户人"下拉列表 var formControlCreateBy = $(".form-control[name='admin_extend.create_by']"); if(formControlCreateBy.children("option").length<=1){ $.each(data.create_list, function (index, row) { formControlCreateBy.append(''); }); } } }); // 单个关联操作 $(document).on('click', '.qd-doassociate', function () { var kl_id = $(this).data("kl_id"); var channel_id = $(this).data("channel_id"); var qd_this= $(this); if (Config.is_index == 1) { Fast.api.close(channel_id); } else { $.post('/admin/kl/rulemanage/ajaxsingeassociate', { 'kl_id': kl_id, 'channel_id': channel_id }, function (result) { if (result.code) { //layer.alert(result.msg); qd_this.removeClass('qd-doassociate').html('已关联'); //table.bootstrapTable('refresh'); } }); } }); } else if (Config.is_index == 2 || Config.isassociated == '3') { // 勾选,查看 删除渠道 $('.js_assosite_del').on('click', function (e, data) { var ids = Table.api.selectedids(table); Layer.confirm( __('已选中条数:%s', ids.length), {icon: 3, title: __('Warning'), offset: 0, shadeClose: true}, function (index) { var strids = ($.isArray(ids) ? ids.join(",") : ids); if (Config.is_index == 2) { Fast.api.close(strids); } else { var url = 'kl/rulemanage/batchassociatedel'; var options = {url: url, data: { ids: strids, kl_id:Config.kl_id, isassociated: 3, params: ''}}; Fast.api.ajax(options, function (data, ret) { table.bootstrapTable('refresh'); parent.layer.close(this); }, function (data, ret) { }); } Layer.close(index); } ); }); // 初始化表格 table.bootstrapTable({ url: $.fn.bootstrapTable.defaults.extend.index_url + '?kl_id=' + Config.kl_id + '&isassociated=' + Config.isassociated+ '&operate=' +Config.operate+ '&channel_ids='+ Config.channel_ids, searchFormVisible: true, search:false, columns: [ [ {field: 'state', checkbox: true, }, {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.benefit_app', title: __('APP佣金比例'), operate: false}, {field: 'admin_extend.create_by', title: __('开户人'), operate: '=', searchList:{}}, { field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: function (value, row, index) { return "删除"; } }, ] ], onLoadSuccess: function (data) { //配置搜索栏"开户人"下拉列表 var formControlCreateBy = $(".form-control[name='admin_extend.create_by']"); if(formControlCreateBy.children("option").length<=1){ $.each(data.create_list, function (index, row) { formControlCreateBy.append(''); }); } } }); // 单个关联操作 $(document).on('click', '.qd-doassociate-del', function () { var kl_id = $(this).data("kl_id"); var channel_id = $(this).data("channel_id"); var qd_this= $(this); if (Config.is_index == 2) { Fast.api.close(channel_id); } else { $.post('/admin/kl/rulemanage/ajaxsingeassociatedel', { 'kl_id': kl_id, 'channel_id': channel_id }, function (result) { if (result.code) { //layer.alert(result.msg); //qd_this.removeClass('qd-doassociate-del').html('已删除'); table.bootstrapTable('refresh'); } }); } }); } else { // 初始化表格 table.bootstrapTable({ url: $.fn.bootstrapTable.defaults.extend.index_url, searchFormVisible: true, 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.benefit_app', title: __('APP佣金比例'), operate: false}, {field: 'admin_extend.create_by', title: __('开户人'), operate: '=', searchList:{}}, {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: '=', searchList: Controller.api.formatter.ophosts()}, {field: 'wxpay', title: __("支付服务号(主)"), operate: '=', searchList: Controller.api.formatter.wxpays()}, {field: 'menuophost', title: __("业务域名(菜单)"), operate: '=', searchList: Controller.api.formatter.ophosts()}, {field: 'menuwxpay_host', title: __("支付服务号(菜单)"), operate: '=', searchList: Controller.api.formatter.wxpays()}, {field: 'admin_extend.can_distribute', title: __("配号状态"), searchList: {'0': '关闭', '1':'开启'},formatter: function(value,row,index){return value==1?"开启":"关闭";}}, {field: 'short_relation_count', title: __('短链域名数'),operate:false}, {field: 'guide_relation_count', title: __('导粉域名数'),operate:false}, {field: 'guide_domain', 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:([2, 9].indexOf(Config.group) > -1), 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); } }, ] ], onLoadSuccess: function (data) { //配置搜索栏"开户人"下拉列表 var formControlCreateBy = $(".form-control[name='admin_extend.create_by']"); if(formControlCreateBy.children("option").length<=1){ $.each(data.create_list, function (index, row) { formControlCreateBy.append(''); }); } } }); } // 为表格绑定事件 Table.api.bindevent(table); }, add: function () { Form.api.bindevent($("form[role=form]")); Form.events.selecttips("form[role=form]"); //选择平台 $('.checkbox_plat input').change(function () { var platform_id = $(this).attr('value'); if($(this).is(":checked")){ Controller.api.addOphostList(platform_id); }else{ Controller.api.delPlatformList(platform_id); } }); }, edit: function () { Form.api.bindevent($("form[role=form]")); Form.events.selecttips("form[role=form]"); $('.checkbox_plat input').change(function () { var platform_id = $(this).attr('value'); if($(this).is(":checked")){ if(Controller.api.checkedPlatformAuth(platform_id,Config.admin_id)){ Controller.api.addOphostList(platform_id); } }else{ Controller.api.delPlatformList(platform_id); } }); }, select:function(){ // 初始化表格参数配置 Table.api.init({ extend: { index_url: 'auth/channel/select' }, searchFormVisible: true, search:false, }); var table = $("#table"); // 初始化表格 table.bootstrapTable({ url: $.fn.bootstrapTable.defaults.extend.index_url + '?type='+Config.type+'&operate='+Config.operate+'&source_id='+Config.source_id+'&group_ids='+Config.group_ids, pk: 'id', sortName: 'id desc', sortOrder: '', columns: [Controller.api.showColumns()], }); // 为表格绑定事件 Table.api.bindevent(table); // 单个关联操作 $(document).on('click', '.qd-doassociate', function () { var kl_id = $(this).data("kl_id"); var channel_id = $(this).data("channel_id"); var qd_this= $(this); Fast.api.close(channel_id); }); // 勾选,关联渠道 $('.js_assosite').on('click', function (e, data) { var ids = Table.api.selectedids(table); Layer.confirm( __('已选中条数:%s', ids.length), {icon: 3, title: __('Warning'), offset: 0, shadeClose: true}, function (index) { var strids = ($.isArray(ids) ? ids.join(",") : ids); Fast.api.close(strids); } ); }); $('.js_assosite_all').on('click', function (e, data) { var kl_id = $(this).data('kl_id'); Layer.confirm( '确定要关联所有渠道吗', {icon: 3, title: __('Warning'), offset: 0, shadeClose: true}, function (index) { Fast.api.close('*'); } ); }); // 勾选,查看 删除渠道 $('.js_assosite_del').on('click', function (e, data) { var ids = Table.api.selectedids(table); Layer.confirm( __('已选中条数:%s', ids.length), {icon: 3, title: __('Warning'), offset: 0, shadeClose: true}, function (index) { var strids = ($.isArray(ids) ? ids.join(",") : ids); Fast.api.close(strids); Layer.close(index); } ); }); // 单个关联操作 $(document).on('click', '.qd-doassociate-del', function () { var kl_id = $(this).data("kl_id"); var channel_id = $(this).data("channel_id"); var qd_this= $(this); Fast.api.close(channel_id); }); }, api:{ showColumns:function(){ var cols = new Array(); cols.push({checkbox: true}); cols.push({field: 'id', title: 'ID'}); cols.push({field: 'username', title: __('Username'), operate: 'LIKE %...%'}); cols.push({field: 'nickname', title: __('Nickname'), operate: 'LIKE %...%'}); cols.push({field: 'groups_text', title: __('Group'), operate:false, formatter: Table.api.formatter.label}); if(Config.operate == 'add'){ cols.push({ field: 'operate', title: __('Operate'), table: table, formatter: function (value, row, index) { html = ""; html += "关联"; return html; } }); } else { cols.push({ field: 'operate', title: __('Operate'), table: table, formatter: function (value, row, index) { return "删除"; } }); } return cols; }, //检查平台,检查用户是否已授权过,检查平台是否已授权过 checkedPlatformAuth:function(platform_id,channel_id){ var is_auth = false; if(Config.channel_is_auth){ $.ajaxSettings.async = false; $.get("auth/channel/checkplatformauth?platform_id=" + platform_id +'&channel_id='+channel_id,function(data){ if(data.code){ is_auth = true; }else{ is_auth = false; } }); $.ajaxSettings.async = true; }else{ is_auth = true; } return is_auth; }, //添加业务域名列表 addOphostList:function(platform_id){ $.get("auth/channel/ajaxgetophostlistbyplatformid?platform_id=" + platform_id, function (data) { if (data.code) { var ophost_list = data.data; for (var key in ophost_list) { $("#c-ophost_id").append("
"); $("#c-menuophost_id").append("
"); } }else{ Toastr.error(data.msg); } }); }, //添加支付域名列表 addOphostPayList:function(platform_id,ophost_id,wxpayName){ $.get("auth/channel/ajaxgetwxpaylistbyplatformid?platform_id=" + platform_id+'&ophost_id='+ophost_id, function (data) { if (data.code) { var pay_list = data.data; for (var key in pay_list) { $('#'+wxpayName).append("
"); } }else{ Toastr.error(data.msg); } }); }, //删除平台列表 delPlatformList:function(platform_id){ $("#c-ophost_id option[data-platform_id='"+platform_id+"']").remove(); $("#c-menuophost_id option[data-platform_id='"+platform_id+"']").remove(); }, delWxpayList:function(wxpayName){ $("#"+wxpayName+" option").remove(); $("#"+wxpayName).append("
"); }, 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; }, ophosts: function () { var list = {}; for(var val in Config.ophosts){ list[val] = Config.ophosts[val]; } return list; }, wxpays: function () { var list = {}; for(var val in Config.wxpays){ list[val] = Config.wxpays[val]; } return list; } }, } }; return Controller; });