@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" name="goods_type" style="color: black;width: 500px;">
                                            <option value="">{{ __('auto.请选择种类') }}</option>
                                            @foreach($goods_type as $k=>$v)
                                                <option value="{{$k}}">{{$v}}</option>
                                            @endforeach
                                        </select>
                                    </div>
                                    <div class="form-inline" style="margin-top: 5px">
                                        <label for="exampleInputName1">*商品类型：</label>&nbsp;&nbsp;
                                        <select class="form-control" name="bonus" style="color: black;width: 500px;">
                                            <option value="">{{ __('auto.请选择类型') }}</option>
                                            @foreach($bonus as $k=>$v)
                                                <option value="{{$k}}">{{$v}}</option>
                                            @endforeach
                                        </select>
                                    </div>
                                    <div class="form-inline" style="margin-top: 5px">
                                        <label for="exampleInputName1">*道具类型：</label>&nbsp;&nbsp;
                                        <select class="form-control" name="prop_type" style="color: black;width: 500px;">
                                            <option value="">{{ __('auto.请选择类型') }}</option>
                                            @foreach($prop_type as $k=>$v)
                                                <option value="{{$k}}">{{$v}}</option>
                                            @endforeach
                                        </select>
                                    </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="amount" placeholder="{{ __('auto.输入商品数量') }}">
                                    </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="title" placeholder="{{ __('auto.输入商品名称') }}">
                                    </div>
                                    <div class="form-inline" style="margin-top: 5px">
                                        <label for="exampleInputName1">*商品权重：</label>&nbsp;&nbsp;
                                        <input type="number" min="0" value="0" style="color: black;width: 500px;" class="form-control required" name="order" placeholder="{{ __('auto.输入商品排序') }}">
                                    </div>
                                    <div class="form-inline" style="margin-top: 5px">
                                        <label for="exampleInputName1">*选择标签：</label>&nbsp;&nbsp;
                                        <select class="form-control" name="status" style="color: black;width: 500px;">
                                            <option value="">{{ __('auto.请选择标签') }}</option>
                                            @foreach($status as $k=>$v)
                                                <option value="{{$k}}">{{$v}}</option>
                                            @endforeach
                                        </select>
                                    </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="ratio" placeholder="{{ __('auto.输入兑换价格') }}">
                                    </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="money" placeholder="{{ __('auto.输入商品价格') }}({{ __('auto.道具类型为红包时必填，其余类型为') }}0)">
                                    </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="total_amount" placeholder="{{ __('auto.输入商品库存') }}">
                                    </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="day_limit" placeholder="{{ __('auto.输入每日限额') }}">
                                    </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="pic_url" placeholder="{{ __('auto.输入商品图片地址') }}">
                                    </div>
                                    <div class="form-inline" style="margin-top: 5px">
                                        <label for="exampleInputName1">*商品描述：</label>&nbsp;&nbsp;
                                        <textarea style="color: black;width: 500px;" class="form-control required" name="describe" rows="4" placeholder="{{ __('auto.输入商品描述') }}"></textarea>
                                    </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="sort" placeholder="输入商品顺序">
                                    </div> -->
                                    <div class="form-inline" style="margin-top: 5px">
                                        <label for="exampleInputName1">*结束时间：</label>&nbsp;&nbsp;
                                        <input type="datetime-local" style="color: black;width: 500px;" name="time" class="form-control required" />
                                    </div>
                                    <div class="form-inline" style="margin-top: 5px">
                                        <label for="exampleInputName1">{{ __('auto.卡券名称：') }}</label>&nbsp;&nbsp;
                                        <input type="text" style="color: black;width: 500px;" class="form-control" name="prop_name" placeholder="{{ __('auto.输入卡券名称，商品分类为卡券时必填') }}"></input>
                                    </div>
                                    <div class="form-inline" style="margin-top: 5px">
                                        <label for="exampleInputName1">{{ __('auto.卡券描述：') }}</label>&nbsp;&nbsp;
                                        <input type="text" style="color: black;width: 500px;" class="form-control" name="prop_desc" placeholder="{{ __('auto.输入卡券描述，商品分类为卡券时必填') }}"></input>
                                    </div>
                                    <div class="form-inline" style="margin-top: 5px">
                                        <label for="exampleInputName1">{{ __('auto.商家地址：') }}</label>&nbsp;&nbsp;
                                        <input type="text" style="color: black;width: 500px;" class="form-control" name="prop_address" placeholder="{{ __('auto.输入商家地址，商品分类为卡券时必填') }}"></input>
                                    </div>
                                    <div class="form-inline" style="margin-top: 5px">
                                        <label for="exampleInputName1">{{ __('auto.联系方式：') }}</label>&nbsp;&nbsp;
                                        <input type="text" style="color: black;width: 500px;" class="form-control" name="prop_phone" placeholder="{{ __('auto.输入联系方式，商品分类为卡券时必填') }}"></input>
                                    </div>
                                    <div class="form-inline" style="margin-top: 5px">
                                        <label for="exampleInputName1">{{ __('auto.商家名称：') }}</label>&nbsp;&nbsp;
                                        <input type="text" style="color: black;width: 500px;" class="form-control" name="prop_business" placeholder="{{ __('auto.输入商家名称，商品分类为卡券时必填') }}"></input>
                                    </div>
                                    <div class="form-inline" style="margin-top: 5px">
                                        <label for="exampleInputName1">{{ __('auto.过期时间（天）：') }}</label>&nbsp;&nbsp;
                                        <input type="text" style="color: black;width: 500px;" class="form-control" name="expiring_date" placeholder="{{ __('auto.输入过期时间') }}">
                                    </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/shop_goods/add/","post",data,function(res){
                layer.msg(res.msg)
                setTimeout(function(){
                    if(res.code==200){
                        parent.location.reload();
                    }
                },1500)
            });
        }
        function cancel() {
            parent.location.reload();
        }
    </script>
@endsection
