app-jeesite uppass

<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title></title>
 		<link href="../css/app.css" rel="stylesheet"/>
 		<script src="../js/jquery.min.js"></script>
		<script src="../js/mui.min.js"></script>
		<script src="../js/app.js"></script>
	</head>
	<body>
		<header class="mui-bar mui-bar-nav" style="background-color: #18538d;" >
			<a href="../admin.html" class="mui-left mui-action-back mui-btn mui-btn-link mui-btn-nav mui-pull-left">
				<span class="mui-icon mui-icon-left-nav" style=""></span>返回
			</a>
			<h1 class="mui-title">修改密码</h1>
		</header>
		<div class="mui-content" style="padding-bottom: 50px;">
			<div class="mui-input-group">
				<div class="mui-input-row">
					<label>原密码</label>
					<input type="password" id="oldPwd" class="mui-input-clear" placeholder="请输入" />
				</div>
				<div class="mui-input-row">
					<label>新密码</label>
					<input type="password" id="newPwd" class="mui-input-clear" placeholder="请输入" />
				</div>
				<div class="mui-input-row">
					<label>确认密码</label>
					<input type="password" id="confirmPwd" class="mui-input-clear" placeholder="请输入" />
				</div>
			</div>
			<div class="mui-input-row" style="padding: 15px;">
				<input type="submit" id="savePwd" class="mui-btn-block mui-btn-blue" value="保存" />
			</div>
			<p class="wrong"></p>
		</div>
	</body>
	<script src="../js/mui.min.js"></script>
	<script src="../js/common.js"></script>
	<script type="text/javascript" src="../js/server.js"></script>
	<script type="text/javascript" src="../js/jquery.min.js"></script>
	<script>
		mui.init();
		//重写返回按钮
		mui.back = function(event) {
			window.location.href="../admin.html";
		}
		var changePwdButton = $('#savePwd');
		//监听保存按钮
		changePwdButton.bind('tap', function(event) {
			var oldPwd = $('#oldPwd').val();
			var newPwd = $('#newPwd').val();
			var confirmPwd = $('#confirmPwd').val();
			var loginname = localStorage.getItem("loginname")
            var password = localStorage.getItem("password")
             var syspass = localStorage.getItem("syspass")
			if(judgeChangePwd(oldPwd, newPwd, confirmPwd)) {
				var rdata = {
					"loginname": loginname,
					"newpassword": newPwd,
					"oldpassword":oldPwd
				};
				fun_server.actionAjax("/app/user/updatePass", rdata, changePwdSuccess);
			}//if
		}); //tap

		function changePwdSuccess(data) {
			mui.toast(data.message, {
				duration: 'long',
				type: 'div'
			});
			localStorage.removeItem("password");
			//修改成功返回登录页面
			setTimeout(function() {
				mui.openWindow({
					url: "../login.html"
				});
			}, 1000);
		}
		function changePwdFail() {
			mui.toast('失败,请稍后再试', {
				duration: 'long',
				type: 'div'
			});
			//修改成功返回登录页面
			setTimeout(function() {
				mui.openWindow({
					url: "../login.html"
				});
			}, 1000);
		}
		//验证密码
		function judgeChangePwd(oldPwd, newPwd, confirmPwd) {
			if(oldPwd == "" || oldPwd == null) {
				$('.wrong').html("请填写原密码");
				return false;
			} else if(newPwd == "" || newPwd == null) {
				$('.wrong').html("请填写新密码");
				return false;
			} else if(newPwd.length < 3) {
				$('.wrong').html("密码不能少于3位");
				return false;
			} else if(newPwd != confirmPwd) {
				$('.wrong').html("确认密码必须与新密码一致");
				return false;
			} else if(oldPwd != localStorage.password) {
				$('.wrong').html("原密码错误");
				return false;
			} else {
				$('.wrong').html("");
				return true;
			}
		} 
	</script>

</html>

	@ResponseBody
	@RequestMapping(value = "${frontPath}/user/updatePass", method = RequestMethod.POST)
	public Map<String, Object> modifyPwdApp(HttpServletRequest request, HttpServletResponse response) {
		User user = UserUtils.getUser();
		Map<String, Object> map=new HashMap<String,Object>();
		@SuppressWarnings("unused")
		String	userpass=user.getPassword();
		String oldPassword=request.getParameter("oldpassword");
		String newPassword=request.getParameter("newpassword");
			if (SystemService.validatePassword(oldPassword, user.getPassword())){
				systemService.updatePasswordById(user.getId(), user.getLoginName(), newPassword);
				map.put("message","修改密码成功");
			}else{
			}
			
		return map;
	
	}

猜你喜欢

转载自blog.csdn.net/gaoduicai/article/details/82943054