<div id="password_edit_block" class="hide account_edit_block">
<table>
<tr>
<td class="account_title">旧密码:</td>
<td>
<input id="txt_oldpwd" class="tb_m" type="password" />
</td>
</tr>
<tr>
<td class="account_title">新密码:</td>
<td>
<input id="txt_newpwd" class="tb_m" type="password" /> 至8个字符,最多30个字符
</td>
</tr>
<tr>
<td class="account_title">确认密码:</td>
<td>
<input id="txt_confirmpwd" class="tb_m" type="password" />
</td>
</tr>
</table>
<div class="account_btn_wrapper">
<input type="button" onclick="ChangePwd();" value="保存" style="margin-left: 0;" />
<input type="button" onclick="passwordToggle();" value="取消" style="margin-left: 3px;" />
<br />
<span id="tip_password" class="text_red"></span>
</div>
</div>
</div>
function ChangePwd() {
var value = $("#txt_newpwd").val();
if (value == '') {
$.messager.alert('请输入密码');
return;
}
if (value != $("#txt_confirmpwd").val()) {
$.messager.alert('两次密码输入不一致');
return;
}
var oldpwd = $("#txt_oldpwd").val();
if (value == oldpwd) {
$.messager.alert("新密码不能与旧密码相同");
return;
}
$.messager.alert("修改操作中,请稍候...");
//密码加密
var encrypt = new JSEncrypt();
encrypt.setPublicKey('')
var encrypted_input1 = encrypt.encrypt(oldpwd);
var encrypted_input2 = encrypt.encrypt(value);
//存入密码
var ajax_data = {
oldpwd: encrypted_input1,
newpwd: encrypted_input2
};
$.ajax({
url: '/user/ChangPwd',
data: JSON.stringify(ajax_data),
type: 'post',
dataType: 'text',
contentType: 'application/json; charset=utf8',
cache: false,
success: function (data) {
if (data.indexOf('修改成功') > -1) {
$.messager.alert(data + ',立即<a href="###" onclick="logout_immediate();return false;">重新登录</a>');
}
else
$("#tip_password").html(data);
},
error: function (xhr) {
$("#tip_password").html(xhr.responseText);
}
});
}