@extends('vip.layouts')
@section('content')

    <form class="layui-form" action="{{ url()->full() }}" id="submitForm" name="submitForm" method="post"
          eventType=eventAjaxForm>
        {!! csrf_field() !!}
        <div class="layui-form-item">
            <label class="layui-form-label">游戏名</label>
            <div class="layui-input-block">
                <input type="text" name="name" required lay-verify="required" autocomplete="off" class="layui-input"
                       value="{{isset($data['name'])?$data['name']:''}}">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">游戏代码</label>
            <div class="layui-input-inline">
                <input type="text" name="table_name" required lay-verify="required" autocomplete="off" class="layui-input"
                       value="{{isset($data['table_name'])?$data['table_name']:''}}">
            </div>
            <div class="layui-form-mid layui-word-aux" style="color: red">*游戏代码请谨慎修改，如修改错误将导致该游戏不可用</div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">游戏分类</label>
            <div class="layui-input-inline">
                <select name="category" id="category" lay-verify="" autocomplete="off" eventType="event-query" class="layui-input" class="Selects" lay-filter="testSelect">
                    <option  value="">选择分类</option>
                    @if(is_array($cate))
                        @foreach($cate as $k=>$v):
                        @if(isset($v['id']))
                            @if($v['id']== $data['cate_id'])
                                <option selected = "selected" value="{{$v['id']}}">{{$v['name']}}</option>
                            @else
                                <option value="{{$v['id']}}">{{$v['name']}}</option>
                            @endif
                        @else
                            <option value="" disabled>{{$v}}</option>
                        @endif
                        @endforeach
                    @endif
                </select>
            </div>

        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">游戏类型</label>
            <div class="layui-input-block" id="testSelect" >
                <input type="radio" name="type" lay-filter="jiedian" value="1" title="高频彩"
                       @if($data['type']==1) checked @endif>
                <input type="radio" name="type" lay-filter="jiedian" value="2" title="低频彩"
                       @if($data['type']==2) checked @endif>
                <input type="radio" name="type" lay-filter="jiedian" value="3" title="链接型"
                       @if($data['type']==3) checked @endif>
                <input type="radio" name="type" lay-filter="jiedian" value="4" title="真人视讯"
                       @if($data['type']==4) checked @endif>
               <input type="radio" name="type" lay-filter="jiedian" value="5" title="扩展字段"
                       @if($data['type']==5) checked @endif>
            </div>
            <div class="layui-form-mid layui-word-aux" style="color: red"></div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">游戏图标</label>
            <div class="layui-input-inline">
                <input type="text" name="icon" required lay-verify="required" autocomplete="off" class="layui-input"
                       value="{{isset($data['icon'])?$data['icon']:''}}">
                <input type="text" id="show_icon" autocomplete="off" class="layui-input" style="display: none;"
                       value="" disabled="disabled" />
            </div>
            <div class="layui-form-mid layui-word-aux" style="color: red">
                <button type="button" class="layui-btn" id="icon" >
                    <i class="layui-icon">&#xe67c;</i>上传图片
                </button>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">游戏未上线图标</label>
            <div class="layui-input-inline">
                <input type="text" name="close_icon" required lay-verify="required" autocomplete="off" class="layui-input"
                       value="{{isset($data['close_icon'])?$data['close_icon']:''}}">
                <input type="text" id="show_close_icon" required  autocomplete="off" class="layui-input" style="display: none;"
                       value="" disabled="disabled"/>
            </div>
            <div class="layui-form-mid layui-word-aux" style="color: red">
                <button type="button" class="layui-btn" id="close_icon">
                    <i class="layui-icon">&#xe67c;</i>上传图片
                </button>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">游戏手机端链接</label>
            <div class="layui-input-inline">
                <input type="text" name="link" required lay-verify="required" autocomplete="off" class="layui-input"
                       value="{{isset($data['link'])?$data['link']:''}}">
            </div>
            <div class="layui-form-mid layui-word-aux" style="color: red"></div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">关闭理由</label>
            <div class="layui-input-block">
                <input type="text" name="close_info" lay-verify="required" placeholder="请输入关闭理由" autocomplete="off"
                       class="layui-input" value="{{isset($data['closeinfo'])?$data['closeinfo']:''}}">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">开奖时间</label>
            <div class="layui-input-inline">
                <input type="text" name="open_time" lay-verify="required" placeholder="" autocomplete="off"
                       class="layui-input" value="{{isset($data['open_time'])?$data['open_time']:''}}">
            </div>
            <div class="layui-form-mid layui-word-aux" style="color: red">*游戏开奖时间以秒数填写</div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">封盘时间</label>
            <div class="layui-input-inline">
                <input type="text" name="close_time"  placeholder="" autocomplete="off"
                       class="layui-input" value="{{isset($data['close_time'])?$data['close_time']:''}}">
            </div>
            <div class="layui-form-mid layui-word-aux" style="color: red">*游戏封盘时间以秒数填写</div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">热度排序</label>
            <div class="layui-input-inline">
                <input type="number" name="hot" lay-verify="" autocomplete="off" class="layui-input"
                       value="{{isset($data['hot'])?$data['hot']:''}}">
            </div>
            <div class="layui-form-mid layui-word-aux">*热度越大排位越靠前</div>
        </div>

        <div class="layui-form-item" style="height: auto;">
            <label class="layui-form-label">扩展字段</label>
            <div class="layui-input-inline" style="width: 800px;">
                <!-- <input type="text" name="limit_amount" lay-verify="" autocomplete="off" class="layui-input"
                       value=""> -->
                <textarea style="height: 400px;" name="limit_amount" lay-verify="" rows="5"  autocomplete="off" class="layui-input">{{isset($data['extend'])?$data['extend']:''}}</textarea>
            </div>
            <div class="layui-form-mid layui-word-aux">JSON字符串</div>
        </div>


        {{--<div class="layui-form-item">--}}
            {{--<label class="layui-form-label">玩法介绍</label>--}}
            {{--<div class="layui-input-block">--}}
                {{--<textarea class="layui-textarea layui-hide" name="play_desc" lay-verify="content"--}}
                          {{--id="LAY_demo_editor">{{isset($data['play_desc'])?$data['play_desc']:''}}</textarea>--}}
            {{--</div>--}}
        {{--</div>--}}

        <div class="layui-form-item">
            <label class="layui-form-label">游戏启用</label>
            <div class="layui-input-block">
                <input type="radio" name="status" value="1" title="启用"
                       @if($data['status']==1) checked @endif>
                <input type="radio" name="status" value="0" title="禁用"
                       @if($data['status']==0) checked @endif>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">游戏上线</label>
            <div class="layui-input-block">
                <input type="radio" name="close_status" value="1" title="开启"
                       @if($data['close_status']==1) checked @endif>
                <input type="radio" name="close_status" value="0" title="关闭"
                       @if($data['close_status']==0) checked @endif>
                <input type="radio" name="close_status" value="2" title="待上线"
                       @if($data['close_status']==2) checked @endif>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">角标</label>
            <div class="layui-input-block">
                <input type="radio" name="corner" value="0" title="无"
                       @if($data['corner']==0) checked @endif>
                <input type="radio" name="corner" value="1" title="热门"
                       @if($data['corner']==1) checked @endif>
                <input type="radio" name="corner" value="2" title="推荐"
                       @if($data['corner']==2) checked @endif>
                <input type="radio" name="corner" value="3" title="精选"
                       @if($data['corner']==3) checked @endif>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="submitForm">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-normal">重置</button>
            </div>
        </div>
    </form>

    <script>
        //Demo
        layui.use(['form', 'layedit', 'laydate','upload'], function () {
            var form = layui.form
                , layer = layui.layer
                , layedit = layui.layedit
                , laydate = layui.laydate
                ,upload = layui.upload;

            var editIndex = layedit.build('LAY_demo_editor');
            //执行实例
            var uploadInst = upload.render({
                elem: '#icon'//绑定元素
                ,url: '/admin/gameClose/upload' //上传接口
                ,done: function(data){
                    var val=data.data;
                    //上传完毕回调
                    $('input[name="icon"]').val(val.path);
                    $('input[name="icon"]').hide();
                    $('#show_icon').val(val.name);
                    $('#show_icon').show();
                    layer.msg(data.msg);
                }
                ,error: function(){
                    //请求异常回调
                    layer.msg('请求异常');
                }
            });
            var uploadIns = upload.render({
                elem: '#close_icon'//绑定元素
                ,url: '/admin/gameClose/upload' //上传接口
                ,done: function(data){
                    var val=data.data;
                    //上传完毕回调
                    $('input[name="close_icon"]').val(val.path);
                    $('input[name="close_icon"]').hide();
                    $('#show_close_icon').val(val.name);
                    $('#show_close_icon').show();
                    layer.msg(data.msg);
                }
                ,error: function(){
                    //请求异常回调
                    layer.msg('请求异常');
                }
            });
            form.verify({
                title: function(value){
                    if(value.length < 5){
                        return '标题至少得5个字符啊';
                    }
                },
                category:function(value){
                    if(value == ''){
                        return '请选择游戏分类';
                    }
                }
                ,pass: [/(.+){6,12}$/, '密码必须6到12位']
                ,content: function(value){
                    layedit.sync(editIndex);
                }
            });

            // var check = $('input:radio[name="type"]:checked').val();
            // var check = $('input:radio:checked').val();
            // console.log(check);

            form.on('radio(jiedian)', function (data) {
                var abc=data.value;
                if (abc == 4 ) {
                    $('.single').show();
                }else{
                    $('.single').hide();
                }

                if (abc == 5) {
                    $('.kuozhan').show();
                }else{
                    $('.kuozhan').hide();
                }

            });

            // form.on('select(testSelect)', function(data){
            //    if (data.value==19) {
            //         $('.single').show();
            //    }else{
            //        $('.single').hide();
            //    }
            // });
            //监听提交
            form.on('submit(submitForm)', function (data) {
                return true;
            });


        });
        //创建一个编辑器

    </script>
@endsection
