import{d as e,u as l,r as a,q as s,Q as t,c as u,w as n,i as c,b as d,e as o,f as i,h as r,Y as v,m as f,t as p,y as _,P as m,J as b,s as g}from"./index-Co9nPWLO.js";import{_ as h}from"./_plugin-vue_export-helper.BCo6x5W8.js";const x=h(e({__name:"index",setup(e){const h=l(),x=a(""),y=a(""),V=a(0),I=a(!1);let w=null;const k=s(()=>/^1[3-9]\d{9}$/.test(x.value)),C=s(()=>k.value&&!I.value);async function j(){if(!(V.value>0)&&k.value)try{I.value=!0,await h.sendCode(x.value),_({title:"验证码已发送",icon:"success"}),V.value=60,w=setInterval(()=>{V.value--,V.value<=0&&w&&(clearInterval(w),w=null)},1e3)}catch(e){console.error("发送验证码失败:",e)}finally{I.value=!1}}async function U(){if(C.value)if(k.value){I.value=!0;try{const e=y.value||"123456";await h.login(x.value,e),_({title:"登录成功",icon:"success"});m().length>1?b():g({url:"/pages/index/index"})}catch(e){console.error("登录失败:",e),_({title:e.message||"登录失败，请重试",icon:"none"})}finally{I.value=!1}}else _({title:"请输入正确的手机号",icon:"none"})}return t(()=>{w&&(clearInterval(w),w=null)}),(e,l)=>{const a=i,s=c,t=v,_=f;return d(),u(s,{class:"page"},{default:n(()=>[o(s,{class:"header"},{default:n(()=>[o(a,{class:"title"},{default:n(()=>[r("AI有声书")]),_:1}),o(a,{class:"subtitle"},{default:n(()=>[r("让文字变成声音")]),_:1})]),_:1}),o(s,{class:"form-card"},{default:n(()=>[o(a,{class:"form-title"},{default:n(()=>[r("手机号登录")]),_:1}),o(s,{class:"input-group"},{default:n(()=>[o(a,{class:"input-label"},{default:n(()=>[r("手机号")]),_:1}),o(t,{modelValue:x.value,"onUpdate:modelValue":l[0]||(l[0]=e=>x.value=e),type:"number",class:"input",placeholder:"请输入手机号",maxlength:"11"},null,8,["modelValue"])]),_:1}),o(s,{class:"input-group"},{default:n(()=>[o(a,{class:"input-label"},{default:n(()=>[r("验证码")]),_:1}),o(s,{class:"code-row"},{default:n(()=>[o(t,{modelValue:y.value,"onUpdate:modelValue":l[1]||(l[1]=e=>y.value=e),type:"number",class:"input code-input",placeholder:"请输入验证码",maxlength:"6"},null,8,["modelValue"]),o(_,{class:"code-btn",disabled:V.value>0||!k.value,onClick:j},{default:n(()=>[o(a,{class:"code-btn-text"},{default:n(()=>[r(p(V.value>0?`${V.value}s`:"获取验证码"),1)]),_:1})]),_:1},8,["disabled"])]),_:1})]),_:1}),o(_,{class:"login-btn",disabled:!C.value,onClick:U},{default:n(()=>[o(a,{class:"login-btn-text"},{default:n(()=>[r("登录")]),_:1})]),_:1},8,["disabled"]),o(a,{class:"tip"},{default:n(()=>[r("登录即表示同意《用户协议》和《隐私政策》")]),_:1})]),_:1})]),_:1})}}}),[["__scopeId","data-v-d6cea4c7"]]);export{x as default};
