//---------------------------基本资料-----------------------------// $(function(){ var testName = /^([a-zA-z]|[\\u4e00-\\u9eff])+([\\s·]([a-zA-z]|[\\u4e00-\\u9eff])+)?$/;//匹配人名的正则表达式 $("#edit_my_account").on('click', function(){ $("#show_account_div").hide(); $("#edit_account_div").show(); }); $("#userIdentity").change(function(){ var option = $("#userIdentity option:selected"); if(option.val()=="1"){ $("#identity_hint").hide(); $("#number").show(); $("#user_student_id").show(); $("#teacher").hide(); $("#profession").hide(); }else if(option.val()=="2"){ $("#number").hide(); $("#user_student_id").hide(); $("#identity_hint").hide(); $("#teacher").hide(); $("#profession").show(); }else if(option.val()=="0"){ $("#number").hide(); $("#user_student_id").hide(); $("#identity_hint").hide(); $("#profession").hide(); $("#teacher").show(); }else{ $("#identity_hint").hide(); } }); $("#province").blur(function () { if ($(this).val() == "") { $(this).attr("placeholder", "在校师生请写所在学校,其它用户填写所在工作单位"); } }); $("#my_account_form_link").on('click',function(){ my_account_form_submit(); }); $('#apply_school').live("click",function(e){ commit_add_school(); }); $('#apply_department').live("click",function(e){ commit_add_department(); }); $("#account_tip_a").on("click", function(e){ $("#account_tip_a").parent().children("p").remove(); $("#account_tip_a").parent().hide(); }); /* $(".a_forced").on("click", function(){ if($("#account_tip").children("p[type='1']").length == 0){ $("#account_tip").append("

完善您的基本资料后,才能使用其他功能哦

"); } $("#account_tip").show(); });*/ $("#mask-left-btn").on('click', function(){ $("#apply_reason_form").show(); }); $("#apply_trail_submit_btn").on('click', function(){ if($("#apply_reason").val().trim() == ""){ $("#hint_message").show(); } else{ $("#hint_message").hide(); $("#apply_trail_form").submit(); hideModal(); } }); }); function showtechnical_title(val) { $("*[nhname='tag_1']").each(function () { $("*[nh_required='1']", $(this)).attr("required", false); $(this).hide() }); $("#number").hide(); $("*[nh_tag_" + val + "='true']").each(function () { $("*[nh_required='1']", $(this)).attr("required", true); $(this).show() }); if(val == 1){ $("#number").show(); $("#user_student_id").show(); } $("#identity_hint").hide(); } function init_identity_and_title(pField, identity, title) { for (var i = 0; i < pField.options.length; i++) { if (pField.options[i].value == identity) { pField.selectedIndex = i; } } showtechnical_title(identity); if(identity == 0){ var cField = document.getElementById('teacher'); for (var i = 0; i < cField.options.length; i++) { if (cField.options[i].value == title) { cField.selectedIndex = i; } } } else if(identity != 1){ var cField = document.getElementById('profession'); for (var i = 0; i < cField.options.length; i++) { if (cField.options[i].value == title) { cField.selectedIndex = i; } } } } function init_province_and_city(pField, province, cField, city) { for (var i = 0; i < pField.options.length; i++) { if (pField.options[i].value == province) { pField.selectedIndex = i; } } showcity(province, cField); for (var i = 0; i < cField.options.length; i++) { if (cField.options[i].value == city) { cField.selectedIndex = i; } } } function changeValue(value, data) { //console.log(value+","+data) $("input[name='school']").val(value); $("input[name='occupation']").val(data); $("#user_department_li").show(); $("#search_school_result_list").hide(); $("#no_school_hint").hide(); } function changeDepValue(value, data) { //console.log(value+","+data) $("input[name='department']").val(value); $("input[name='department_id']").val(data); $("#search_department_result_list").hide(); $("#no_department_hint").hide(); } // 基本资料页面提交表单时,判断身份与单位是否合法 function my_account_form_submit() { if ($("#nickname").val().trim() == '') { $("#nickname").focus(); $("#nickname_hint").show(); e.stopImmediatePropagation(); return; } else{ $("#nickname_hint").hide(); } //姓名不能为空 if ($("#lastname").val().trim() == '') { $("#lastname").focus(); $("#lastname_hint").show(); e.stopImmediatePropagation(); return; } else{ $("#lastname_hint").hide(); } if ($("#userIdentity").val() == -1) { $("#identity_hint").show(); e.stopImmediatePropagation(); // 阻止事件冒泡 return; } else{ $("#identity_hint").hide(); } if ($("#teacher").is(":visible") == true && $("#teacher").val() == "0") { $("#identity_hint").show(); e.stopImmediatePropagation(); return; } else{ $("#identity_hint").hide(); } if ($("#profession").is(":visible") == true && $("#profession").val() == "0") { $("#identity_hint").show(); e.stopImmediatePropagation(); return; } else{ $("#identity_hint").hide(); } if ($("#user_student_id").parent().is(":visible") == true && ($("#user_student_id").val() == "" || !/^[0-9]\d*$/.test($("#user_student_id").val().trim()))) { $("#user_student_id").focus(); $("#student_id_hint").show(); e.stopImmediatePropagation(); return; } else{ $("#student_id_hint").hide(); } if ($("#userProvince").val() == "0" || $("#userCity").val() == "0"){ $("#province_hint").show(); e.stopImmediatePropagation(); return; } else{ $("#province_hint").hide(); } // 学校名字必须填写、单位或高校必须从下拉列表中选择 if ($("input[name='school']").val().trim() == '' || ($("input[name='school']").val().trim() != '' && $("input[name='occupation']").val().trim() == '')) { //学校名字和id不对的话 $("#school_name_hint").show(); e.stopImmediatePropagation(); return; } else{ $("#school_name_hint").hide(); } if($("#user_student_id").parent().is(":visible") == true && $("#user_student_id").val() != ""){ $.ajax({ url: '/account/check_user_student_id', type: 'post', data: {student_id:$("#user_student_id").val(), school_id:$("input[name='occupation']").val()}, success: function(data){ if(data.result == 0){ notice_box("该学号已被另一个账号(" + data.account + ")使用"); } else if (data.result == 1){ if($("#user_certi_school_id").length == 1 && $("#user_certi_school_id").val() != $("input[name='occupation']").val().trim()){ var htmlvalue = '
提示
'+ '

修改单位名称后需要重新申请试用授权

取消'+ '确定
'; pop_box_new(htmlvalue, 480, 160); } else{ $('#my_account_form').submit(); } } } }); } else{ if(($("#user_certi_real_name").length == 1 && $("#user_certi_real_name").val() != $("input[name='lastname']").val()) || ($("#user_certi_school_id").length == 1 && $("#user_certi_school_id").val() != $("input[name='occupation']").val().trim())){ var htmlvalue = '

提示

'+ '

修改真实姓名/单位名称后需要重新申请试用授权

取消'+ '确定
'; pop_box_new(htmlvalue, 480, 160); } else{ $('#my_account_form').submit(); } } } //申请单位 function commit_add_school(){ var name,province,city,address,remarks; name = $("#schoolname").val(); province = $("#schollProvince").val(); address = $("#address").val(); city = $("#schoolCity").val(); if(name == ""){ $("#schoolname").focus(); return; } if($("#schoolrepeatnotice").attr("value") == "1"){ return; } if(province == "" || city == ""){ $("#province_notice").show(); return; } if(address == ""){ $("#address").focus(); return; } remarks = $("#remarks").val(); $.ajax({ url: '/school/apply_add_school', type: 'get', data: {name:name,province:province,city:city,address:address,remarks:remarks}, success: function(data){ if(data.result == 0){ $("input[name='school']").val(data.name); $("input[name='occupation']").val(data.school_id); $("#user_department_li").show(); $("#no_school_hint").hide(); $("#school_name_hint").hide(); //var htmlvalue = "
添加成功!您可以继续使用了。

后续我们将对您的高校(单位)进行审核,如有问题我们再联系您。

"; //$('#province').onload(); //$('#my_account_form_link').click(); long_notice_box("添加成功!您可以继续使用了。
后续我们将对您的单位进行审核,如有问题我们再联系您。"); } else if (data.result == 1){ } else if (data.result == 2){ $("#school_name_check").removeClass("fa-check-circle").removeClass("color-light-green").addClass("fa-times-circle").addClass("color-orange"); $("#schoolrepeatnotice").show(); $("#schoolrepeatnotice").attr("value",1); } return; } }); } function ifNameRepeat(){ //名称不能为空也不能重复 if($("#schoolname").val() == ""){ return; } $.ajax({ url: '/school/search_repeat_schoolname', type: 'get', data: {name:$("#schoolname").val()}, success: function(data){ if (data == 1){ $("#school_name_check").removeClass("fa-check-circle").removeClass("color-green").addClass("fa-times-circle").addClass("color-orange"); $("#schoolrepeatnotice").show(); $("#schoolrepeatnotice").attr("value",1); } else{ $("#school_name_check").removeClass("fa-times-circle").removeClass("color-orange").addClass("fa-check-circle").addClass("color-green"); $("#schoolrepeatnotice").hide(); $("#schoolrepeatnotice").attr("value",0); } } }); } //申请部门/学院 function commit_add_department(){ var school_id, name,remarks; school_id = $("#school_id").val(); name = $("#department_name").val(); if(name == ""){ $("#department_name").focus(); return; } if($("#departmentrepeatnotice").attr("value") == "1"){ return; } remarks = $("#remarks").val(); $.ajax({ url: '/department/apply_add_department', type: 'post', data: {name:name,school_id:school_id,remarks:remarks}, success: function(data){ if(data.result == 0){ $("input[name='department']").val(data.name); $("input[name='department_id']").val(data.department_id); $("#no_department_hint").hide(); long_notice_box("添加成功!您可以继续使用了。
后续我们将对您的部门进行审核,如有问题我们再联系您。"); } else if (data.result == 1){ } else if (data.result == 2){ $("#department_name_check").removeClass("fa-check-circle").removeClass("color-light-green").addClass("fa-times-circle").addClass("color-orange"); $("#departmentrepeatnotice").attr("value",1).show(); }else if (data.result == 4){ $("#schoolnamenotice").show(); $("#departmentrepeatnotice").attr("value",1); } return; } }); } function ifDepNameRepeat(){ //名称不能为空也不能重复 if($("#department_name").val() == ""){ return; } $.ajax({ url: '/department/search_repeat_departmentname', type: 'post', data: {name:$("#department_name").val(),school_id:$("#school_id").val()}, success: function(data){ if (data == 1){ $("#department_name_check").removeClass("fa-check-circle").removeClass("color-light-green").addClass("fa-times-circle").addClass("color-orange"); $("#departmentrepeatnotice").attr("value",1).show(); } else if(data == 2){ $("#department_name_check").removeClass("fa-times-circle").removeClass("color-orange").addClass("fa-check-circle").addClass("color-light-green"); $("#departmentrepeatnotice").attr("value",0).hide(); } else if(data == 0){ $("#schoolnamenotice").show(); $("#departmentrepeatnotice").attr("value",1); } } }); } // 修改密码 $(function(){ var $psd_correct = false; $("#password").on("blur", function(){ if($("#password").val().trim() == ""){ $("#user_password_1_check").removeClass("fa-check-circle").removeClass("color-light-green").addClass("fa-times-circle").addClass("color-orange"); $("#user_password_1_notice").html("请输入原始密码"); $("#user_password_1_notice").parent().show(); }else { $.post( '/account/valid_psd', { value: this.value }, function (data) { if (data.valid) { $('#user_password_1_notice').html(''); $('#user_password_1_notice').parent().hide(); $("#user_password_1_check").removeClass("fa-times-circle").removeClass("color-orange").addClass("fa-check-circle").addClass("color-light-green"); $psd_correct = true; } else { $('#user_password_1_notice').html('密码输入有误'); $('#user_password_1_notice').parent().show(); $("#user_password_1_check").removeClass("fa-check-circle").removeClass("color-light-green").addClass("fa-times-circle").addClass("color-orange"); $psd_correct = false; } }); } }); $("#reset_password_submit").on("click", function(){ if(!$psd_correct){ $("#password").blur(); }else { $("#user_password_1_check").removeClass("fa-times-circle").removeClass("color-orange").addClass("fa-check-circle").addClass("color-light-green"); $("#user_password_1_notice").parent().hide(); if($("#new_password").val().length < 8 || $("#new_password").val().length > 16){ $("#user_password_2_check").removeClass("fa-check-circle").removeClass("color-light-green").addClass("fa-times-circle").addClass("color-orange"); $("#user_password_3_check").removeClass("fa-check-circle").removeClass("color-light-green").addClass("fa-times-circle").addClass("color-orange"); $("#user_password_2_notice").html("新密码8-16位,区分大小写字母"); $('#user_password_2_notice').parent().show(); } else{ $("#user_password_2_check").removeClass("fa-times-circle").removeClass("color-orange").addClass("fa-check-circle").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-circle").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-circle").addClass("color-light-green"); $('#user_password_3_notice').parent().hide(); $("#my_password_form").submit(); } } } }); $(".new_loggin_input").focus(function(){ var notice_icon = $(this).next(); if(notice_icon.hasClass("color-orange")){ notice_icon.removeClass("color-orange"); } if(notice_icon.hasClass("fa-times-circle")){ notice_icon.removeClass("fa-times-circle"); } $(this).next().next(".new-login-error").hide(); }); }); //---------------------------身份认证-----------------------------// function user_auth_submit(type, url){ if(type == '0'){ if($("#upload_img_pro_sign").val() == 1 && $("#upload_img_id_sign").val() == 1){ op_confirm_box(url ,"认证信息只能提交一次,不能随意修改,请慎重填写
你是否确定提交?"); } else{ long_notice_box("请先上传相应证明照片"); } } else{ if($("#upload_img_pro_sign").val() == 1 || $("#upload_img_id_sign").val() == 1){ op_confirm_box(url ,"认证信息只能提交一次,不能随意修改,请慎重填写
你是否确定提交?"); } else{ long_notice_box("请重新上传相应证明照片"); } } } //---------------------------更改或绑定邮箱/手机号-----------------------------// $(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-circle").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-circle").addClass("color-light-green"); $phone_correct = true; } else { $('#user_phone_notice').html('该手机号已被绑定'); $('#user_phone_notice').parent().show(); $("#user_phone_check").removeClass("fa-check-circle").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-zA-Z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/.test(this.value) == false){ $('#user_phone_hint').show(); $('#user_phone_notice').html('邮箱地址格式不对'); $('#user_phone_notice').parent().show(); $("#user_email_check").removeClass("fa-check-circle").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-circle").addClass("color-light-green"); $mail_correct = true; } else { $('#user_phone_notice').html('该邮箱已被绑定'); $('#user_phone_notice').parent().show(); $("#user_email_check").removeClass("fa-check-circle").removeClass("color-light-green").addClass("fa-times-circle").addClass("color-orange"); $mail_correct = false; } }); } }); $("#get_verification_code").on('click', function(){ btn = this; if($(this).attr("disabled")){ return false; } else{ 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); var uurl = gotoEmail(data.link); $("#send_success_notice").html("验证码已发送到您的邮箱,去查收"); $("#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); } }); function pro_certification(){ $("#no_certification_box").hide(); $("#professional_certification_box").show(); } function real_certification(){ $("#no_certification_box").hide(); $("#auth_certification_box").show(); } function submit_pro_certification(){ var check = true; if ($("#userIdentity").val() == "-1") { $("#identity_hint").show(); check = false; } else{ $("#identity_hint").hide(); } if ($("#teacher").is(":visible") == true && $("#teacher").val() == "0") { $("#identity_hint").show(); check = false; } else{ $("#identity_hint").hide(); } if ($("#user_student_id").parent().is(":visible") == true && ($("#user_student_id").val() == "" || !/^[0-9]\d*$/.test($("#user_student_id").val().trim()))) { $("#user_student_id").focus(); $("#student_id_hint").show(); e.stopImmediatePropagation(); return; } else{ $("#student_id_hint").hide(); } // 单位或高校必须从下拉列表中选择 if ($("input[name='school']").val().trim() == '' || ($("input[name='school']").val().trim() != '' && $("input[name='occupation']").val().trim() == '')) { //学校名字和id不对的话 $("#school_name_hint").show(); check = false; } else{ $("#school_name_hint").hide(); } // if($("#user_student_id").parent().is(":visible") == false){ if($("#upload_img_pro_sign").val() != "1"){ check = false; notice_box("请上传职业证的正面照"); } // } if(check){ if ($("#user_student_id").parent().is(":visible") == true && $("#user_student_id").val() != ""){ $.ajax({ url: '/account/check_student_id', type: 'post', data: {student_id:$("#user_student_id").val(), school_id:$("input[name='occupation']").val()}, success: function(data){ if(data.result == 0){ notice_box("该学号已被另一个账号(" + data.account + ")使用"); } else if (data.result == 1){ if($("#user_certi_school_id").length == 1 && $("#user_certi_school_id").val() != $("input[name='occupation']").val().trim()){ var htmlvalue = '
提示
'+ '

修改单位名称后需要重新申请试用授权

取消'+ '确定
'; pop_box_new(htmlvalue, 480, 160); } else{ $('#my_pro_certification_form').submit(); } } } }); } else{ if($("#user_certi_school_id").length == 1 && $("#user_certi_school_id").val() != $("input[name='occupation']").val().trim()){ var htmlvalue = '
提示
'+ '

修改单位名称后需要重新申请试用授权

取消'+ '确定
'; pop_box_new(htmlvalue, 480, 160); } else{ $('#my_pro_certification_form').submit(); } } } }