@extends('vip.layouts')
@section('seo_title')
    游戏设置
@endsection
@section('content')
    <style>
        .layui-laydate-range {
            width: auto;
        }
    </style>
    <script type="text/html" id="closeTools">
  <!-- 这里的 checked 的状态只是演示 -->
  @if(checkRriv('/admin/egame/GameClose'))
  <input type="checkbox" style="width: 60px;" name="status" value="@{{d.game_name}}" lay-skin="switch" lay-text="启用|禁用" lay-filter="openStatus" @{{ d.status == '1' ? 'checked' : '' }}>
  @endif
 <!-- <a href="http://baidu.com" class="layui-btn layui-btn-sm">jump</a>-->
</script>

    <script type="text/html" id="online">
        @{{# if(d.close_status != 2){ }}
        <input type="checkbox" style="width: 60px;" name="close_status" value="@{{d.game_name}}" lay-skin="switch" lay-text="开启|关闭" lay-filter="onlineStatus" @{{ d.close_status == '1' ? 'checked' : '' }}>
        @{{# }else{ }}
            待上线
        @{{# } }}
    </script>

    <script type="text/html" id="option">
        <!-- 这里的 操作栏 -->
        <a class="layui-btn layui-btn-primary layui-btn-xs edit" lay-event="detail" pid="id" uri="/admin/egameClose/edit/?id=" href="/admin/egameClose/edit/?id=@{{d.id}}&name=@{{d.name}}"> 玩法介绍 </a>
        <a class="layui-btn layui-btn-primary layui-btn-xs edit" lay-event="detail" pid="id" uri="/admin/egameClose/edit/?id=" href="/admin/egameClose/editInfo/?id=@{{d.id}}"> 修改 </a>
    </script>
    <!---注单管理-->
    <div class="layui-row">

        <div class="layui-col-xs12">

            <form class="layui-form rewrite" action="" eventType=eventForm>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">{{ trans('gamemenu.name') }}</label>
                        <div class="layui-input-inline" style="width: 125px">
                            <select name="name" id="name" lay-verify="" autocomplete="off" eventType="event-query" class="layui-input">
                                <option  value="">{{ trans('gamemenu.select_game') }}</option>
                                @foreach(trans('gamemenu.egame_type') as $k=>$v):
                                @if($k == $name)
                                <option selected = "selected" value="{{$k}}">{{$v}}</option>
                                @else
                                <option value="{{$k}}">{{$v}}</option>
                                @endif
                                @endforeach
                            </select>
                        </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>
                    </div>
                    <div class="layui-inline"><a href="/admin/egameClose/add" class="layui-btn layui-btn-sm  ">添加游戏</a></div>

                </div>
            </form>
        </div>
    </div>
@push('dataTableJS')
//  var active = {
//        reload: function(){
//            //执行重载
//            table.reload('{{ $dataId }}', {
//                page: {
//                    curr: 1 //重新从第 1 页开始
//                }
//                ,where: {
//                    name:$('#name').val(),
//                }
//            });
//      }
//  };

//  $('.lay-btn-diy').on('click', function(){
//      var type = $(this).data('type');
//      active[type] ? active[type].call(this) : '';
//  });

    //重置表单
    $('.reset').on('click',function(){
        $('input').val('');
        $('#name').val('');
//      var type = $(this).data('type');
//      active[type] ? active[type].call(this) : '';
    });

    //刷新表单
    $('.set').on('click',function(){

    });

    form.on('switch(openStatus)', function(obj){
        var status = 0;
        if(obj.elem.checked==true){
            status =1;
        }
        setcolumn('/admin/egame/GameClose',this.name,status,this.value,obj);
        //layer.tips(msg, obj.othis);
    });

    form.on('switch(onlineStatus)', function(obj){
        var status = 0;
        if(obj.elem.checked==true){
        status =1;
        }
        setcolumn('/admin/egame/GameOnlie',this.name,status,this.value,obj);
        //layer.tips(msg, obj.othis);
    });

    function setcolumn(url,column,value,id,obj){
        $.ajax({
            url: url+'?'+column+'='+value+'&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>';
                    }
                }
            }
        });
    }
    @endpush
    @include('vip.datatable')


@endsection
