@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-inline">
                <select name="chatRoom" id="chatRoom" lay-verify="required" required autocomplete="off" eventType="event-query" class="layui-input">
                    <option  value="">选择房间</option>
                    @if(isset($chatRoom) && is_array($chatRoom))
                        @foreach($chatRoom as $k=>$v):
                            <option value="{{$v['id']}}">{{$v['room_name']}}</option>
                        @endforeach
                    @endif
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">红包金额</label>
            <div class="layui-input-inline">
                <input type="number" name="red_money" id="red_money" required lay-verify="required" autocomplete="off" class="layui-input" value="0">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">红包数量</label>
            <div class="layui-input-inline">
                <input type="text" name="red_num"  id="red_num" 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-block">
                <input type="text" name="red_mark" id="red_mark" lay-verify="" 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="radio" name="status" value="1" title="是" checked>
                <input type="radio" name="status" value="0" title="否">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">扣除资金账户</label>
            <div class="layui-input-block">
                <input type="text" name="username" id="red_mark" lay-verify="" autocomplete="off" class="layui-input" value="" placeholder="请填写扣除红包金额的账户">
            </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>
        //Demo
        layui.use(['form', 'layedit', 'laydate'], function () {
            var form = layui.form;

            form.verify({
                chatRoom: function(value){
                    if(value.length == 0){
                        return '请选择房间';
                    }
                },
                vip: function(value){
                    if(value.length == 0){
                        return '请选择等级';
                    }
                },
                red_num: function(value){
                    if(value.length == 0){
                        return '请选择等级';
                    }
                },
                red_money: function(value){
                    if(value.length == 0){
                        return '请选择等级';
                    }
                }
            });
            //监听提交
            form.on('submit(submitForm)', function (data) {
                return true;
            });
        });

    </script>
@endsection
