@extends('Merchant::layouts.app')
@section('title', '修改密码')

@section('content')
<form class="form-horizontal" method="post" action="{{ route('merchant.setting.password') }}">

    <div class="form-group">
        <label class="col-xs-3 control-label">新密码</label>
        <div class="col-xs-8">
            <input type="password" class="form-control" value="" name="password">
        </div>
    </div>
    <div class="form-group">
        <label class="col-xs-3 control-label">确认密码</label>
        <div class="col-xs-8">
            <input type="password" class="form-control" value="" name="password_confirmation">
        </div>
    </div>
    <div class="form-group">
        <div class="col-xs-offset-3 col-xs-8">
            @csrf

            <button class="btn btn-primary btn-block ajax" type="button">
                <i class="icon icon-check"></i> 保存
            </button>
        </div>
    </div>
</form>
@endsection


@push('script')
    <script type="text/javascript">
    $('body').on('click', '.ajax', function(event) {
        if ($(this).hasClass('disabled') || $(this).attr('disabled')) {
            return false;
        };
        event.preventDefault();
        var $this   = $(this);
        var $form   = $this.parents('form');
        var $action = $form.attr("action");

        $this.attr('disabled', 'disabled');
        var query = $form.serialize();
        $.post($action, query, function(res) {
            $this.removeAttr('disabled');
            if (res.code) {
                parent.updateAlert(res.msg, res.code, function() {
                    var index = parent.layer.getFrameIndex(window.name);
                    parent.layer.close(index);
                });
            } else {
                parent.updateAlert(res.msg, res.code);
            }
        });
    });
</script>
@endpush
