import{d as D,N as O,a as d,b as o,w as t,au as $,av as h,aA as S,ai as U,J as v,a5 as z,r as u,o as V,Z as b,Y as P,a1 as y,v as c}from"./vendor-Cv2dYodt.js";import{_ as q}from"./index-D5nbxFF0.js";const N=D({name:"forget-password",components:{UserOutlined:$,LockOutlined:h,SafetyCertificateOutlined:S},setup(){const e=U(),a=v(),f=v(!1),m=v(0),i=z({username:"",verification_code:"",new_password:"",confirm_password:""});return{forgetPasswordForm:a,formData:i,rules:{username:[{required:!0,message:"请输入用户名或手机号"},{min:4,message:"用户名长度不能小于4位"}],verification_code:[{required:!0,message:"请输入验证码"},{len:6,message:"验证码长度必须为6位"}],new_password:[{required:!0,message:"请输入新密码"},{min:6,message:"密码长度不能小于6位"}],confirm_password:[{required:!0,message:"请确认新密码"},{validator:(r,n)=>n&&n!==i.new_password?Promise.reject("两次输入的密码不一致"):Promise.resolve()}]},loading:f,countdown:m,handleSubmit:async()=>{var r,n;try{f.value=!0,await a.value.validate();const s=await y.post("https://aiapi.raycos.com.cn/user/forget_password",{username:i.username,verification_code:i.verification_code,new_password:i.new_password,confirm_password:i.confirm_password});s.data.code===200?(c.success("密码重置成功"),e.push("/login")):c.error(s.data.message||"密码重置失败")}catch(s){console.error("密码重置失败:",s),c.error(((n=(r=s.response)==null?void 0:r.data)==null?void 0:n.message)||"密码重置失败，请检查输入信息")}finally{f.value=!1}},sendVerificationCode:async()=>{var r,n;try{await a.value.validateFields(["username"]);const s=await y.post("https://aiapi.raycos.com.cn/user/send_verification_code",{mobile:i.username});if(s.data.code===200){c.success("验证码发送成功"),m.value=60;const p=setInterval(()=>{m.value--,m.value<=0&&clearInterval(p)},1e3)}else c.error(s.data.message||"验证码发送失败")}catch(s){console.error("验证码发送失败:",s),c.error(((n=(r=s.response)==null?void 0:r.data)==null?void 0:n.message)||"验证码发送失败")}}}}}),B={class:"forget-password-page"},F={class:"forget-password-container"},I={class:"forget-password-content"},L={class:"verification-code-input"},j={class:"form-footer"};function A(e,a,f,m,i,C){const w=u("UserOutlined"),_=u("a-input"),r=u("a-form-item"),n=u("SafetyCertificateOutlined"),s=u("a-button"),p=u("LockOutlined"),g=u("a-input-password"),k=u("a-form");return V(),O("div",B,[d("div",F,[d("div",I,[a[6]||(a[6]=d("div",{class:"forget-password-header"},[d("h2",null,"重置密码"),d("p",{class:"sub-title"},"请填写以下信息以重置您的密码")],-1)),o(k,{ref:"forgetPasswordForm",model:e.formData,rules:e.rules,layout:"vertical"},{default:t(()=>[o(r,{label:"用户名或手机号",name:"username"},{default:t(()=>[o(_,{value:e.formData.username,"onUpdate:value":a[0]||(a[0]=l=>e.formData.username=l),placeholder:"请输入用户名或手机号",size:"large"},{prefix:t(()=>[o(w,{style:{color:"rgba(0,0,0,.25)"}})]),_:1},8,["value"])]),_:1}),o(r,{label:"验证码",name:"verification_code"},{default:t(()=>[d("div",L,[o(_,{value:e.formData.verification_code,"onUpdate:value":a[1]||(a[1]=l=>e.formData.verification_code=l),placeholder:"请输入验证码",size:"large"},{prefix:t(()=>[o(n,{style:{color:"rgba(0,0,0,.25)"}})]),_:1},8,["value"]),o(s,{disabled:!!e.countdown||!e.formData.username,onClick:e.sendVerificationCode,size:"large"},{default:t(()=>[b(P(e.countdown?`${e.countdown}秒后重试`:"获取验证码"),1)]),_:1},8,["disabled","onClick"])])]),_:1}),o(r,{label:"新密码",name:"new_password"},{default:t(()=>[o(g,{value:e.formData.new_password,"onUpdate:value":a[2]||(a[2]=l=>e.formData.new_password=l),placeholder:"请输入新密码",size:"large"},{prefix:t(()=>[o(p,{style:{color:"rgba(0,0,0,.25)"}})]),_:1},8,["value"])]),_:1}),o(r,{label:"确认新密码",name:"confirm_password"},{default:t(()=>[o(g,{value:e.formData.confirm_password,"onUpdate:value":a[3]||(a[3]=l=>e.formData.confirm_password=l),placeholder:"请再次输入新密码",size:"large"},{prefix:t(()=>[o(p,{style:{color:"rgba(0,0,0,.25)"}})]),_:1},8,["value"])]),_:1}),o(r,null,{default:t(()=>[o(s,{type:"primary",loading:e.loading,size:"large",block:"",onClick:e.handleSubmit},{default:t(()=>a[5]||(a[5]=[b(" 重置密码 ")])),_:1},8,["loading","onClick"])]),_:1}),d("div",j,[d("a",{onClick:a[4]||(a[4]=l=>e.$router.push("/login")),class:"back-to-login"},"返回登录")])]),_:1},8,["model","rules"])])])])}const R=q(N,[["render",A],["__scopeId","data-v-0e9ffc51"]]);export{R as default};
