var vm=new Vue({el:"#app",data:{phoneResetForm:{mobilePhone:"",messageCode:"",validateCode:""},mailResetForm:{QQ:"",emailYZM:"",customerName:""},passWordForm:{password:"",confirmPassword:""},resetType:0,active:0,step:0,hideClass:"hideActive",sendMailSuccess:!1,content:"获取验证码",totalTime:100,canClick:!0,timer:5},methods:{phoneStepOne:function(){vm.active=1;vm.step=1;vm.resetType=0},phoneStepTwo:function(){vm.validateMobilePhone(function(){axios.post("/ResetPassword/ResetPasswordValidateByMobilePhone",{mobilePhone:vm.phoneResetForm.mobilePhone,validateCode:vm.phoneResetForm.messageCode}).then(function(n){if(n.data.IsSuccess)vm.active=2,vm.step=3;else{vm.getImgValidateCode();vm.$message({message:n.data.Message,type:"error"});return}}).catch(function(){vm.$message({message:"系统延时,请您稍后重试",type:"error"})})},!0)},mailStepOne:function(){vm.active=1;vm.step=2;vm.resetType=1},mailStepTwo:function(){vm.validatMailCustomerQQ(function(){if(!vm.mailResetForm.emailYZM){vm.$message({message:"邮箱验证码必须填写",type:"error"});return}axios.post("/ResetPassword/ResetPasswordValidateByEMail",{email:vm.mailResetForm.QQ+"@qq.com",validateCode:vm.mailResetForm.emailYZM}).then(function(n){if(n.data.IsSuccess)vm.active=2,vm.step=3;else{vm.$message({message:n.data.Message,type:"error"});return}}).catch(function(){vm.$message({message:"系统延时,请您稍后重试",type:"error"})})})},stepThree:function(){if(vm.passWordForm.password){if(vm.passWordForm.password==="123456"||vm.passWordForm.password==="sd/123456/"){vm.$message({message:"你输入的密码为原始密码,为了安全考虑,请输入其他密码!",type:"error"});return}if(/^(?![\d]+$)(?![a-zA-Z]+$)(?![^\da-zA-Z]+$).{8,16}$/.test(vm.passWordForm.password)){if(vm.passWordForm.password!==vm.passWordForm.confirmPassword){vm.$message({message:"两次密码不一致",type:"error"});return}}else{vm.$message({message:"密码长度8-16位,数字、字母、字符至少包含两种",type:"error"});return}}else{vm.$message({message:"密码必须填写",type:"error"});return}vm.resetType===0?axios.post("/ResetPassword/ResetPasswordByMobilePhone",{mobilePhone:vm.phoneResetForm.mobilePhone,password:vm.passWordForm.password}).then(function(n){if(n.data.IsSuccess){vm.active=3;vm.step=4;var t=setInterval(function(){vm.timer-=1;vm.timer>0||(clearInterval(t),location.href="/Login")},1e3)}else vm.$message({message:n.data.Message,type:"error"})}).catch(function(){vm.$message({message:"系统延时,请您稍后重试",type:"error"})}):vm.resetType===1&&axios.post("/ResetPassword/ResetPasswordByEMail",{email:vm.mailResetForm.QQ,password:vm.passWordForm.password}).then(function(n){if(n.data.IsSuccess){vm.active=3;vm.step=4;var t=setInterval(function(){vm.timer-=1;vm.timer>0||(clearInterval(t),location.href="/Login")},1e3)}else vm.$message({message:n.data.Message,type:"error"})}).catch(function(){vm.$message({message:"系统延时,请您稍后重试",type:"error"})})},getImgValidateCode:function(){vm.$refs.imgValidateCode.src="/Common/GetValidateCode?v="+(new Date).getTime()},validateMobilePhone:function(n,t){if(!(vm.phoneResetForm.mobilePhone&&/^1[0-9]{10}$/.test(vm.phoneResetForm.mobilePhone))){vm.$message({message:"手机号未填写或者格式不正确",type:"error"});return}if(!vm.phoneResetForm.validateCode){vm.$message({message:"图形验证码必须填写",type:"error"});return}if(t&&!vm.phoneResetForm.messageCode){vm.$message({message:"短信验证码必须填写",type:"error"});return}axios.post("/Register/IsExistsCustomerByMobilePhone",{mobilePhone:vm.phoneResetForm.mobilePhone}).then(function(t){t.data.IsSuccess?n():axios.post("/Register/IsExistsSubMobilePhone",{mobilePhone:vm.phoneResetForm.mobilePhone}).then(function(n){if(n.data.IsSuccess){vm.$alert("子账号不允许重设密码,请联系您的管理员进行重设密码的操作!","温馨提示",{dangerouslyUseHTMLString:!0});return}vm.$alert("系统中不存在此手机号!","温馨提示",{dangerouslyUseHTMLString:!0});return})}).catch(function(){vm.$message({message:"系统延时,请您稍后重试",type:"error"})})},validatMailCustomerQQ:function(n){if(!(vm.mailResetForm.QQ&&/^[1-9][0-9]{4,9}$/.test(vm.mailResetForm.QQ))){vm.$message({message:"QQ号未填写或者格式不正确",type:"error"});return}axios.post("/ResetPassword/GetCustomerNameByQQ",{QQ:vm.mailResetForm.QQ}).then(function(t){if(t.data.IsSuccess){if(t.data.Message===""){vm.$alert("系统中不存在此QQ号!","温馨提示",{dangerouslyUseHTMLString:!0});return}vm.mailResetForm.customerName=t.data.Message;n()}}).catch(function(){vm.$message({message:"系统延时,请您稍后重试",type:"error"})})},validateImgCode:function(n){axios.post("/Common/validateCode",{code:vm.phoneResetForm.validateCode}).then(function(t){if(t.data.IsSuccess)n();else{vm.$message({message:"图形验证码不正确",type:"error"});vm.getImgValidateCode();return}}).catch(function(){vm.$message({message:"系统延时,请您稍后重试",type:"error"})})},getSMSValidateCode:function(){vm.canClick&&vm.validateMobilePhone(function(){vm.validateImgCode(function(){axios.post("/Common/SendSMSValidateCode",{mobilePhone:vm.phoneResetForm.mobilePhone,imgCode:vm.phoneResetForm.validateCode}).then(function(n){if(n.data.IsSuccess){vm.canClick=!1;vm.content=vm.totalTime+"s后重新发送";var t=setInterval(function(){vm.totalTime--;vm.content=vm.totalTime+"s后重新发送";vm.totalTime<0&&(clearInterval(t),vm.content="重新发送验证码",vm.totalTime=100,vm.canClick=!0)},1e3);vm.$message({message:"短信验证码已成功发送至手机号"+vm.phoneResetForm.mobilePhone+",请注意查收",type:"success"})}else vm.$message({message:n.data.Message,type:"error"}),vm.getImgValidateCode()}).catch(function(){vm.$message({message:"系统延时,请您稍后重试",type:"error"})})})})},getMailValidateCode:function(){vm.canClick&&vm.validatMailCustomerQQ(function(){axios.post("/Common/SendMailValidateCode",{email:vm.mailResetForm.QQ+"@qq.com",customerName:vm.mailResetForm.customerName}).then(function(n){if(n.data.IsSuccess){vm.canClick=!1;vm.content=vm.totalTime+"s后重新发送";var t=setInterval(function(){vm.totalTime--;vm.content=vm.totalTime+"s后重新发送";vm.totalTime<0&&(clearInterval(t),vm.content="重新发送验证码",vm.totalTime=100,vm.canClick=!0)},1e3);vm.sendMailSuccess=!0}else vm.$message({message:n.data.Message,type:"error"})}).catch(function(){vm.$message({message:"系统延时,请您稍后重试",type:"error"})})})}}})