<%@ page language="java" contentType="text/html;charset=UTF-8" trimDirectiveWhitespaces="true"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fastboot" prefix="fb"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://shiro.apache.org/tags" prefix="shiro"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<shiro:notAuthenticated>
    <%
        response.sendRedirect("/login");
    %>
</shiro:notAuthenticated>
<fb:ui src="base/main">

    <fb:property name="title"><spring:message code="admin.change_password"/></fb:property>

    <fb:script type="text/javascript">
        <script>
            layui.use(['tool', 'form', 'nipt', 'sug'], function () {
                // 操作对象
                var $ = layui.$, tool = layui.tool, form = layui.form

                // 监听提交
                form.on('submit(go)', function (data) {
                    tool.post('${base}/admin/submitUpdatePassword', $("#inputForm").serializeArray(),function (data) {
                        console.log(data)
                        if(data.code === 0){
                            layer.msg("ok");
                        }else{
                            layer.msg(data.msg);
                        }
                    })
                    return false
                });
            });
        </script>

    </fb:script>

    <fb:layout>

        <div class="layui-card">

            <form id="inputForm" class="layui-form layui-form-pane" action="" lay-filter="inputForm">

                <div class="layui-form-item">
                    <label class="layui-form-label"><spring:message code="account"/></label>
                    <div class="layui-input-block">
                        <label class="layui-form-label">${user.username}</label>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label"><spring:message code="old_password"/></label>
                    <div class="layui-input-inline">
                        <input type="password" id="oldPassword" name="oldPassword" value=""  class="layui-input" >
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label"><spring:message code="new_password"/></label>
                    <div class="layui-input-inline">
                        <input type="password" id="newPassword" name="newPassword"  value="" class="layui-input" >
                    </div>
                </div>

                <button class="layui-btn" id="submit" lay-submit lay-filter="go"   ><spring:message code="submit"/></button>
                <button type="reset" class="layui-btn"><spring:message code="reset"/></button>
            </form>
        </div>
    </fb:layout>
</fb:ui>