123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
- Date.prototype.Format = function (fmt) { // author: meizz
- var o = {
- "M+": this.getMonth() + 1, // 月份
- "d+": this.getDate(), // 日
- "h+": this.getHours(), // 小时
- "m+": this.getMinutes(), // 分
- "s+": this.getSeconds(), // 秒
- "q+": Math.floor((this.getMonth() + 3) / 3), // 季度
- "S": this.getMilliseconds() // 毫秒
- };
- if (/(y+)/.test(fmt))
- fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
- for (var k in o)
- if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
- return fmt;
- }
- //选择平台的js
- var Controller = {
- index: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'platform/index',
- add_url: 'platform/add',
- edit_url: 'platform/edit',
- // del_url: 'platform/del',
- multi_url: 'platform/multi',
- table: 'platform',
- }
- });
- var table = $("#table");
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'id',
- sortName: 'id',
- columns: [
- [
- {checkbox: true},
- {field: 'id', title: __('Id')},
- {field: 'name', title: __('Name')},
- {field: 'authhost', title: __('Authhost')},
- {field: 'status', title: __('Status'), visible:false, searchList: {"0":__('Status 0'),"1":__('Status 1')}},
- {field: 'status_text', title: __('Status'), operate:false, operate:false},
- {field: 'isdefault', title: __('Isdefault'), visible:false, searchList: {"0":__('Isdefault 0'),"1":__('Isdefault 1')}},
- {field: 'isdefault_text', title: __('Isdefault'), operate:false, operate:false},
- {field: 'appid', title: __('Appid')},
- {field: 'secret', title: __('Secret'), operate:false},
- {field: 'token', title: __('Token'), operate:false},
- {field: 'aes_key', title: __('Aes_key'), operate:false},
- {field: 'platfile', title: __('Platfile'), operate:false},
- {field: 'p_desc', title: __('描述'), operate:false},
- {field: 'proxy_config', title: __('代理IP'), visible:true, operate: 'LIKE %...%'},
- {field: 'job_proxy_config', title: __('Job推送代理IP'), visible:true, operate: 'LIKE %...%'},
- {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime, operate:false},
- {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime, operate:false},
- {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
- ]
- ]
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- },
- add: function () {
- Controller.api.isdefault();
- Controller.api.bindevent();
- },
- edit: function () {
- Controller.api.isdefault();
- Controller.api.bindevent();
- },
- // switchmenuhost:function(){
- // //选择业务域名&菜单业务域名
- // var op_list = [
- // {host_key:"c-menuophost_id",pay_key:"c-menuwxpay_id"},
- // {host_key:"c-new_menuophost_id",pay_key:"c-new_menuwxpay_id"}
- // ];
- // $.each(op_list,function(index,data){
- // $('#'+data.host_key).change(function () {
- // var ophost_id = $(this).val();
- // var platform_id =$("#"+data.host_key+" option[value='"+ophost_id+"']").data('platform_id');
- // if(ophost_id && ophost_id != undefined && platform_id && platform_id != undefined){
- // Controller.api.addOphostPayList(platform_id,ophost_id,data.pay_key);
- // }else{
- // Controller.api.delWxpayList(data.pay_key);
- // }
- // });
- // });
- // Form.api.bindevent($("form[role=form]"),
- // function (data,result) {
- // Controller.api.showResultWindow(data);
- // return false;
- // },
- // function (data,result) {
- // layer.alert(result.msg);
- // return false;
- // }
- // );
- // },
- // switchophost:function(){
- // //选择业务域名&菜单业务域名
- // var op_list = [
- // {host_key:"c-ophost_id",pay_key:"c-wxpay_id"},
- // {host_key:"c-new_ophost_id",pay_key:"c-new_wxpay_id"},
- // ];
- // $.each(op_list,function(index,data){
- // $('#'+data.host_key).change(function () {
- // var ophost_id = $(this).val();
- // var platform_id =$("#"+data.host_key+" option[value='"+ophost_id+"']").data('platform_id');
- // if(ophost_id && ophost_id != undefined && platform_id && platform_id != undefined){
- // Controller.api.addOphostPayList(platform_id,ophost_id,data.pay_key);
- // }else{
- // Controller.api.delWxpayList(data.pay_key);
- // }
- // });
- // });
- // Form.api.bindevent($("form[role=form]"),
- // function (data,result) {
- // Controller.api.showResultWindow(data);
- // return false;
- // },
- // function (data,result) {
- // layer.alert(result.msg);
- // return false;
- // }
- // );
- // },
- switchplatform:function(){
- $("form[role=form]").validator({
- valid: function(form) {
- var is_post = true;
- $('#c-create_by-id').isValid(function(v){
- if (!v) {is_post = false;}
- });
- $('#c-nickname').isValid(function(v){
- if (!v) {is_post = false;}
- });
- if(is_post){
- var post_data = $(form).serializeArray();
- var search_data = $('#search-form').serializeArray();
- $.post(location.href,post_data.concat(search_data),function(result){
- if(result.code){
- Controller.api.showResultWindow(result.data);
- }else{
- layer.alert(result.msg);
- }
- })
- }
- }
- });
- },
- api: {
- //添加支付域名列表
- addOphostPayList:function(platform_id,ophost_id,wxpayName){
- $.get("auth/channel/ajaxgetwxpaylistbyplatformid?platform_id=" + platform_id+'&ophost_id='+ophost_id, function (data) {
- if (data.code) {
- Controller.api.delWxpayList(wxpayName);
- var pay_list = data.data;
- for (var key in pay_list) {
- $('#'+wxpayName).append("<option data-platform_id='"+ platform_id +"' value='" + pay_list[key]['id'] + "' >" + pay_list[key]['text'] + "</option><br>");
- }
- }else{
- Toastr.error(data.msg);
- }
- });
- },
- showResultWindow:function(data){
- var html = "<p align='center' style='color:coral'>符合条件的总数为:"+data.total+"个</p>";
- html += "<p align='center' style='color:peru;'>没有授权的总数为:"+data.unauthorized+"个</p>";
- html += "<p align='center' style='color:peru;'>平台不符的总数为:"+data.platform+"个</p>";
- html += "<p align='center' style='color:green;'>切换成功的总数为:"+data.success+"个</p>";
- html += "<p align='center' style='color:red;'>切换失败的总数为:"+data.fail+"个</p>";
- if(data.export == true){
- layer.confirm(html, {
- btn: ['导出切换渠道','不导出切换渠道'] //按钮
- }, function(){
- window.location.href = "/admin/platform/export"
- layer.close(layer.index)
- }, function(){
- });
- }else{
- layer.alert(html);
- }
- },
- delWxpayList:function(wxpayName){
- $("#"+wxpayName+" option").remove();
- $("#"+wxpayName).append("<option value='' selected>请选择</option><br>");
- },
- bindevent: function () {
- Form.api.bindevent($("form[role=form]"));
- },
- isdefault:function (){
- $("#c-isdefault").change(function(){
- if($(this).val()==1){
- if(!confirm("确定修改为默认吗?")){
- $(this).val(0);
- }
- }
- });
- }
- }
- };
- return Controller;
- });
|