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

    <form class="layui-form" action="{{ url()->full() }}" id="submitForm" name="submitForm" method="post"
          eventType=eventAjaxForm enctype="multipart/form-data">
        {!! csrf_field() !!}
        <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">
                    <option  value="">选择分类</option>
                    @if(is_array($cate))
                        @foreach($cate as $k=>$v):
                        @if(isset($v['id']))
                          <option value="{{$v['id']}}">{{$v['name']}}</option>
                        @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-inline">
                <input type="text" name="name" required lay-verify="required" autocomplete="off" class="layui-input" value="">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">玩法代码</label>
            <div class="layui-input-inline">
                <input type="text" name="code" required lay-verify="code" autocomplete="off" class="layui-input" value="">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">投注示例</label>
            <div class="layui-input-block">
                <input type="text" name="bet_example" required lay-verify="bet_example" autocomplete="off" class="layui-input" value="">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">示例号码</label>
            <div class="layui-input-block">
                <input type="text" name="sample_number" required lay-verify="sample_number" autocomplete="off" class="layui-input" value="">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">玩法简介</label>
            <div class="layui-input-block">
                <input type="text" name="introduction" required lay-verify="introduction" autocomplete="off" class="layui-input" value="">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">玩法排序</label>
            <div class="layui-input-inline">
                <input type="number" name="sort" required lay-verify="sort" autocomplete="off" class="layui-input" value="0">
            </div>
            <div class="layui-form-mid layui-word-aux">*越大排位越靠前</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="description" lay-verify="description" id="LAY_demo_editor"></textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                    <a class="layui-btn lay-btn-diy" href="javascript:history.go(-1)">返回</a>
                    <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;
            var editIndex = layedit.build('LAY_demo_editor',{
                uploadImage:{
                    url: '/admin/GamePlay/upload'
                }
            });
            form.verify({
                name: function(value){
                    if(value.length == 0){
                        return '玩法名称不能为空';
                    }
                },
                category:function(value){
                    if(value == ''){
                        return '请选择游戏分类';
                    }
                },
                description: function(value){
                layedit.sync(editIndex);
            }
            });
            //监听提交
            form.on('submit(submitForm)', function (data) {
                return true;
            });
        });
    </script>
@endsection
