@extends('base.base')
@section('base')
    <!-- 内容区域 -->
    <div class="main-panel">
        <div class="content-wrapper">
            <div class="row">
                <div class="col-12 grid-margin stretch-card">
                    <div class="card">
                        <div class="card-body">
                            <h4 class="card-title">{{ __('auto.请编辑兑换码内容') }}</h4>
                            {{--<p class="card-message">--}}
                            {{--Basic form elements--}}
                            {{--</p>--}}
                            <form class="forms-sample" id="form">
                                    <div class="form-inline">
                                        <label for="exampleInputName1">*奖品类型：</label>&nbsp;&nbsp;
                                        <select class="form-control required" name="batch" style="color: black;width: 500px;">
                                            <option value="">{{ __('auto.请选择种类') }}</option>
                                            @foreach($list as $k=>$v)
                                                <option value="{{$v->id}}">{{$v->desc}}</option>
                                            @endforeach
                                        </select>
                                    </div>
                                    <div class="form-inline" style="margin-top: 5px">
                                        <label for="exampleInputName1">*过期时间：</label>&nbsp;&nbsp;
                                        <input type="date"  step="01" name="time" class="form-control required"/>&nbsp;&nbsp;
                                    </div>
                                    <div class="form-inline" style="margin-top: 5px">
                                        <label for="exampleInputName1">*兑换码数量：</label>&nbsp;&nbsp;
                                        <input type="text" style="color: black;width: 500px;" class="form-control required" name="number" placeholder="{{ __('auto.输入兑换码数量') }}">
                                    </div>
                                    <div class="form-inline" style="margin-top: 5px">
                                        <label for="exampleInputName1">*兑换限制：</label>&nbsp;&nbsp;
                                        <label><input name="limit" type="radio" value="0" />{{ __('auto.无限制') }} </label> 
                                        <label><input name="limit" type="radio" value="1" />{{ __('auto.仅新用户') }} </label> 
                                    </div>
                                    <button type="button" onclick="commit()" class="btn btn-sm btn-gradient-primary btn-icon-text">
                                        <i class="mdi mdi-file-check btn-icon-prepend"></i>
                                        {{ __('auto.提交') }}
                                    </button>
                                    <button type="button" onclick="cancel()" class="btn btn-sm btn-gradient-warning btn-icon-text">
                                        <i class="mdi mdi-reload btn-icon-prepend"></i>
                                        {{ __('auto.取消') }}
                                    </button>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script>
        function commit(){
            if(!checkForm()){
                return false;
            }
            var data = $("#form").serializeObject();
            myRequest("/admin/code/add","post",data,function(res){
                layer.msg(res.msg)
                setTimeout(function(){
                    parent.location.reload();
                },1500)
            });
        }
        function cancel() {
            parent.location.reload();
        }
    </script>
@endsection
