优化密码修改页面

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

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