<title>设置我的密码</title>

<div class="layui-card layadmin-header">
    <div class="layui-breadcrumb" lay-filter="breadcrumb">
        <a lay-href="">主页</a>
        <a><cite>设置</cite></a>
        <a><cite>我的密码</cite></a>
    </div>
</div>

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">修改密码</div>
                <div class="layui-card-body" pad15>

                    <div class="layui-form" lay-filter="LAY-app-CoreCmsSms-editLoginUserPassWord" id="LAY-app-CoreCmsSms-editLoginUserPassWord">
                        <div class="layui-form-item">
                            <label class="layui-form-label">当前密码</label>
                            <div class="layui-input-inline">
                                <input type="password" name="oldPassword" lay-verType="tips" lay-verify="required" lay-verType="tips" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">新密码</label>
                            <div class="layui-input-inline">
                                <input type="password" name="password" lay-verify="pass" lay-verType="tips" autocomplete="off" id="LAY_password" class="layui-input">
                            </div>
                            <div class="layui-form-mid layui-word-aux">6到16个字符</div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">确认新密码</label>
                            <div class="layui-input-inline">
                                <input type="password" name="repassword" lay-verify="repass" lay-verType="tips" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit lay-filter="LAY-app-CoreCmsSms-editLoginUserPassWord-setPassSubmit">确认修改</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    layui.use(['admin', 'form', 'laydate', 'coreHelper'],
        function () {
            var $ = layui.$, form = layui.form, admin = layui.admin, laydate = layui.laydate, coreHelper = layui.coreHelper;
            //重载form
            form.render(null, 'LAY-app-CoreCmsSms-editLoginUserPassWord');

            //监听提交
            form.on('submit(LAY-app-CoreCmsSms-editLoginUserPassWord-setPassSubmit)',
                function (data) {
                    var field = data.field; //获取提交的字段
                    //提交 Ajax 成功后，关闭当前弹层并重载表格
                    coreHelper.Post("Api/Tools/EditLoginUserPassWord", field, function (e) {
                        console.log(e)
                        if (e.code === 0) {
                            layer.msg('修改成功,请重新登录...', { time: 2000 },
                                function () {
                                    admin.exit();
                                });
                        } else {
                            layer.msg(e.msg);
                        }
                    });
                });

        });
</script>