<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>掌上医院管理后台</title>
    <link rel="stylesheet" th:href="@{/layui/css/layui.css}">
    <link rel="stylesheet" th:href="@{/iconfont/iconfont.css}">
    <link rel="icon" th:href="@{image/sgl.png}" sizes="32x32">
    <script th:src="@{/layui/layui.js}"></script>
    <script th:src="@{/layui/jquery-3.4.1.min.js}"></script>
    <script th:src="@{/js/common.js}"></script>
    <!--<script th:src="@{/js/rem.js}"></script>-->
</head>
<style>
    iframe{width:100%;height:100%;border:0;margin:0;padding:0;}
    body{margin:0;padding:0;}
    .layui-bg-black {
        background-color: #197EFE!important;
    }
    .layui-layout-admin .layui-header {
        background-color: #fff;
        -moz-box-shadow: 0px 0px 10px rgba(215, 215, 215, 1);
        -webkit-box-shadow: 0px 0px 10px rgb(215 215 215);
        box-shadow: 0px 0px 10px rgb(215 215 215);
    }
    .layui-nav{background-color: #197EFE;}
    .layui-nav-child dd{padding-left:20px;}
    .layui-nav-tree .layui-nav-item a:hover{
        background-color: #0070FE;
    }
    .layui-nav-item i{margin-right:5px;}
    .layui-nav-itemed>.layui-nav-child {
        display: block;
        padding: 0;
        background-color: #197EFE !important;
    }
    .layui-nav-tree .layui-nav-child a {
        color: #fff !important;
    }
    .layui-nav .layui-nav-item a{
        color: #fff;
    }
    .layui-nav .layui-nav-more{
        border-top-color: #fff;
    }
    .layui-nav-tree .layui-nav-child dd.layui-this, .layui-nav-tree .layui-nav-child dd.layui-this a, .layui-nav-tree .layui-this, .layui-nav-tree .layui-this>a, .layui-nav-tree .layui-this>a:hover {
        background-color: #0070FE;
        color: #fff;
    }
    .layui-nav .personalUser .layui-nav-more {
        border-top-color: #CCCCCC;
    }
    .layui-input{width:auto;display:inline-block;}
</style>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
    <div class="layui-header">
        <div class="layui-logo" style="background-color: #1A7FFE;color: #fff;">掌上医院管理后台</div>
        <!-- 头部区域（可配合layui已有的水平导航） -->
        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-item">
                <a href="javascript:;" class="personalUser">
                    <img th:src="@{image/user.png}" class="layui-nav-img">
                    <span id="user" style="color: black;">[[${userTrueName}]]</span>
                </a>
                <dl class="layui-nav-child">
                    <dd id="password"><a href="javascript:;" style="color:#333">修改密码</a></dd>
                </dl>
            </li>
            <li class="layui-nav-item" ><a href="/logout" style="color:black;">退出</a></li>
        </ul>
    </div>

    <div class="layui-side layui-bg-black" style="z-index: 1000 !important;">
        <div class="layui-side-scroll">
            <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
            <ul id="menu" class="layui-nav layui-nav-tree"  lay-filter="test">
                <li th:each="menu : ${resourceInfo}" class="layui-nav-item">
                    <a href="javascript:;" >
                        <i th:class="'iconfont '+${menu.attributes.get('LINK_IMG')}" ></i>[[${menu.title}]]
                    </a>
                    <dl class="layui-nav-child">
                        <dd th:each="menu2:${menu.children}" class="dd">
                            <a href="javascript:;" th:url="${menu2.attributes.get('URLS')}" th:text="${menu2.title}"></a>
                        </dd>
                    </dl>
                </li>
            </ul>
        </div>
    </div>

    <div class="layui-body" style="bottom:0;overflow:hidden;">
        <!-- 内容主体区域 -->
        <iframe id="contain" src="/home"></iframe>
    </div>

    <div id="modifyPassword" style="display:none;">
        <form id="indexPassword" class="" style="margin-top:20px;">
            <input type="hidden" id="username" th:value="${userName}" >
            <div class="layui-form-item">
                <label class="layui-form-label">新密码:</label>
                <div class="layui-input-block">
                    <input type="password"  id="onePassword" required lay-verify="required" autocomplete="off" placeholder="请输入密码" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">确认新密码:</label>
                <div class="layui-input-block">
                    <input type="password"  id="twoPassword" required lay-verify="required" autocomplete="off" placeholder="请输入密码" class="layui-input">
                </div>
            </div>
        </form>
    </div>
</div>

<script>
    //JavaScript代码区域
    var element,layer;
    layui.use(['element','layer'], function(){
        element = layui.element;
        layer = layui.layer;

        $("#password").on('click',function(){
            $("#onePassword").val("");
            $("#twoPassword").val("");
            layer.open({
                type : 1,
                title : "修改密码",
                shade : 0,
                area : [ '350px', '240px' ],
                offset : 'auto',
                content : $("#modifyPassword"),
                btn : [ '确定', '取消' ],
                btnAlign : 'c',
                yes : function(index, layero) {

                    var onePassword = $("#onePassword").val();
                    var twoPassword = $("#twoPassword").val();
                    if(onePassword==null || onePassword==""){
                        layer.msg('请输入密码',{time:1000},function(){
                            $("#onePassword").focus();
                        });
                        return;
                    }
                    if(twoPassword==null || twoPassword==""){
                        layer.msg('请再次输入密码',{time:1000},function(){
                            $("#twoPassword").focus();
                        });
                        return;
                    }
                    if(!isValuse(onePassword)){
                        layer.msg('密码必须包含字母数字特殊符号，且长度至少为8位',{time:1000});
                        return;
                    }
                    if(!isValuse(twoPassword)){
                        layer.msg('密码必须包含字母数字特殊符号，且长度至少为8位',{time:1000});
                        return;
                    }

                    if(onePassword == twoPassword){

                        var url="/modifyPassword";
                        var param={};
                        param.username=$("#username").val();
                        param.password=onePassword;
                        AjaxPostJson(url,param,function(data){
                            if (data.state == true) {
                                layer.msg(data.message, {
                                    time : 1000
                                },function(){
                                    layer.closeAll();
                                });
                            } else {
                                layer.msg(data.message, {
                                    time : 1000
                                });
                            }
                        });
                    }else{
                        layer.msg('密码输入不一致',{time:1000});
                        return;
                    }
                },
                btn2 : function() {}
            });
        });
    });

    $(function(){
        $("#menu li").eq(0).addClass("layui-nav-itemed");
        $(".dd a").click(function(){
            var url = $(this).attr("url");
            $("#contain").attr("src",url)
        })
    })

</script>
<script>
    function handleResize() {
        var htmlWidth = document.documentElement.clientWidth|| document.body.clientWidth
        let htmlDom=document.getElementsByTagName('html')[0]
        htmlDom.style.fontSize= 100 / 1920 * htmlWidth + 'px';
    }
    handleResize();
    window.onresize = handleResize;
</script>
</body>
</html>
