|
|
@@ -0,0 +1,217 @@ |
|
|
|
/*! |
|
|
|
* 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园(http://www.learun.cn) |
|
|
|
* Copyright (c) 2013-2018 北京泉江科技有限公司 |
|
|
|
* 创建人:陈彬彬 |
|
|
|
* 日 期:2017.03.08 |
|
|
|
* 描 述:登录页面前端脚本 |
|
|
|
*/ |
|
|
|
(function ($) { |
|
|
|
"use strict"; |
|
|
|
var codeType = 'forgetpwd', hasSendCode = false, time = 0, timeT = '', isSending = false; |
|
|
|
var lrPage = { |
|
|
|
init: function () { |
|
|
|
lrPage.bind(); |
|
|
|
}, |
|
|
|
bind: function () { |
|
|
|
// 去登陆 |
|
|
|
$('#goLogin').click(function () { |
|
|
|
window.location.href = "/"; |
|
|
|
}) |
|
|
|
|
|
|
|
// 确认修改按钮 |
|
|
|
$("#confirmUpdate").on('click', function () { |
|
|
|
lrPage.confirmUpdate(); |
|
|
|
}); |
|
|
|
|
|
|
|
// 发送验证码事件 |
|
|
|
$("#sendCode").on('click', function () { |
|
|
|
lrPage.sendCode(); |
|
|
|
}); |
|
|
|
|
|
|
|
$('.psw_change').css({ |
|
|
|
'background': 'url(' + '/Content/images/Login/psw0.png) no-repeat center center' |
|
|
|
}); |
|
|
|
|
|
|
|
//点击密码icon 显示/隐藏 |
|
|
|
$('.psw_change').click(function (event) { |
|
|
|
var event = event || window.event; |
|
|
|
event.stopPropagation(); |
|
|
|
var $this = $(this); |
|
|
|
$this.toggleClass('psw_show'); |
|
|
|
//如果当前隐藏 变显示 |
|
|
|
if ($this.hasClass('psw_show')) { |
|
|
|
$this.css({ |
|
|
|
'background': 'url(' + '/Content/images/Login/psw1.png) no-repeat center center' |
|
|
|
}); |
|
|
|
$this.prev().attr('type', 'text'); |
|
|
|
} else { |
|
|
|
$this.css( |
|
|
|
'background', 'url(/Content/images/Login/psw0.png) no-repeat center center' |
|
|
|
); |
|
|
|
$this.prev().attr('type', 'password'); |
|
|
|
} |
|
|
|
}); |
|
|
|
}, |
|
|
|
updating: function (isShow) { |
|
|
|
if (isShow) { |
|
|
|
$('#updatepwBox input').attr('disabled', 'disabled'); |
|
|
|
$("#confirmUpdate").addClass('active').attr('disabled', 'disabled').find('span').hide(); |
|
|
|
$("#confirmUpdate").css('background', '#eeecec url(/Content/images/Login/loading.gif) no-repeat center 10px'); |
|
|
|
|
|
|
|
} |
|
|
|
else { |
|
|
|
$('#updatepwBox input').removeAttr('disabled'); |
|
|
|
$("#confirmUpdate").removeClass('active').removeAttr('disabled').find('span').show(); |
|
|
|
$("#confirmUpdate").css('background', '#268fe2'); |
|
|
|
} |
|
|
|
}, |
|
|
|
sendCode: function () { |
|
|
|
if (isSending || hasSendCode) return; |
|
|
|
let phone = $('#phone').val() |
|
|
|
if (!phone) { |
|
|
|
$('#updatepwBox .error_info span').text('请输入手机号') |
|
|
|
$('#updatepwBox .error_info').show() |
|
|
|
return |
|
|
|
} else if (!/^1[0-9]{10}$/.test(phone)) { |
|
|
|
$('#updatepwBox .error_info span').text('手机号格式不正确') |
|
|
|
$('#updatepwBox .error_info').show() |
|
|
|
return |
|
|
|
} |
|
|
|
$('#updatepwBox .error_info').hide() |
|
|
|
isSending = true |
|
|
|
$.ajax({ |
|
|
|
url: "/Login/Sendcode", |
|
|
|
data: { phone, codeType }, |
|
|
|
dataType: 'json', |
|
|
|
type: "post", |
|
|
|
success: (res) => { |
|
|
|
isSending = false; |
|
|
|
if (res.code == 200) { |
|
|
|
$('#updatepwBox .error_info span').text('短信已发送') |
|
|
|
$('#updatepwBox .error_info').show() |
|
|
|
|
|
|
|
hasSendCode = true |
|
|
|
time = 60 |
|
|
|
$('#sendCode').text(`重新发送(${time}s)`) |
|
|
|
timeT = setInterval(() => { |
|
|
|
time-- |
|
|
|
if (time == 0) { |
|
|
|
hasSendCode = false |
|
|
|
clearInterval(timeT) |
|
|
|
timeT = '' |
|
|
|
} |
|
|
|
$('#sendCode').text(`重新发送${time ? '(' + time + 's' + ')' : ''}`) |
|
|
|
}, 1000); |
|
|
|
} else { |
|
|
|
$('#updatepwBox .error_info span').text(res.info) |
|
|
|
$('#updatepwBox .error_info').show() |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}, |
|
|
|
checkverifycode: function () { |
|
|
|
return new Promise((resolve) => { |
|
|
|
let verifycode = $('#verifycode').val() |
|
|
|
let phone = $('#phone').val() |
|
|
|
if (!verifycode) { |
|
|
|
$('#updatepwBox .error_info span').text('请输入验证码') |
|
|
|
$('#updatepwBox .error_info').show() |
|
|
|
resolve(false) |
|
|
|
return |
|
|
|
} |
|
|
|
$('#updatepwBox .error_info').hide() |
|
|
|
$.ajax({ |
|
|
|
url: "/Login/LoginCodeVerify", |
|
|
|
data: { phone, verifycode, codeType }, |
|
|
|
dataType: 'json', |
|
|
|
type: "post", |
|
|
|
success: (res) => { |
|
|
|
if (res.code == 200) { |
|
|
|
resolve(true) |
|
|
|
} else { |
|
|
|
$('#updatepwBox .error_info span').text(res.info) |
|
|
|
$('#updatepwBox .error_info').show() |
|
|
|
resolve(false) |
|
|
|
} |
|
|
|
}, |
|
|
|
error: () => { |
|
|
|
$('#updatepwBox .error_info span').text('验证码校验失败') |
|
|
|
$('#updatepwBox .error_info').show() |
|
|
|
resolve(false) |
|
|
|
} |
|
|
|
}); |
|
|
|
}) |
|
|
|
}, |
|
|
|
confirmUpdate: async function () { |
|
|
|
let phone = $('#phone').val() |
|
|
|
let verifycode = $('#verifycode').val() |
|
|
|
let newpassword = $('#newpassword').val() |
|
|
|
let newpassword1 = $('#newpassword1').val() |
|
|
|
if (!phone) { |
|
|
|
$('#updatepwBox .error_info span').text('请输入手机号') |
|
|
|
$('#updatepwBox .error_info').show() |
|
|
|
return |
|
|
|
} else if (!/^1[0-9]{10}$/.test(phone)) { |
|
|
|
$('#updatepwBox .error_info span').text('手机号格式不正确') |
|
|
|
$('#updatepwBox .error_info').show() |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
if (!newpassword) { |
|
|
|
$('#updatepwBox .error_info span').text('请输入新密码') |
|
|
|
$('#updatepwBox .error_info').show() |
|
|
|
return |
|
|
|
} |
|
|
|
if (!/^(?=.*[0-9])(?=.*[A-Z])(?=.*[a-z])(?=.*[!@#$%^&*,\.])[0-9a-zA-Z!@#$%^&*,\.]{8,20}$/.test(newpassword)) { |
|
|
|
$('#updatepwBox .error_info span').text('您的密码不满足强度要求,请重新输入') |
|
|
|
$('#updatepwBox .error_info').show() |
|
|
|
return |
|
|
|
} |
|
|
|
if (!newpassword1) { |
|
|
|
$('#updatepwBox .error_info span').text('请再次输入新密码') |
|
|
|
$('#updatepwBox .error_info').show() |
|
|
|
return |
|
|
|
} |
|
|
|
if (newpassword != newpassword1) { |
|
|
|
$('#updatepwBox .error_info span').text('两次密码输入不一致') |
|
|
|
$('#updatepwBox .error_info').show() |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
if (!verifycode) { |
|
|
|
$('#updatepwBox .error_info span').text('请输入验证码') |
|
|
|
$('#updatepwBox .error_info').show() |
|
|
|
return |
|
|
|
} |
|
|
|
$('#updatepwBox .error_info').hide() |
|
|
|
lrPage.updating(true); |
|
|
|
let codeRes = await lrPage.checkverifycode() |
|
|
|
if (!codeRes) { |
|
|
|
lrPage.updating(false); |
|
|
|
return |
|
|
|
} |
|
|
|
$.ajax({ |
|
|
|
url: "/Login/ForgotPasswordHandle", |
|
|
|
data: { phone, codeType, newpassword }, |
|
|
|
dataType: 'json', |
|
|
|
type: "post", |
|
|
|
success: (res) => { |
|
|
|
if (res.code == 200) { |
|
|
|
$('#updatepwBox .error_info span').text('修改密码成功') |
|
|
|
$('#updatepwBox .error_info').show() |
|
|
|
setTimeout(() => { |
|
|
|
window.location.href = "/"; |
|
|
|
},1500) |
|
|
|
} else { |
|
|
|
lrPage.updating(false); |
|
|
|
$('#updatepwBox .error_info span').text(res.info) |
|
|
|
$('#updatepwBox .error_info').show() |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
}; |
|
|
|
$(function () { |
|
|
|
lrPage.init(); |
|
|
|
}); |
|
|
|
})(window.jQuery) |