<!--#layout("/common/container.html"){  -->
  <!-- 顶部 -->
  <form class="layui-form layui-form-pane">
  <div class="layui-header">
    <a href="ibeetl.com" class="layui-hide-xs"><div class="layui-logo">${env("app.name")}</div></a>
    <a href="javascript:" class="layui-hide-xs"><div class="fsSwitchMenu"><i class="iconfont icon-category"></i></div></a>
      <script src="${ctxPath}/js/lib-js.js"></script>
      <script src="${ctxPath}/js/pass.js"></script>
    <!-- 顶部菜单 -->
    <ul class="layui-nav layui-layout-left fsTopMenu" id="fsTopMenu" lay-filter="fsTopMenu">
      <!--#for(node in menus.children){  -->
      <li class="layui-nav-item ${nodeLP.first?'layui-this'}" dataPid="${node.data.id}"><a href="javascript:"><i class="layui-icon">${node.data.icon}</i>
      <!--#if(nodeLP.first){  -->
      <cite>${node.data.name}</cite>
      <!--#}else{  -->
      ${node.data.name}
      <!--#}  -->
      </a></li>
      <!--#} -->
    </ul>
    
    <ul class="layui-nav layui-layout-right">
      <li class="layui-nav-item layui-hide-xs">
        <a href="javascript:">
         	${session["core:user"].name}
        </a>
        <dl class="layui-nav-child">
          <dd><a href="javascript:">基本资料</a></dd>
          <dd id="changeCompanyButton"><a href="javascript:">${session["core:currentOrg"].name}</a>
          </dd>
           <dd id="updatePasswordButton" ><a href="javascript:" >修改密码</a>
           
           		<!-- <layui:accessButton function="user.password" action="changePassword">修改密码</layui:accessButton> -->
           
<!--            <dd id="updatePasswordButton"><a href="/GAA/user/changePassword.do?id=${session['core:user'].id} "  action="changePassword" >修改密码</a> -->
           		
         <!--   <layui:accessButton function="user.password" action="changePassword">修改密码</layui:accessButton> -->
          </dd>
        </dl>
      </li>
      <li class="layui-nav-item layui-hide-xs"><a href="/logout.do"><i class="iconfont icon-tuichu"></i> 退出</a></li>
    </ul>
  </div>

<script type="text/javascript">


	 function getMess(message, data){
        var keyHex = CryptoJS.enc.Utf8.parse(data);
        var encrypted = CryptoJS.DES.encrypt(message, keyHex, {
            mode: CryptoJS.mode.ECB,
            padding: CryptoJS.pad.Pkcs7
        });
        return encrypted.ciphertext.toString().toUpperCase();
    };


	var id = ${session["core:user"].id};
	var pas = "${session["core:user"].password}";
	 var pwdRegex = new RegExp('(?=.*[0-9])(?=.*[A-Z])(?=.*[a-z])(?=.*[^a-zA-Z0-9]).{8,}');
	$("#updatePasswordButton").click(function(){
		var showdd=['确定', '取消'];
		showupdatepwd(showdd);
	});



	function showupdatepwd(buttonshow) {
		layer.open({
			type: 1
			,title: "修改密码" //不显示标题栏
			,closeBtn: false
			,area: ['500px', '500px']
			,shade: 0.8
			,id: 'LAY_layuipro' //设定一个id，防止重复弹出
			,resize: false
			,btn: buttonshow
			,btnAlign: 'c',
			success: function (layero, index) {//打开层之后可执行的回调
				layui.use(['form', 'layer'], function () {
					var form = layui.form;
					var layer = layui.layer;

					form.render();  //重新渲染表单
				});
			}
			,moveType: 1 //拖拽模式，0或者1
			,content: $("#passwordInfos")

			,yes: function (index, layero) { //确定按钮
				var con = {};
				//con.userId = userId.id;

				con.oldPassword = $("#oldPassword").val();
				con.password = $("#password").val();
				con.password2 = $("#password2").val();
				var p2 = con.password2;
				var p = con.password;
				var data = getPass();
				var newp = getMess(con.password2,data);

				//con.oldPassword =  getMess(con.oldPassword,data);
				con.password =  getMess(con.password,data);
				con.password2 =  getMess(con.password2,data);

				con.id =  id;
				if(con.oldPassword.length==0){
					$("#mopwd-aux").css({
						display: "block",
						color: "#ff1010",
					}).html("请输入原密码")
				}else{
					if (pas != con.oldPassword) {
						$("#mopwd-aux").css({
							display: "block",
							color: "#ff1010",
						}).html("密码不正确")
					} else {
						$("#mopwd-aux").css({
							display: "block",
							color: "#5FB878"
						}).html("输入正确")
					}


				}
				var flag = pwdRegex.test(p);
				var flag2 = pwdRegex.test(p2);
				if (con.password == 0) {
					$("#newpwd1-aux").css({
						display: "block",
						color: "#ff1010"
					}).html("请输入新密码")
				}else {
					$("#newpwd1-aux").css({
						display: "block",
						color: "#5FB878"
					}).html("输入正确")
				}
				if (flag == false && flag2 == false){
					$("#newpwd2-aux").css({
						display: "block",
						color: "#ff1010"
					}).html("新的密码复杂度太低（密码中必须包含大小写字母、数字、特殊字符），请重新输入新密码")
					$("#newpwd1-aux").css({
						display: "block",
						color: "#ff1010"
					}).html("新的密码复杂度太低（密码中必须包含大小写字母、数字、特殊字符），请重新输入新密码")

				}else{
					if (con.password2 == 0) {
						$("#newpwd2-aux").css({
							display: "block",
							color: "#ff1010"
						}).html("请输入新密码")
					} else if (con.password != con.password2) {
						$("#newpwd2-aux").css({
							display: "block",
							color: "#ff1010"
						}).html("两次输入不一致")
						$("#newpwd1-aux").css({
							display: "block",
							color: "#ff1010"
						}).html("两次输入不一致")

					} else if (con.password2 == con.password && password == pas) {
						$("#newpwd2-aux").css({
							display: "block",
							color: "#ff1010"
						}).html("新密码不能与原密码相同")
						$("#newpwd1-aux").css({
							display: "block",
							color: "#ff1010"
						}).html("新密码不能与原密码相同")
					}else {
						$("#newpwd1-aux").css({
							display: "block",
							color: "#5FB878"
						}).html("输入正确")
						$("#newpwd2-aux").css({
							display: "block",
							color: "#5FB878"
						}).html("输入正确")
						$.ajax({
							url: Common.ctxPath + "/GAA/user/changePassword.json",
							dataType: 'json',
							type: 'post',
							async: false,
							data: con,
							success: function (res) {
								if (res.data==1) {
									layer.msg("密码修改成功", { icon: 6, time: 1500 });
									window.location.href="/";
								}else{
									layer.msg(res.msg, { icon: 6, time: 1500 });
								}
							}
						});

					}

				}
			},
		});
	}

	var isshow=${showPwd};

</script>

	<div id="passwordInfos"  style="padding: 50px;display:none;">
			<div class="layui-form" lay-filter="indexUPdatePWFrom">
				<div class="layui-form-item">
					<label class="layui-form-label">原密码<font color="red">*</font></label>
					<div class="layui-input-inline">
						<input type="password" id="oldPassword" name="oldPassword" value="${session['core:user'].password}"
							  autocomplete="off"  disabled
							class="layui-input" maxlength="25">
					</div>
					<div id="mopwd-aux" class="aux-self-word"></div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">新密码<font color="red">*</font></label>
					<div class="layui-input-inline">
						<input type="password" id="password" name="password"
							placeholder="请填写新密码" autocomplete="off" class="layui-input" lay-verify="pass"
							maxlength="25">
					</div>
					<div id="newpwd1-aux" class="aux-self-word"></div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">确认密码<font color="red">*</font></label>
					<div class="layui-input-inline">
						<input type="password" id="password2" name="password2"
							placeholder="请填写确认密码" autocomplete="off" class="layui-input" lay-verify="pass"
							maxlength="25">
					</div>
					<div id="newpwd2-aux" class="aux-self-word"></div>
				</div>
			</div>
	</div>
  
  <div  id="selectCompany" 
  	style="padding: 50px;display:none;">
  	<div class="layui-row">
		<div class="layui-form-item">
			<select id="companyList"> 
			<!--#
			var allOrgs = session["core:orgs"];
			for(org in allOrgs){
				var checked = false;
				if(session["core:currentOrg"].id==org.id){
					checked=true;
				}
			 -->
		  	
		  	<option value="${org.id}" ${checked?"selected"}>${org.name}</option>
		  	<!--#}  -->
		  	</select>
  		</div>
 	 </div>
 	</div>


  <!-- 左边菜单 -->
  <div class="layui-side layui-bg-black">
    <div class="layui-side-scroll">
      <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
      <ul class="layui-nav layui-nav-tree fsMenu"  lay-filter="fsLeftMenu" id="fsLeftMenu">
      	<!--#
      	for(node in menus.children){  
      	var hasSite = true;//系统的第一个菜单默认显示
      	-->
      	<!--#for(subSystem in node.children){  -->
        <li class="layui-nav-item layui-nav-itemed" dataPid="${node.data.id}" style="display: none;">
          <a href="javascript:">${subSystem.data.name}</a>
          <dl class="layui-nav-child">
          	<!--#for(menu in subSystem.children){  -->
          	<dd class="" ><a href="javascript:" menuId="${menu.data.id}" dataUrl="${ctxPath}${menu.data.accessUrl}"><i class="layui-icon">&#xe68e;</i>
          	${menu.data.name}
          	</a></dd>
            <!--#}  -->
           </dl>
        </li>
        <!--#}  -->
        <!--#}  -->
      </ul>
    </div>
  </div>

  <!-- 右边内容区域 -->
  <div class="layui-body layui-form">
  	<div class="layui-tab layui-tab-card fsTab" lay-filter="fsTab" lay-allowClose="true">
  		
  		<!-- 菜单导航 -->
		<ul class="layui-tab-title">
		 <li class="layui-this">系统说明</li>
		</ul>
		
		<!-- 内容 -->
		<div class="layui-tab-content">
			<div class="layui-tab-item layui-show">
			<!--#include("/help.html"){}  -->
			</div>
		</div>
	</div>
  </div>
  </form>
<script type="text/javascript">
	window.onload=function () {
		if(isshow){
			var showdd=['确定'];
			showupdatepwd(showdd);
		}
	};
</script>
<!--#}  -->
  