@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-group" style="margin-top: 5px">
                                    <label for="exampleInputName1">
                                       <h5> *请修改或添加IP白名单：</h5>  <br>
                                        {{ __('auto.请编辑IP白名单') }} {{ __('auto.注：每个ip白名单格式用英文') }} , {{ __('auto.分开') }}
                                    </label>&nbsp;&nbsp;

                                    <input type="text" style="color: black;width: 500px;" class="form-control required" name="ip" placeholder="{{ __('auto.输入') }}IP" value="{{$info->ip ?? ''}}">
                                </div>
                                <input type="hidden" name="config_id" value="{{$info->id}}">
                                <div class="form-group" style="margin-top: 5px">
                                    <label for="exampleInputName1">*备注：</label>&nbsp;&nbsp;
                                    <textarea name="remarks" id="" cols="30" rows="10" class="form-control">{{$info->remarks ?? ''}}</textarea>
                                </div>
                                <button type="button" onclick="commit({{$info->id}})" 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(id){
            if(!checkForm()){
                return false;
            }
            var data = $("#form").serializeObject();
            myRequest("/admin/recharge/ip_white_update/"+id,"post",data,function(res){
                layer.msg(res.msg)
                if(res.code == 200){
                    setTimeout(function(){
                        parent.location.reload();
                    },1500)
                }
            });
        }
        function cancel() {
            parent.location.reload();
        }
    </script>
@endsection
