import{d as e,r as a,a as l,w as o,o as s,c as n,b as t,e as u,n as i,f as d,t as r,s as m,g as c,h as f,i as b,j as p,k as v,l as h,m as P,p as _}from"./index-72b896ac.js";import{_ as g,a as y,b as w,c as C}from"./logo.1cbcaa3f.js";import{o as V,r as j,_ as k}from"./uni-app.es.e89653c9.js";import{s as x,v as I,m as U,p as $}from"./h5.1f9437c2.js";const q=k(e({__name:"index",setup(e){const k=a(""),q=l({code:"",mobilePhone:""}),M=l({mobilePhone:{rules:[{required:!0,errorMessage:"请输入手机号"}]},code:{rules:[{required:!0,errorMessage:"请输入验证码"}]}}),S=a("获取验证码"),F=a(!1),J=a(60),N=a(null);o((()=>J.value),(e=>{0==e&&(clearInterval(N.value),F.value=!1,S.value="重新获取",J.value=60)}));const O=async()=>{if(q.mobilePhone)if(F.value)m({title:"倒计时结束后再发送",icon:"none"});else{c({title:"正在获取验证码",mask:!0});200===(await x({mobilePhone:q.mobilePhone})).code&&(f(),S.value=`${J.value}S`,F.value=!0,N.value=setInterval((()=>{J.value=J.value-1,S.value=`${J.value}秒重新获取`}),1e3),m({title:"发送成功",icon:"none"}))}else m({title:"请输入手机号",icon:"none"})},R=async()=>{if((await U({mobilePhone:q.mobilePhone})).data){const e=encodeURIComponent(JSON.stringify({unitCode:k.value,mobilePhone:q.mobilePhone}));P({url:`/pages/password/password?parameter=${e}`})}else(async()=>{const e=await $({mobilePhone:q.mobilePhone,prefUnitCode:k.value});if(200===e.code&&(m({title:e.message,icon:"none"}),e.data)){const{userCode:a}=e.data;setTimeout((()=>{_({url:`/pages/result/result?provinceCode=${null==a?void 0:a.slice(0,2)}`})}),800)}})()},T=a(),z=()=>{q.code&&q.mobilePhone&&T.value.validate().then((async e=>{const a=await I(e);200===a.code&&(a.data?R():m({title:"验证码错误",icon:"none"}))}))};return V((e=>{k.value=e.unitCode})),(e,a)=>{const l=b,o=p,m=j(v("uni-easyinput"),y),c=j(v("uni-forms-item"),w),f=j(v("uni-forms"),C),P=h;return s(),n(o,null,{default:t((()=>[u(o,{class:"logo"},{default:t((()=>[u(l,{src:g,mode:"aspectFit"})])),_:1}),u(o,{class:"form"},{default:t((()=>[u(f,{ref_key:"form",ref:T,modelValue:q,rules:M,"label-width":0},{default:t((()=>[u(c,{name:"mobilePhone"},{default:t((()=>[u(m,{type:"number",maxlength:"11",clearable:!1,modelValue:q.mobilePhone,"onUpdate:modelValue":a[0]||(a[0]=e=>q.mobilePhone=e),placeholder:"请输入手机号"},null,8,["modelValue"])])),_:1}),u(c,{name:"code"},{default:t((()=>[u(o,{class:"form-code"},{default:t((()=>[u(m,{type:"number",clearable:!1,modelValue:q.code,"onUpdate:modelValue":a[1]||(a[1]=e=>q.code=e),placeholder:"请输入验证码"},null,8,["modelValue"]),u(o,{class:i(["code",{"code-disabled":F.value}]),onClick:O},{default:t((()=>[d(r(S.value),1)])),_:1},8,["class"])])),_:1})])),_:1})])),_:1},8,["modelValue","rules"]),u(P,{class:i(["submit",{"submit-disabled":!q.code||!q.mobilePhone}]),onClick:z},{default:t((()=>[d("登录")])),_:1},8,["class"])])),_:1})])),_:1})}}}),[["__scopeId","data-v-053a2c31"]]);export{q as default};
