/*
* wms(http://www.learun.cn)
*
* 创建人:前端开发组
* 日 期:2017.04.11
* 描 述:个人中心-修改密码
*/
var bootstrap = function ($, learun) {
"use strict";
var page = {
init: function () {
page.bind();
},
bind: function () {
// 点击切换验证码
$("#Verifycode_img").click(function () {
$("#Verifycode").val('');
$.ajax({
type: 'post',
dataType: 'json',
url: top.$.rootUrl + "/UserCenter/VerifyCode",
success: function (data) {
//将图片的Base64编码设置给src
$("#Verifycode_img").attr("src", "data:image/Gif;base64," + data);
}
});
});
$("#Verifycode_img").trigger('click');
// 旧密码验证
$("#OldPassword").blur(function () {
var $this = $(this);
$this.parent().find('.tip').html('');
if ($this.val() == "") {
return false;
}
var password = $this.val();
learun.httpAsyncPost(top.$.rootUrl + "/UserCenter/ValidationOldPassword", { OldPassword: password }, function (res) {
if (res.code<1) {
$this.parent().find('.tip').html('
密码错误!
');
}
else {
$this.parent().find('.tip').html('
');
}
});
});
// 新密码
$("#NewPassword").blur(function () {
var $this = $(this);
$this.parent().find('.tip').html('');
if ($this.val() == "") {
return false;
}
$this.parent().find('.tip').html('
');
});
$("#RedoNewPassword").blur(function () {
var $this = $(this);
$this.parent().find('.tip').html('');
if ($this.val() == "") {
return false;
}
if ($this.val() == $('#NewPassword').val()) {
$this.parent().find('.tip').html('
');
}
else {
$this.parent().find('.tip').html('两次密码输入不一样!
');
}
});
$('#lr_save_btn').on('click', function () {
if (!$('#form').lrValidform()) {
return false;
}
if ($('#OldPassword').parent().find('.tip-success').length > 0 && $('#NewPassword').parent().find('.tip-success').length > 0 && $('#RedoNewPassword').parent().find('.tip-success').length > 0)
{
var formData = $('#form').lrGetFormData();
var postData = {
password: formData.NewPassword,
oldPassword: formData.OldPassword,
verifyCode: formData.Verifycode
};
learun.layerConfirm('注:请牢记当前设置密码,您确认要修改密码?', function (res, index) {
if (res) {
$.lrSaveForm(top.$.rootUrl + '/UserCenter/SubmitResetPassword', postData, function (res) {
if (res.code >0) {
top.location.href = top.$.rootUrl + "/Login/Index";
}
console.log(res);
});
top.layer.close(index); //再执行关闭
}
});
}
return false;
});
}
};
page.init();
}