<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<html>
<head>
	<%@ include file="../../include/lib.jsp" %> 
</head>

<body>
    	<div style=" width:264px; height:250px;">
		    <form id="passwordFrom" method="post" >
	    		<!-- <ul> <span style="color: red;font: 20px;font-size: larger;">演示版本不可修改密码</span></ul> -->
	    		<br/>
	    		<ul>
	    			<li>旧密码：</li>
	    			<li class="right"><input class="easyui-validatebox" type="password" name="oldPassword" data-options="required:true,missingMessage:'请输入旧密码'"></input></li>
	    		</ul>
	    		<ul>
	    			<li>新密码：</li>
	    			<li class="right"><input class="easyui-validatebox" type="password" name="newPassword" data-options="required:true,missingMessage:'请输入新密码',validType:'length[5,18]',invalidMessage:'密码长度为5-18个字符'"></input></li>
	    		</ul>
	    		<ul>
	    			<li>确认密码：</li>
	    			<li class="right"><input class="easyui-validatebox" type="password" name="againPassword" data-options="required:true,missingMessage:'请再次输入新密码',validType:'length[5,18]',invalidMessage:'密码长度为5-18个字符'"></input></li>
	    		</ul>
		    	<div class="foot">
				    <div class="button">
				    	<a href="javascript:void(0)" class="easyui-linkbutton confirm" onclick="submitForm()">确定</a>
				    	<a href="javascript:void(0)" class="easyui-linkbutton reset" onclick="clearForm('#passwordFrom')">重置</a>
				    </div>
				</div>
		    </form>
    	</div>
</body>
	    
<script>
	/*点击确定修改时执行保存修改信息的servlet，若修改成功，则弹出提示框*/
	function submitForm(){
			var temp = new Array();
			$("#passwordFrom li input").each(function(i) {
				temp[i] = $(this).val();
			});
			$.ajax({
			type : "post",
			dataType:"json",
			url:"${base_url}/admin/passwordEdit", 
			data:"oldPassword=" + temp[0] + "&newPassword=" + temp[1] + "&againPassword=" + temp[2],
		    success: function(data){
		       switch(data.code){
		       		case 106:
		       			showFormMsg(SYSTEM_TITLE,"密码修改成功!");
		       			break;
		       		case 107:
		       			showFormMsg(SYSTEM_TITLE,"旧密码输入错误");	
		       			break;
		       		case 118:
		       			showFormMsg(SYSTEM_TITLE,"新密码不能为空");	
		       			break;
		       		case 119:
		       			showFormMsg(SYSTEM_TITLE,"新设置的密码长度应为5—18个字符");	
		       			break;
		       		case 108:
		       			showFormMsg(SYSTEM_TITLE,"两次输入的新密码不一致");	
		       			break;
		       }
		    } 
		}); 
	}
	
</script>

</html>
