var systemPath = "http://cs1.zhizhuchuxing.com"; //初始化 第一步 $(function(){ var find_height = $(window).height()-34; $(".find_box").height(find_height); findPwdStep.findStepFirst(); }); var findPwdStep = { step:0, wait:60, userId:"", userPhone:"", backLogin:function(){ window.location.href="http://cs.zhizhuchuxing.com"; }, findStepFirst:function(){ stepBar.init("navStep",0); $(".pwd_box_p1").show(); $(".pwd_box_p2").hide(); $(".pwd_box_p3").hide(); $(".pwd_box_p4").hide(); $("#step_first").on("click",function(){ var user = $('#user').val(); if(user == ''){ $("#submit_warning1").text("请输入帐号"); return; } $.ajax({ url: systemPath+"/api/login/get-account-info", data: {account_name:user}, type: 'post', dataType: "json", success: function (data) { console.log(data); if (data.code == 0) { //success stepBar.init("navStep",1); findPwdStep.findStepSecond(data.data); } else { $("#submit_warning1").text(data.message); } }, error: function (msg) { $("#submit_warning1").text('系统错误,请联系管理员'); } }); }); }, findStepSecond:function(data){ $(".pwd_box_p1").hide(); $(".pwd_box_p2").show(); $(".pwd_box_p3").hide(); $(".pwd_box_p4").hide(); var phoneNoText = data.user_mobile; var user_id = data.user_id; this.userId = data.user_id; this.userPhone = data.user_mobile; if(phoneNoText != ""){ phoneNoText = phoneNoText.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2'); }else{ phoneNoText = "未绑定手机"; } $("#bind_phone_no").text(phoneNoText); //有无手机的top切换 $("#have_tel").on("click",function(){ $(this).addClass("cut_sel"); $(this).removeClass("cut_nosel"); $("#submit_warning2").text(''); $("#nothave_tel").addClass("cut_nosel"); $("#nothave_tel").removeClass("cut_sel"); $("#bind_phone_no").show(); $("#no_tel").hide(); $("#control_code").show(); }); $("#nothave_tel").on("click",function(){ $(this).addClass("cut_sel"); $(this).removeClass("cut_nosel"); $("#submit_warning2").text(''); $("#have_tel").addClass("cut_nosel"); $("#have_tel").removeClass("cut_sel"); $("#bind_phone_no").hide(); $("#no_tel").show(); $("#control_code").hide(); }); //获取验证码 $("#get_code").on("click",function(){ $("#get_code").addClass("code_time"); $("#get_code").removeClass("find_code"); var thisId = $("#get_code") findPwdStep.time(thisId); $("#get_code").off("click"); //获取验证码接口 findPwdStep.getCode(); }); //输入验证码 $("#code_input").on("input",function(){ if($(this).val() != ""){ $("#step_second").addClass("sub_bg_color"); $("#step_second").removeClass("nosub_bg_color"); }else{ $("#step_second").addClass("nosub_bg_color"); $("#step_second").removeClass("sub_bg_color"); } }); //下一步 $("#step_second").on("click",function(){ //判断输入框是否被隐藏; if($("#control_code").is(":visible")){ var inputCode = $("#code_input").val(); if(inputCode == ""){ $("#submit_warning2").text("请输入验证码"); return; } $.ajax({ url: systemPath+"/api/login/check-auth-code", data: {user_id:user_id,input_code:inputCode}, type: 'post', dataType: "json", success: function (data) { console.log(data); if (data.code == 0) { //success stepBar.init("navStep",2); findPwdStep.findStepThird(); } else { $("#submit_warning2").text(data.message); } }, error: function (data) { $("#submit_warning2").text('系统错误,请联系管理员'); } }); }else{ $("#submit_warning2").text(''); } }); }, findStepThird:function(){ $(".pwd_box_p1").hide(); $(".pwd_box_p2").hide(); $(".pwd_box_p3").show(); $(".pwd_box_p4").hide(); var user_id = this.userId; $("#step_third").on("click",function(){ var new_pwd1 = $("#new_pwd").val(); var new_pwd2 = $("#confirm_new_pwd").val(); if(new_pwd1 == ""){ $("#submit_warning3").text('请填写新密码'); return; } if(new_pwd2 == ""){ $("#submit_warning3").text('请确认新密码'); return; } if(new_pwd1 != new_pwd2){ $("#submit_warning3").text('!密码不一致'); return; } $.ajax({ url: systemPath+"/api/login/change-user-password", data: {user_id:user_id,input_pwd:new_pwd1}, type: 'post', dataType: "json", success: function (data) { console.log(data); if (data.code == 0) { //success findPwdStep.findfourth(); } else { $("#submit_warning3").text(data.message); } }, error: function (data) { $("#submit_warning3").text('系统错误,请联系管理员'); } }); }); }, findfourth:function(){ $("#navStep").remove(); $(".pwd_box_p1").hide(); $(".pwd_box_p2").hide(); $(".pwd_box_p3").hide(); $(".pwd_box_p4").show(); }, time:function(id){ if(this.wait == 0){ id.addClass("find_code"); id.removeClass("code_time"); id.text("重新获取"); this.wait = 60; id.on("click",function(){ id.addClass("code_time"); id.removeClass("find_code"); findPwdStep.time(id); id.off("click"); //获取验证码接口 findPwdStep.getCode(); }); }else{ id.text("剩余(" + this.wait + ")"); this.wait--; setTimeout(function() { findPwdStep.time(id); }, 1000) } }, //获取验证码接口 getCode:function(){ $.ajax({ url: systemPath+"/api/login/send-reset-message", data: { user_id:this.userId, user_mobile:this.userPhone }, type: 'post', dataType: "json", success: function (data) { console.log(data); if (data.code == 0) { //success } else { $("#submit_warning2").text(data.message); } }, error: function (msg) { $("#submit_warning2").text('系统错误,请联系管理员'); } }); }, seePwd:function(index){ if($(index).hasClass("pwd_eye_on")){ $(index).removeClass("pwd_eye_on"); $(index).addClass("pwd_eye_off"); $(index).prev("input").attr("type","text"); }else{ $(index).removeClass("pwd_eye_off"); $(index).addClass("pwd_eye_on"); $(index).prev("input").attr("type","password"); } } } //当浏览器大小变化时 $(window).resize(function () { var find_height = $(window).height()-34; $(".find_box").height(find_height); });