@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="channel_type" lay-vgateway_type_iderify="" autocomplete="off" class="layui-input" eventType=event-query>
                                    <option value="">选择通道大类</option>
                                    <option value="1" @if($channel_type==1) selected @endif>PC通道</option>
                                    <option value="2" @if($channel_type==2) selected @endif>WAP通道</option>
                                    <option value="3" @if($channel_type==3) selected @endif>网银通道</option>

                                </select>
                            </div>
                        </div>
                        <div class="layui-inline" style="width: 280px">
                            <label class="layui-form-label">通道类别</label>
                            <div class="layui-input-inline" style="width: 200px">
                                <select name="channel_type_id" id="channel_type_id" lay-vgateway_type_iderify="" autocomplete="off" class="layui-input" eventType=event-query>
                                    <option value="">选择通道类别</option>
                                    @foreach($channel_type_list as $k=>$v)
                                        <option value="{{$v->id}}"
                                                @if($channel_type_id==$v->id) selected @endif>{{$v->typename}}</option>
                                    @endforeach
                                </select>
                            </div>
                        </div>

                        <div class="layui-inline">
                            <label class="layui-form-label">{{ trans('pay_channels.channel_name') }}</label>
                            <div class="layui-input-inline">
                                <input type="text" name="channel_name" id="channel_name" eventType="event-query"
                                       value="{{$channel_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/channelAdd" class="layui-btn layui-btn-sm ">添加</a>
                      
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
    <script id="opt" type="text/html">
        <a href="/payment/channelEdit?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/removeChannelHandler?id='+id,function(data){
                        layer.msg(data.msg)
                        location.reload()
                    })

                }
            });


        }
    </script>
    <script id="channel_type" type="text/html">
        @{{#if(d.channel_type == '1'){ }}
        PC
        @{{#}else if(d.channel_type == '2'){ }}
        WAP
        @{{#}else{ }}
        网银
        @{{#} }}

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


    </script>

@push('dataTableJS')
    form.on('switch(openStatus)', function(obj){
        var status = 0;
        if(obj.elem.checked==true){
            status =1;
        }
        setcolumn('/payment/ChannelStatusSwitch',this.name,status,this.value,obj);
        //layer.tips(msg, obj.othis);
    });
    function setcolumn(url,column,value,id,obj){
        $.ajax({
            url: url+'?'+column+'='+value+'&channel_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
