优化密码修改页面

This commit is contained in:
季圣华
2020-04-17 23:17:30 +08:00
parent 61b42302f5
commit c8041a6b41
2 changed files with 50 additions and 47 deletions

View File

@@ -90,7 +90,7 @@ function loginFun() {
return; return;
} }
else if (loginInfoTip.indexOf("user password error") != -1) { else if (loginInfoTip.indexOf("user password error") != -1) {
alert("用户密码错误"); alert("密码错误");
return; return;
} }
else if (loginInfoTip.indexOf("access service error") != -1) { else if (loginInfoTip.indexOf("access service error") != -1) {

View File

@@ -16,42 +16,48 @@
<script type="text/javascript" src="/js/common/common.js"></script> <script type="text/javascript" src="/js/common/common.js"></script>
</head> </head>
<body> <body>
<div id="userDlg" class="easyui-panel" data-options="fit:true" title="修改密码" style="background-color:#EAF2FD; " <div id="userDlg" class="easyui-panel" data-options="fit:true" title="修改密码" iconCls="icon-list" style="padding:10px 20px"
iconCls="icon-unlock"> iconCls="icon-unlock">
<form id="passwordFM" method="post" novalidate> <form id="passwordFM" method="post" novalidate>
<div class="fitem" style="padding:10px"> <table style="width:100%">
<label id="passwordLabel">原始密码&nbsp;&nbsp;</label> <tr>
<input type="password" name="oldpassword" id="oldpassword" class="easyui-validatebox" <td style="width:80px;">原始密码</td>
data-options="required:true,validType:'length[5,20]'" style="width: 230px;height: 20px" <td style="padding:5px;">
missingMessage="请输入原始密码"/> <input type="password" name="oldpassword" id="oldpassword" class="easyui-textbox"
<span id="orgTipMsg"></span> data-options="required:true,validType:'length[5,20]'" style="width: 230px;"
</div> missingMessage="请输入原始密码"/>
<div class="fitem" style="padding:10px"> </td>
<label id="newPassword">重设密码&nbsp;&nbsp;</label> </tr>
<input type="password" name="password" id="password" class="easyui-validatebox" <tr>
data-options="required:true,validType:'length[5,20]'" style="width: 230px;height: 20px" <td>重设密码</td>
missingMessage="请填写新密码"/> <td style="padding:5px;">
<span id="orgTipMsg"></span> <input type="password" name="password" id="password" class="easyui-textbox"
</div> data-options="required:true,validType:'length[5,20]'" style="width: 230px;"
<div class="fitem" style="padding:10px"> missingMessage="请填写新密码"/>
<label id="repasswordLabel">再输一遍&nbsp;&nbsp;</label> </td>
<input type="password" name="repassword" id="repassword" class="easyui-validatebox" </tr>
style="width: 230px;height: 20px" required="true" class="easyui-validatebox" <tr>
validType="equals['#password']" missingMessage="请再次填写新密码" invalidMessage="两次密码输入不一致"/> <td>再输一遍</td>
<span id="tipMsg"></span> <td style="padding:5px;">
</div> <input type="password" name="repassword" id="repassword" class="easyui-textbox"
data-options="required:true,validType:'length[5,20]'" style="width: 230px;"
missingMessage="请再次填写新密码"/>
</td>
</tr>
<tr>
<td></td>
<td style="padding:5px;">
<a href="javascript:void(0)" id="savepassword" class="easyui-linkbutton" iconCls="icon-save">保存</a>&nbsp;&nbsp;
<a href="javascript:void(0)" id="cancelpassword" class="easyui-linkbutton" iconCls="icon-redo">重置</a>
</td>
</tr>
</table>
</form> </form>
<div style="clear: both;">&nbsp;</div>
<div id="dlg-buttons">
<a href="javascript:void(0)" id="savepassword" class="easyui-linkbutton" iconCls="icon-save">保存</a>
<a href="javascript:void(0)" id="cancelpassword" class="easyui-linkbutton" iconCls="icon-redo">重置</a>
</div>
</div> </div>
<script type="text/javascript"> <script type="text/javascript">
//初始化界面 //初始化界面
$(function () { $(function () {
$("#oldpassword").focus();
$('#passwordFM').form({ $('#passwordFM').form({
onSubmit: function () { onSubmit: function () {
return false; return false;
@@ -62,9 +68,9 @@
}); });
//重置 //重置
$("#cancelpassword").off("click").on("click", function () { $("#cancelpassword").off("click").on("click", function () {
$("#oldpassword").val(""); $("#oldpassword").textbox("clear");
$("#password").val(""); $("#password").textbox("clear");
$("#repassword").val(""); $("#repassword").textbox("clear");
}); });
//初始化键盘enter事件 //初始化键盘enter事件
$(document).keydown(function (event) { $(document).keydown(function (event) {
@@ -80,8 +86,16 @@
$("#savepassword").unbind().bind({ $("#savepassword").unbind().bind({
click: function () { click: function () {
if (!$('#passwordFM').form('validate')) var oldpassword = $.trim($("#oldpassword").textbox("getValue"));
var password = $.trim($("#password").textbox("getValue"));
var repassword = $.trim($("#repassword").textbox("getValue"));
if (!$('#passwordFM').form('validate')){
return; return;
}
if(password != repassword) {
$.messager.alert('提示', '两次密码输入不一致!', 'warning');
return;
}
$.ajax({ $.ajax({
type: "post", type: "post",
url: "/user/updatePwd", url: "/user/updatePwd",
@@ -89,8 +103,8 @@
async: false, async: false,
data: ({ data: ({
userId: sessionStorage.getItem("userId"), userId: sessionStorage.getItem("userId"),
password: $.trim($("#password").val()), password: password,
oldpwd: $.trim($("#oldpassword").val()) oldpwd: oldpassword
}), }),
success: function (res) { success: function (res) {
if(res && res.code === 200) { if(res && res.code === 200) {
@@ -101,7 +115,7 @@
history.go(-1); history.go(-1);
} }
else if (2 == status) { else if (2 == status) {
$("#orgTipMsg").empty().append("<font color='red'>原始密码输入错误</font>"); $.messager.alert('提示', '原始密码输入错误!', 'warning');
return; return;
} }
else if (3 == status) { else if (3 == status) {
@@ -123,17 +137,6 @@
}); });
} }
}); });
//处理tip提示
$("#oldpassword").unbind().bind({
'click keyup': function () {
$("#orgTipMsg").empty();
},
'blur': function () {
$("#orgTipMsg").empty();
}
});
</script> </script>
</body> </body>
</html> </html>