
@extends('vip.layouts')
<link href={{ asset("baidu/themes/default/css/umeditor.css") }} type="text/css" rel="stylesheet">
@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']))
                            @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-inline">
                <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-block">
                <input type="text" name="code" required lay-verify="code" autocomplete="off" class="layui-input" value="{{isset(
      $data['code'])?$data['code']:''}}">
            </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="{{isset(
      $data['bet_example'])?$data['bet_example']:''}}">
            </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="{{isset(
      $data['sample_number'])?$data['sample_number']:''}}">
            </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="{{isset(
      $data['introduction'])?$data['introduction']:''}}">
            </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="{{isset(
      $data['sort'])?$data['sort']:'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 name="description" lay-verify="content"
                    rows="80"  cols="150"    id="LAY_demo_editor">{{isset($data['description'])?$data['description']:''}}</textarea>
            </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">{{isset($data['description'])?$data['description']:''}}</textarea>
            </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 type="text/javascript" src={{ asset("baidu/third-party/jquery.min.js") }}></script>
    <script type="text/javascript" charset="utf-8" src={{ asset("baidu/umeditor.config.js") }}></script>
    <script type="text/javascript" charset="utf-8" src={{ asset("baidu/umeditor.min.js") }}></script>
    <script type="text/javascript" src={{ asset("baidu/lang/zh-cn/zh-cn.js") }}></script>
    <script>
        //Demo
        var um = UM.getEditor('LAY_demo_editor');
        layui.use(['form', 'layedit', 'laydate'], function () {
            var form = layui.form
                , layer = layui.layer
                , layedit = layui.layedit
                , laydate = layui.laydate;

//            var editIndex = layedit.build('LAY_demo_editor');
            form.verify({
                title: function(value){
                    if(value.length < 5){
                        return '标题至少得5个字符啊';
                    }
                }
                ,pass: [/(.+){6,12}$/, '密码必须6到12位']
//                ,content: function(value){
////                    layedit.sync(editIndex);
//                }
            });
            //监听提交
            form.on('submit(submitForm)', function (data) {
                return true;
            });


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

    </script>

    <script>
        //Demo
        layui.use(['form','layedit','laydate','upload'], function () {
            var form = layui.form
                , layer = layui.layer
                , layedit = layui.layedit
                , laydate = layui.laydate;
            /*layedit.set({
                uploadImage: {
                    url: '/admin/GamePlay/upload' //接口url
                }
            });*/
            // 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
