@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="title" required lay-verify="required" autocomplete="off" class="layui-input"
                       value="{{isset(
      $data['title'])?$data['title']:''}}">
            </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">
                        <option  value="">请选择</option>
                        <option  value="1" selected>系统信息</option>
                        <option  value="2">普通信息</option>
                        {{--<option  value="3">会员组</option>--}}
                        <option  value="3">系统信息</option>
                        <option  value="4">管理员通知</option>
                    </select>
                </div>
            </div>
        @endif


        {{--@if(isset($select))--}}
        {{--<div class="layui-form-item">--}}
            {{--<label class="layui-form-label">发送选择类型</label>--}}
            {{--<div class="layui-input-block">--}}
                {{--<select name="type" id="testSelect">--}}
                    {{--<option  value="">请选择</option>--}}
                    {{--<option  value="1" selected>在线会员</option>--}}
                    {{--<option  value="2">所以会员</option>--}}
                    {{--<option  value="3">会员组</option>--}}
                    {{--<option  value="4">自己选择</option>--}}
                {{--</select>--}}
            {{--</div>--}}
        {{--</div>--}}
        {{--@endif--}}


        <div class="layui-form-item" id="label">
            <label class="layui-form-label">接收者</label>
            <div class="layui-input-block">
                <input type="text" name="toname"   autocomplete="off" class="layui-input" value="{{isset(
      $data['toname'])?$data['toname']:''}}">
                <p style="color: red">(选择普通消息时，填写名字请用‘，’分开)</p>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">发布者</label>
            <div class="layui-input-block">
                <input type="text" name="formname"  autocomplete="off" class="layui-input" value="{{isset(
      $data['formname'])?$data['formname']:''}}">
                <p style="color: red">(选择普通消息时，必须填写发布者)</p>
            </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="desc" lay-verify="content"
                          id="LAY_demo_editor">{{isset($data['content'])?$data['content']:''}}</textarea>
            </div>
        </div>


        <div class="layui-form-item">
            <div class="layui-input-block">
                @if(!isset($data['toname']))
                @if(checkRriv('/admin/Message/view'))<button class="layui-btn" lay-submit lay-filter="submitForm">立即提交</button>@endif
                <button type="reset" class="layui-btn layui-btn-normal">重置</button>
                    @else

                @endif
            </div>
        </div>


    </form>

    <script>

        //Demo
        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;
            });


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