filesbox/web/dist/design/designstatic/front/js/password.js
2024-07-26 14:10:54 +08:00

2 lines
5.3 KiB
JavaScript

var wapurl=window.location.origin+"/pages/wap/password.html"+window.location.search;/Android|webOS|iPhone|iPod|iPad|BlackBerry/i.test(navigator.userAgent)&&(window.location.href=wapurl);var passbtnon=$(".find_back_box .password_form").eq(0),passbtntw=$(".find_back_box .password_form").eq(1),passbtnth=$(".find_back_box .password_form").eq(2);passbtnon.on("click",".next",function(){retrieveone()}),passbtntw.on("click",".next",function(){setpass()}),$(".get_code").on("click",function(){validate()});var tel="",code="";function validate(){tel=$("#find_pwd_tel").val(),code=$("#find_pwd_code").val(),tel==""?($("#find_pwd_tel").parent().find(".tips").addClass("show").text("\u624B\u673A\u53F7\u4E0D\u80FD\u4E3A\u7A7A"),$("#find_pwd_tel").focus()):/^[1](([3][0-9])|([4][5-9])|([5][0-3,5-9])|([6][5,6])|([7][0-8])|([8][0-9])|([9][1,8,9]))[0-9]{8}$/.test(tel)?($("#find_pwd_tel").parent().find(".tips").removeClass("show"),$.ajax({type:"POST",headers:{token:getCookie("token")},url:"/api/school/sendforgetPassword?projectid=45",contentType:"application/json",dataType:"json",data:JSON.stringify({mobilePhone:tel||""}),async:!0,success:function(e){if(e.code==200){let t=function(i){if(d==1){i.attr("disabled",!1),i.show(),$(".disableds").hide(),d=60;return}else $(".disableds").attr("disabled",!0),i.hide(),$(".disableds").show().val("\u91CD\u65B0\u53D1\u9001("+d+")"),d--;setTimeout(function(){t(i)},1e3)};var n=t,d=60,s=$(".get_code");t(s)}else e.code==601?($("#find_pwd_tel").parent().find(".tips").addClass("show").text("\u53D1\u9001\u9A8C\u8BC1\u7801\u5931\u8D25,\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458\uFF01"),$("#find_pwd_tel").focus()):e.code==400?($("#find_pwd_tel").parent().find(".tips").addClass("show").text("\u8BE5\u624B\u673A\u53F7\u53D1\u9001\u9A8C\u8BC1\u7801\u8FBE\u5230\u4E0A\u9650\uFF01"),$("#find_pwd_tel").focus()):e.code==404&&($("#find_pwd_tel").parent().find(".tips").addClass("show").text("\u624B\u673A\u53F7\u7801\u672A\u6CE8\u518C\uFF01"),$("#find_pwd_tel").focus())}})):($("#find_pwd_tel").parent().find(".tips").addClass("show").text("\u624B\u673A\u53F7\u7801\u4E0D\u6B63\u786E"),$("#find_pwd_tel").focus())}function retrieveone(){tel=$("#find_pwd_tel").val(),code=$("#find_pwd_code").val(),tel==""?($("#find_pwd_tel").parent().find(".tips").addClass("show").text("\u624B\u673A\u53F7\u4E0D\u80FD\u4E3A\u7A7A"),$("#find_pwd_tel").focus()):/^[1](([3][0-9])|([4][5-9])|([5][0-3,5-9])|([6][5,6])|([7][0-8])|([8][0-9])|([9][1,8,9]))[0-9]{8}$/.test(tel)?$.ajax({type:"GET",url:"/api/user/phone/check?projectid=10",contentType:"application/json;charset=utf-8",dataType:"json",data:{mobilePhone:tel},success:function(e){e.data==!0?($("#find_pwd_tel").parent().find(".tips").removeClass("show"),code==""?($("#find_pwd_code").parent().find(".tips").addClass("show").text("\u9A8C\u8BC1\u7801\u4E0D\u80FD\u4E3A\u7A7A"),$("#find_pwd_code").focus()):($("#find_pwd_code").parent().find(".tips").removeClass("show"),$.ajax({type:"post",url:"/api/user/checkVerificationCode?projectid=45",contentType:"application/json;charset=utf-8",dataType:"json",data:JSON.stringify({code,detail:tel}),success:function(d){d.code==200?($("#find_pwd_code").parent().find(".tips").removeClass("show"),$(".step_progress li").eq(1).addClass("on"),passbtnon.hide(),passbtntw.show()):($("#find_pwd_code").parent().find(".tips").addClass("show").text("\u9A8C\u8BC1\u7801\u9519\u8BEF!"),$("#find_pwd_code").focus())}}))):($("#find_pwd_tel").parent().find(".tips").addClass("show").text("\u624B\u673A\u53F7\u7801\u672A\u6CE8\u518C!"),$("#find_pwd_tel").focus())}}):($("#find_pwd_tel").parent().find(".tips").addClass("show").text("\u624B\u673A\u53F7\u7801\u672A\u6CE8\u518C"),$("#find_pwd_tel").focus())}function setpass(){tel=$("#find_pwd_tel").val(),code=$("#find_pwd_code").val();var e=$("#find_pwd_one").val(),d=$("#find_pwd_two").val();e==""?($("#find_pwd_one").parent().find(".tips").addClass("show").text("\u5BC6\u7801\u4E0D\u80FD\u4E3A\u7A7A"),$("#find_pwd_one").focus()):/^.*(?=.{8,20})(?=.*\d)(?=.*[a-zA-Z!@#$%^&*? ]).*$/.test(e)?($("#find_pwd_one").parent().find(".tips").removeClass("show"),d==""?($("#find_pwd_two").parent().find(".tips").addClass("show").text("\u786E\u8BA4\u5BC6\u7801\u4E0D\u80FD\u4E3A\u7A7A"),$("#find_pwd_two").focus()):d==e?($("#find_pwd_two").parent().find(".tips").removeClass("show"),$.ajax({type:"PUT",headers:{token:getCookie("token")},url:"/api/user/setPwd?projectid=45",contentType:"application/json",dataType:"json",data:JSON.stringify({code,detail:tel,password:e}),async:!0,success:function(s){s.code==200?($("#find_pwd_code").parent().find(".tips").removeClass("show"),$(".step_progress li").eq(2).addClass("on"),passbtntw.hide(),passbtnth.show(),setTimeout(alertFunc,2e3)):layer.alert("\u627E\u56DE\u5931\u8D25,\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458\uFF01")}})):($("#find_pwd_two").parent().find(".tips").addClass("show").text("\u4E24\u6B21\u8F93\u5165\u7684\u5BC6\u7801\u4E0D\u4E00\u81F4"),$("#find_pwd_two").focus())):($("#find_pwd_one").parent().find(".tips").addClass("show").text("\u5BC6\u7801\u7531\u5B57\u6BCD\u52A0\u6570\u5B57\u81F3\u5C11\u4E24\u79CD\u4EE5\u4E0A\u5B57\u7B26\u7EC4\u6210\u76848-20\u4F4D\u5B57\u7B26"),$("#find_pwd_one").focus())}function alertFunc(){window.location.href=window.location.origin}function getCookie(e){for(var d=document.cookie,s=d.split("; "),n=0;n<s.length;n++){var t=s[n].split("=");if(t[0]==e)return t[1]}return""}