@extends('vip.layouts')
@section('seo_title')
    支付管理
@endsection
@section('content')
    <style>
        .layui-form-switch em {
            width: auto;
        }

        .layui-form-item .checkbox {
            width: auto;
        }
    </style>

    <div class="layui-row">
        <div class="layui-col-xs12">
            <form class="layui-form rewrite" eventType="eventForm" action="">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <div class="layui-inline" style="width: 280px">
                            <label class="layui-form-label">网关类别</label>
                            <div class="layui-input-inline" style="width: 200px">
                                <select name="gateway_type_id" id="gateway_type_id" lay-vgateway_type_iderify="" autocomplete="off" class="layui-input" eventType=event-query>
                                    <option value="">选择网关类别</option>
                                    @foreach($gateway_type_list as $k=>$v)
                                        <option value="{{$v->id}}"
                                                @if($gateway_type_id==$v->id) selected @endif>{{$v->typename}}</option>
                                    @endforeach
                                </select>
                            </div>
                        </div>

                        <div class="layui-inline">
                            <label class="layui-form-label">{{ trans('pay_gateway.gateway_name') }}</label>
                            <div class="layui-input-inline">
                                <input type="text" name="gateway_name" id="gateway_name" eventType="event-query"
                                       value="{{$gateway_name}}" lay-verify="required" autocomplete="off"
                                       class="layui-input">
                            </div>
                            <!-- <div class="layui-input-inline checkbox">
                                <input type="checkbox" name="sureblur" id="sureblur" lay-skin="switch" lay-text="精确|模糊"
                                       checked>
                            </div> -->
                        </div>

                        <div class="layui-inline">
                            <a class="layui-btn layui-btn-sm lay-btn-diy" data-type="reload"
                               eventType="event-query-submit" style="opacity: 1; pointer-events: auto;">提交</a>
                            <a class="layui-btn   layui-btn-sm layui-btn-normal reset" data-type="reload"
                               style="opacity: 1; pointer-events: auto;">重置</a>
                            <a class="layui-btn layui-btn-sm layui-btn-green set" data-type="reload"
                               style="opacity: 1; pointer-events: auto;"><i class="layui-icon">ဂ</i></a>
                           
                                <a href="/payment/gatewayAdd" class="layui-btn layui-btn-sm ">添加</a>
                           
                   
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
    <script id="opt" type="text/html">
        <a href="/payment/gatewayEdit?id=@{{d.id}}" class="layui-btn layui-btn-sm">修改</a>
        <a onclick="delChannel(@{{d.id}})" class="layui-btn layui-btn-xs  layui-btn-danger">删除</a>
    </script>
    <script>
        function delChannel(id){
            layer.open({
                title: '温馨提示'
                ,content: '确认删除该网关吗？'
                ,btn: ['确定', '取消', ]
                ,yes: function(index, layero){
                    $.get('/payment/removeGatewayHandler?id='+id,function(data){
                        layer.msg(data.msg)
                        location.reload()
                    })

                }
            });
        }
    </script>
    <script id="status" type="text/html">
          <!-- 这里的 checked 的状态只是演示 -->
          <input type="checkbox" name="gateway_status" value="@{{d.id}}" lay-skin="switch" lay-text="开启|关闭" lay-filter="openStatus" @{{ d.status == '1' ? 'checked' : '' }}>


    </script>

@push('dataTableJS')
    form.on('switch(openStatus)', function(obj){
        var status = 0;
        if(obj.elem.checked==true){
            status =1;
        }
        setcolumn('/payment/GatewayStatusSwitch',this.name,status,this.value,obj);
        //layer.tips(msg, obj.othis);
    });
    function setcolumn(url,column,value,id,obj){
        $.ajax({
            url: url+'?'+column+'='+value+'&gateway_id='+id,
            dataType: 'json',
            type: 'get',
            success:function(data){
                layer.msg(data.msg);
                if(data.status!=1){
                    if(value==1){
                        obj.othis[0].setAttribute("class", "layui-unselect layui-form-switch");
                        obj.othis[0].innerHTML='<em>开启</em><i></i>';
                    }else{
                        obj.othis[0].setAttribute("class",'layui-unselect layui-form-switch layui-form-onswitch');
                        obj.othis[0].innerHTML='<em>禁用</em><i></i>';
                    }
                }
            },
            error:function(){
            }

        });
    }

@endpush
    @include('vip.datatable')
    <link rel="stylesheet" href="{{ asset('/css/untablelist.css') }}"/>
@endsection
