@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>
                            <form class="forms-sample" id="form">

                                <div class="form-group">
                                    <label>{{ __('auto.修改头像') }}</label>
                                    <input type="file" class="file-upload-default img-file" data-path="avatar">
                                    <input type="hidden" name="avatar" class="image-path" value="{{$admin->avatar}}">
                                    <div class="input-group col-xs-12">
                                        <input type="text" class="form-control file-upload-info" disabled="" value="{{$admin->avatar}}" placeholder="{{ __('auto.选择图片') }}">
                                        <span class="input-group-append">
                                            <button class="file-upload-browse btn btn-gradient-primary" onclick="upload($(this))" type="button">{{ __('auto.上传') }}</button>
                                        </span>
                                    </div>
                                    <div class="img-yl" style="display: block;">
                                        <img src="{{$admin->avatar}}">
                                    </div>
                                </div>

                                <div class="form-group">
                                    <label for="nickname">*{{__('auto.昵称')}}</label>
                                    <input type="text"  class="form-control required" name="nickname" value="{{$admin->nickname}}">
                                </div>

                                <div class="form-group">
                                    <label for="locale">*{{__('auto.语言')}}Lang</label>
                                    <select id="locale" name="locale"  class="form-control form-control-lg"  >
                                        <option value="zh_CN"
                                            @if ($admin->locale=='zh_CN')
                                            selected="selected"
                                            @endif
                                        >中文</option>
                                        <option value="en_US"
                                                @if ($admin->locale=='en_US')
                                                    selected="selected"
                                            @endif
                                        >English</option>
                                    </select>
                                </div>

                                <div class="form-group">
                                    <label for="password">*{{__('auto.密码')}}</label>
                                    <input type="password" id="password"  class="form-control" name="password" value="{{$admin->clear_password}}">
                                </div>

                                <div class="form-group">
                                    <label for="password">*{{__('auto.确认密码')}}</label>
                                    <input type="password" id="password_verify"  class="form-control" name="password_verify" value="{{$admin->clear_password}}">
                                </div>

                                <button type="button" onclick="commit({{$admin->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($("#password").val() != $("#password_verify").val()){
                layer.msg('{{ __('auto.两次密码输入不一致') }}', function(){});
            }
            if(!checkForm()){
                return false;
            }
            var data = $("#form").serializeObject();
            myRequest("/edit/info/"+id,"post",data,function(res){
                if(res.code == '200'){
                    layer.msg(res.msg)
                    setTimeout(function(){
                        parent.location.reload();
                    },1500)
                }else{
                    layer.msg(res.msg)
                }
            });
        }
        function cancel() {
            parent.location.reload();
        }
    </script>
@endsection
