123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- /*
- * 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('<div class="tip-error"><i class="fa fa-exclamation-circle"></i>密码错误!</div>');
- }
- else {
- $this.parent().find('.tip').html('<div class="tip-success"><i class="fa fa-check-circle"></i></div>');
- }
- });
- });
- // 新密码
- $("#NewPassword").blur(function () {
- var $this = $(this);
- $this.parent().find('.tip').html('');
- if ($this.val() == "") {
- return false;
- }
- $this.parent().find('.tip').html('<div class="tip-success"><i class="fa fa-check-circle"></i></div>');
- });
- $("#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('<div class="tip-success"><i class="fa fa-check-circle"></i></div>');
- }
- else {
- $this.parent().find('.tip').html('<div class="tip-error"><i class="fa fa-exclamation-circle"></i>两次密码输入不一样!</div>');
- }
-
- });
- $('#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();
- }
|