{{template "header.tmpl" .}}
</head>
<body>
{{template "navbar.tmpl" .}}

<div class="container-fluid">
	<h4 class="text-center">修改密码</h4>
	<hr />
	<div class="row">
		<div class="col-md-4 col-md-offset-4">
			<div class="pannel">
				<div class="pannel_body">
					<form id="mainform">
						<div class="form-group">
							<label>ID</label>
							<input type="text" class="form-control" name="" value="{{.Sess.Account.Id}}" maxlength="20" readonly="readonly" />
						</div>
						<div class="form-group">
							<label>用户名</label>
							<input type="text" class="form-control" name="" value="{{.Sess.Account.Account}}" maxlength="20" readonly="readonly" />
						</div>
						<div class="form-group">
							<label>旧密码</label>
							<input type="password" class="form-control" name="oldpwd" value="" maxlength="20" />
						</div>
						<div class="form-group">
							<label>新密码(6位以上)</label>
							<input type="password" class="form-control" name="newpwd" value="" maxlength="20" />
						</div>
						<div class="form-group">
							<label>重复新密码</label>
							<input type="password" class="form-control" name="newpwd2" value="" maxlength="20" />
						</div>
						<button class="btn btn-primary">提交</button>
					</form>
				</div>
			</div>
		</div>
	</div>
</div>

<script type="text/javascript">
var $SESS = {{.Sess}};
$(function(){
	$('#mainform').submit(function(){
		if (this.oldpwd.value == '') {
			$.alert({'content': '旧密码不能为空！'});
		} else if (this.oldpwd.value.length < 6) {
			$.alert({'content': '旧密码格式不正确！'});
		} else if (this.newpwd.value == '') {
			$.alert({'content': '新密码不能为空！'});
		} else if (this.newpwd.value.length < 6) {
			$.alert({'content': '新密码格式不正确！'});
		} else if (this.newpwd2.value != this.newpwd.value) {
			$.alert({'content': '新密码两次输入不一致！'});
		} else {
			$.post('/profile/passwd', $(this).serialize(), function(resp){
				if (resp.errno) {
					$.alert({'content': resp.error});
				} else {
					$.alert({'content': '修改成功！'});
				}
			}, 'json');
		}
		return false;
	});
});
</script>
</body>
</html>