241 lines
11 KiB
JavaScript
241 lines
11 KiB
JavaScript
|
|
//---------------------------基本资料-----------------------------//
|
|
$(function(){
|
|
var testName = /^([a-zA-z]|[\\u4e00-\\u9eff])+([\\s·]([a-zA-z]|[\\u4e00-\\u9eff])+)?$/;//匹配人名的正则表达式
|
|
$("#duty").change(function(){
|
|
var option = $("#duty option:selected");
|
|
if(option.val()=="1"){
|
|
$("li .hint").hide();
|
|
$("#number").show();
|
|
$("#teacher").hide();
|
|
$("#profession").hide();
|
|
}else if(option.val()=="2"){
|
|
$("#number").hide();
|
|
$("li .hint").hide();
|
|
$("#teacher").hide();
|
|
$("#profession").show();
|
|
}else if(option.val()=="0"){
|
|
$("#number").hide();
|
|
$("li .hint").hide();
|
|
$("#profession").hide();
|
|
$("#teacher").show();
|
|
}else{
|
|
$("li .hint").show();
|
|
}
|
|
});
|
|
|
|
});
|
|
|
|
// 修改密码
|
|
$(function(){
|
|
$("#reset_password_submit").on("click", function(){
|
|
if($("#password").val().trim() == ""){
|
|
$("#user_password_1_check").removeClass("fa-check").removeClass("color-light-green").addClass("fa-times-circle").addClass("color-orange");
|
|
$("#user_password_1_notice").html("请输入原始密码");
|
|
$("#user_password_1_notice").parent().show();
|
|
}else {
|
|
$("#user_password_1_check").removeClass("fa-times-circle").removeClass("color-orange").addClass("fa-check").addClass("color-light-green");
|
|
$("#user_password_1_notice").parent().hide();
|
|
if($("#new_password").val().length < 8){
|
|
$("#user_password_2_check").removeClass("fa-check").removeClass("color-light-green").addClass("fa-times-circle").addClass("color-orange");
|
|
$("#user_password_3_check").removeClass("fa-check").removeClass("color-light-green").addClass("fa-times-circle").addClass("color-orange");
|
|
$("#user_password_2_notice").html("新密码至少由8位字母或特殊符号和数字组成");
|
|
$('#user_password_2_notice').parent().show();
|
|
} else{
|
|
$("#user_password_2_check").removeClass("fa-times-circle").removeClass("color-orange").addClass("fa-check").addClass("color-light-green");
|
|
$('#user_password_2_notice').parent().hide();
|
|
if($("#new_password").val() != $("#new_password_confirmation").val()) {
|
|
$("#user_password_3_check").removeClass("fa-check").removeClass("color-light-green").addClass("fa-times-circle").addClass("color-orange");
|
|
$("#user_password_3_notice").html("两次密码输入不一致");
|
|
$('#user_password_3_notice').parent().show();
|
|
} else{
|
|
$("#user_password_3_check").removeClass("fa-times-circle").removeClass("color-orange").addClass("fa-check").addClass("color-light-green");
|
|
$('#user_password_3_notice').parent().hide();
|
|
$("#my_password_form").submit();
|
|
}
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
//---------------------------更改或绑定邮箱/手机号-----------------------------//
|
|
$(function(){
|
|
var $phone_correct = false;
|
|
var $mail_correct = false;
|
|
var lost_psd_time = 60;
|
|
$("#user_phone_num").blur(function (event) {
|
|
if ($(this).is('#user_phone_num')) {
|
|
if (/^1\d{10}$/.test(this.value) == false){
|
|
$('#user_phone_notice').html('请输入有效的11位手机号码');
|
|
$('#user_phone_notice').parent().show();
|
|
$("#user_phone_check").removeClass("fa-check").removeClass("color-light-green").addClass("fa-times-circle").addClass("color-orange");
|
|
return false;
|
|
}
|
|
else{
|
|
$.get(
|
|
'/account/valid_ajax',
|
|
{ valid: "phone",
|
|
value: this.value },
|
|
function (data) {
|
|
if (data.valid) {
|
|
$('#user_phone_notice').html('');
|
|
$('#user_phone_notice').parent().hide();
|
|
$("#user_phone_check").removeClass("fa-times-circle").removeClass("color-orange").addClass("fa-check").addClass("color-light-green");
|
|
$phone_correct = true;
|
|
} else {
|
|
$('#user_phone_notice').html('该手机号已被绑定');
|
|
$('#user_phone_notice').parent().show();
|
|
$("#user_phone_check").removeClass("fa-check").removeClass("color-light-green").addClass("fa-times-circle").addClass("color-orange");
|
|
$phone_correct = false;
|
|
}
|
|
});
|
|
}
|
|
}
|
|
});
|
|
|
|
$("#user_email_addr").blur(function (event) {
|
|
if (/^[a-zA-Z0-9]+([._\\]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/.test(this.value) == false){
|
|
$('#user_phone_notice').html('邮箱地址格式不对');
|
|
$('#user_phone_notice').parent().show();
|
|
$("#user_email_check").removeClass("fa-check").removeClass("color-light-green").addClass("fa-times-circle").addClass("color-orange");
|
|
$mail_correct = false;
|
|
return ;
|
|
}
|
|
if ($(this).is('#user_email_addr')) {
|
|
$.get('/account/valid_ajax',
|
|
{ valid: "mail",
|
|
value: this.value },
|
|
function (data) {
|
|
if (data.valid) {
|
|
$('#user_phone_notice').html('');
|
|
$('#user_phone_notice').parent().hide();
|
|
$("#user_email_check").removeClass("fa-times-circle").removeClass("color-orange").addClass("fa-check").addClass("color-light-green");
|
|
$mail_correct = true;
|
|
} else {
|
|
$('#user_phone_notice').html('该邮箱已被绑定');
|
|
$('#user_phone_notice').parent().show();
|
|
$("#user_email_check").removeClass("fa-check").removeClass("color-light-green").addClass("fa-times-circle").addClass("color-orange");
|
|
$mail_correct = false;
|
|
}
|
|
});
|
|
}
|
|
});
|
|
|
|
$("#get_verification_code").on('click', function(){
|
|
btn = this;
|
|
if($mail_correct || $phone_correct){
|
|
if($('.drag_text').html() == "验证通过") {
|
|
btn.setAttribute("disabled", "disabled");
|
|
var val = '';
|
|
var type = 4;
|
|
if($mail_correct){
|
|
val = $("#user_email_addr").val().trim();
|
|
type = 5;
|
|
} else if($phone_correct){
|
|
val = $("#user_phone_num").val().trim();
|
|
type = 4;
|
|
}
|
|
|
|
$.get(
|
|
'/account/get_verification_code',
|
|
{ value: val,
|
|
type: type},
|
|
function (data) {
|
|
if (data.status == "2") {
|
|
$('#user_phone_notice').html(data.msg);
|
|
$('#user_phone_notice').parent().show();
|
|
btn.removeAttribute("disabled");
|
|
} else {
|
|
$('#user_phone_notice').html('');
|
|
$('#user_phone_notice').parent().hide();
|
|
settime(btn);
|
|
if(data.status == "3"){
|
|
$("#ver_code_type").val(3);
|
|
$("#send_success_notice").html("验证码已发送到您的邮箱,去<a href='http://mail." + data.link + "' style='color: #6a8abe; text-decoration: underline;' target='_blank'>查收</a>");
|
|
$("#send_success_notice").show();
|
|
} else{
|
|
$("#ver_code_type").val(2);
|
|
$("#send_success_notice").html("验证码已发送到您的手机,请注意查收");
|
|
$("#send_success_notice").show();
|
|
}
|
|
}
|
|
});
|
|
} else{
|
|
$("#user_verification_notice").html("请先拖动滑块完成验证");
|
|
$('#user_verification_notice').parent().show();
|
|
}
|
|
} else{
|
|
$('#user_phone_num').blur();
|
|
$('#user_email_addr').blur();
|
|
}
|
|
});
|
|
|
|
$("#bind_email_or_phone_form_submit").on('click', function(){
|
|
if($("#bind_email_or_phone_form_submit").hasClass('new_login_submit_disable')){
|
|
console.log(1111);
|
|
return;
|
|
}
|
|
console.log($mail_correct || $phone_correct);
|
|
if($mail_correct || $phone_correct){
|
|
if($('.drag_text').html() == "验证通过"){
|
|
if($("#phone_verification_code").val().trim() == ""){
|
|
$("#phone_verification_code_notice").html("请输入验证码");
|
|
$("#phone_verification_code_notice").parent().show();
|
|
} else{
|
|
$("#phone_verification_code_notice").html("");
|
|
$("#phone_verification_code_notice").parent().hide();
|
|
var val = '';
|
|
var type = 4;
|
|
if($mail_correct){
|
|
val = $("#user_email_addr").val().trim();
|
|
type = 5;
|
|
} else if($phone_correct){
|
|
val = $("#user_phone_num").val().trim();
|
|
type = 4;
|
|
}
|
|
$.get(
|
|
'/account/valid_verification_code',
|
|
{ phone: val,
|
|
code: $("#phone_verification_code").val().trim(),
|
|
type: type},
|
|
function (data) {
|
|
if (data.valid) {
|
|
$("#phone_verification_code_notice").html("");
|
|
$("#phone_verification_code_notice").parent().hide();
|
|
$("#bind_email_or_phone_form_submit").addClass("new_login_submit_disable");
|
|
$("#bind_email_or_phone_form").submit();
|
|
} else {
|
|
$("#phone_verification_code_notice").html("验证码错误或过期");
|
|
$("#phone_verification_code_notice").parent().show();
|
|
}
|
|
});
|
|
}
|
|
} else{
|
|
$("#user_verification_notice").html("请先拖动滑块完成验证");
|
|
$('#user_verification_notice').parent().show();
|
|
}
|
|
} else{
|
|
$('#user_phone_num').blur();
|
|
$('#user_email_addr').blur();
|
|
}
|
|
});
|
|
|
|
function settime(btn){
|
|
if (lost_psd_time==0) {
|
|
$(btn).removeClass("rest-btn-ver");
|
|
btn.removeAttribute("disabled");
|
|
btn.innerHTML = "获取验证码";
|
|
lost_psd_time = 60;
|
|
return;
|
|
}else{
|
|
$(btn).addClass("rest-btn-ver");
|
|
btn.setAttribute("disabled", "disabled");
|
|
btn.innerHTML = lost_psd_time + "s后重试";
|
|
lost_psd_time--;
|
|
}
|
|
setTimeout(function(){
|
|
settime(btn);
|
|
},1000);
|
|
}
|
|
|
|
}); |