@extends('vip.layouts254js')
@section('content')
    <link href={{ asset("baidu/themes/default/css/umeditor.css") }} type="text/css" rel="stylesheet">
    <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="title" required lay-verify="required" autocomplete="off" class="layui-input"
                       value="体育">
            </div>
        </div>
        @if(isset($select))
            <div class="layui-form-item">
                <label class="layui-form-label">所属类别</label>
                <div class="layui-input-block">
                    <select name="type" id="testSelect" class="Selects" lay-filter="testSelect">
                        <option value="" selected>请选择</option>
                        <option value="1" @if (isset($data['group_id']) && $data['group_id']==1 )  selected  @endif>一般体育说明</option>
                        <option value="2" @if (isset($data['group_id']) && $data['group_id']==2 )  selected  @endif>冠军</option>
                        <option value="3" @if (isset($data['group_id']) && $data['group_id']==3 )  selected  @endif>连串过关/复式过关</option>
                        <option value="4" @if (isset($data['group_id']) && $data['group_id']==4 )  selected  @endif>独赢及位置</option>
                        <option value="5" @if (isset($data['group_id']) && $data['group_id']==5 )  selected  @endif>提前结算</option>
                        <option value="11" @if (isset($data['group_id']) && $data['group_id']==11 )  selected  @endif>足球</option>
                        <option value="12" @if (isset($data['group_id']) && $data['group_id']==12 )  selected  @endif>篮球</option>
                        <option value="13" @if (isset($data['group_id']) && $data['group_id']==13 )  selected  @endif>网球</option>
                        <option value="14" @if (isset($data['group_id']) && $data['group_id']==14 )  selected  @endif>棒球</option>
                    </select>
                </div>
            </div>
        @endif

        <div class="layui-form-item">
            <label class="layui-form-label">具体内容</label>
            <div class="layui-input-block">
                <textarea name="desc" id="myEditor"
                          style="width:1000px;height:240px;">{{isset($data['content'])?$data['content']:''}}</textarea>
            </div>
        </div>
      
        @if(isset($list))
            <div class="layui-form-item">
                <label class="layui-form-label">作者</label>
                <div class="layui-input-block">
                    <input type="text" name="author" required lay-verify="required" autocomplete="off"
                           class="layui-input" value="{{isset($data['author'])?$data['author']:''}}">
                </div>
            </div>
        @endif

        <div class="layui-form-item">
            <div class="layui-input-block">
                @if(checkRriv('/admin/Notice/view'))
                    <button class="layui-btn" lay-submit lay-filter="submitForm">立即提交</button>@endif
                <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
        layui.use(['form', 'layedit', 'laydate', 'upload'], function () {
            var form = layui.form
                , layer = layui.layer
                , layedit = layui.layedit
                , laydate = layui.laydate
                , upload = layui.upload;
            //图片上传接口
            layedit.set({
                uploadImage: {
                    url: '/admin/notice/upImg' //接口url
                    , type: 'post' //默认post
                }
            });

            upload.render({
                elem: '#test1' //绑定元素
                , url: '/admin/notice/upImg' //上传接口
                , headers: {"X-CSRF-TOKEN": "{{ csrf_token() }}"}
                , done: function (res) {
                    if (res.code == 0) {
                        $("#img").val(res.data.src);
                        layer.msg("上传图片成功!", {icon: 1});
                    } else {
                        layer.msg("上传图片发生错误!", {icon: 5});
                    }
                }
                , error: function () {
                    console.log('upload img error');
                }
            });

            //执行实例
            upload.render({
                elem: '#test2' //绑定元素
                , url: '/admin/notice/upImg' //上传接口
                , headers: {"X-CSRF-TOKEN": "{{ csrf_token() }}"}
                , done: function (res) {
                    if (res.code == 0) {
                        $("#mobileimg").val(res.data.src);
                        layer.msg("上传图片成功!", {icon: 1});
                    } else {
                        layer.msg("上传图片发生错误!", {icon: 5});
                    }
                }
                , error: function () {
                    console.log('upload img error');
                }
            });

            //var um = UM.getEditor('myEditor');
            var um = UM.getEditor('myEditor', {
                initialFrameWidth: 1000,
                initialFrameHeight: 400
            });
            var umtwo = UM.getEditor('myEditortwo', {
                initialFrameWidth: 1000,
                initialFrameHeight: 400
            });
            /*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;
            });


        });

        //创建一个编辑器
        function cbFormSuccess(data) {
            layer.msg(data.msg);
            setTimeout(function () {
                window.history.go(-1)
            }, 2500);
        }
    </script>
@endsection
