@extends('vip.layouts')
@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="{{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" class="Selects" lay-filter="testSelect">
                    <option value="" selected>请选择</option>

                    @foreach ($selectdata as $k=>$v)
                        <option @if( $v["id"]==$select) selected @endif value={{$v["id"]}} }}>{{$v["name"]}}</option>
                    @endforeach
<!--                    <option value="1">新闻</option>
                    <option value="2">公告</option>
                    <option value="3">优惠活动</option>
                    <option value="11" >新手指南</option>
                    <option value="10" >常见问题</option>
                    <option value="20" >彩金活动</option>-->

                </select>
            </div>
        </div>
        @endif

{{--        <div class="layui-form-item dum" style="display: none;">
            <label class="layui-form-label">分类活动</label>
            <div class="layui-input-block">
                <select name="child_id">
                    @foreach ($admin as $k=>$v)
                        <option value="{{ $v['id'] }}">{{ $v['name'] }}</option>
                    @endforeach
                </select>
            </div>
        </div>--}}



        <div class="layui-form-item single" @if(empty($child_id)) style="display: none;  @endif ">

            <label class="layui-form-label">彩金名称</label>
            <div class="layui-input-block">

                <select name="child_id">
                    <option value="0" selected>请选择</option>
                    @foreach ($arr as $k=>$v)
                    <option @if($v['id']==$child_id) selected="selected" @endif value="{{ $v['id'] }}">{{ $v['name'] }}</option>
                    @endforeach

                </select>
            </div>
        </div>


        <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>

        <div class="layui-form-item">
            <label class="layui-form-label">电脑图片</label>
            <div class="layui-input-block">
                <input type="text" name="img"    class="layui-input"
                       value="{{isset($data['img'])?$data['img']:''}}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">手机内容</label>
            <div class="layui-input-block">
                <textarea  name="mobilecontent"  id="myEditortwo" style="width:1000px;height:240px;">{{isset($data['mobilecontent'])?$data['mobilecontent']:''}}</textarea>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">手机图片</label>
            <div class="layui-input-block">
                <input type="text" name="mobileimg"  class="layui-input" value="{{isset($data['mobileimg'])?$data['mobileimg']:''}}">
            </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">
            <label class="layui-form-label">绑定参数</label>
            <div class="layui-input-inline">
                <input type="text" name="typebind"  autocomplete="off" class="layui-input"  value="{{isset($data['typebind'])?$data['typebind']:''}}">
            </div>
            <div class="layui-form-mid layui-word-aux">参数可填写【saveMoneyScanQRcode（存款二维码扫描教程）,saveMoneyTobank（存款到银行卡教程），indexNotice（首页公告）,sign (签到规则说明),chatroomExplain(聊天室说明),openhome(首页活动推荐弹图),shoppingcart(购物车帮助),chathelp(存聊天室的帮助教程)】</div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">排序</label>
            <div class="layui-input-block">
                <input type="text" name="sort" required lay-verify="required" autocomplete="off" class="layui-input"  value="{{isset($data['sort'])?$data['sort']:''}}">

            </div>

        </div>
        <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'], function () {
            var form = layui.form
                , layer = layui.layer
                , layedit = layui.layedit
                , laydate = layui.laydate;
            //图片上传接口
            layedit.set({
                uploadImage: {
                    url: '/admin/notice/upImg' //接口url
                    ,type: 'post' //默认post
                }
            });
            //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('select(testSelect)', function(data){
              //只有在优惠活动下的才会有该选项
               var hui={{$show_hui}}

               if (($.inArray(parseInt(data.value),hui)>-1)||(data.value==3)) {

                    $('.single').show();
               }else{
                   $('.single').hide();
               }

            });

            //监听提交
            form.on('submit(submitForm)', function (data) {
                return true;
            });


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