import{b7 as x,u as O,a as T,$ as N,O as S,z as E,aS as I,aT as B,bf as d,a$ as v,b0 as m,ba as M,N as R,cg as A,r,c as D,b8 as F,ad as U,d0 as j,d2 as z,f as W,aX as G}from"./index-xnhGKCfe.js";const X={class:"tip"},Z=x({__name:"bindPassword",emits:["close","jumpWorkOrder"],setup(q,{emit:y}){const n=r(""),c=r(),f=y,p=r(null),s=r({phone:void 0,verifyCode:void 0,newPwd:"",confirmNewPwd:""}),w=W(),{t:o}=O(),{loginOff:h,verifyPhone:l,verifyEmail:g,phone:i}=E(),{isOpenForgetPwdSMS:b,isOpenForgetPwdEmail:k}=T(),u=r(!1),{getVerifyCode:P,loadingText:_}=N(U);async function C(){var a;if((a=p.value)==null?void 0:a.validate("phone")){const t=l.value?i.value:`${n.value}${s.value.phone}`;await P({verifyCodeType:1,codeType:3,phoneOrEmail:t.trim()})}}const V=D(()=>[{key:"phone",icon:"phone",prefix:!0,props:{placeholder:l.value?j(i.value.slice(n.value.length)):o("t782"),type:"text",disabled:l.value},rule:{message:o("t783"),validate:e=>{var t;const a=l.value?i.value.slice(n.value.length):e;return(t=c.value)==null?void 0:t.validPhone(a)}}},{key:"verifyCode",icon:"safe",suffix:!0,props:{placeholder:o("t1122"),type:"text"},rule:{message:o("t1123"),validate:e=>!!e}},{key:"newPwd",icon:"lock",props:{placeholder:o("t901"),type:"password"},rule:{message:o("t901"),validate:e=>!e||!e.trim()?!1:/^[a-zA-Z0-9]{8,32}$/.test(e)}},{key:"confirmNewPwd",icon:"lock",props:{placeholder:o("t1125"),type:"password"},rule:{message:o("t1126"),validate:e=>e===s.value.newPwd},onClick:()=>{}}]);async function $(){if(!u.value)try{u.value=!0;const e=l.value?i.value:`${n.value}${s.value.phone}`,{code:a}=await z({type:"Mobile",userName:`${e}`.trim(),code:s.value.verifyCode,password:s.value.newPwd});a==0&&(w.success(o("t197")),f("close"),await h())}finally{u.value=!1}}return S(()=>{(g.value&&!l.value?!k.value:!b.value)&&f("jumpWorkOrder")}),(e,a)=>(B(),I(F,{ref_key:"formRef",ref:p,modelValue:s.value,"onUpdate:modelValue":a[1]||(a[1]=t=>s.value=t),configs:V.value,confirmText:u.value?e.$t("t1127"):e.$t("t962"),onSubmit:$},{phonePrefix:d(()=>[R(A,{ref_key:"phoneInputRef",ref:c,modelValue:n.value,"onUpdate:modelValue":a[0]||(a[0]=t=>n.value=t),isDialog:!0,disabled:!0},null,8,["modelValue"])]),verifyCodeSuffix:d(()=>[v("button",{class:"send btn_main_style",onClick:C,type:"button"},m(M(_)),1)]),footer:d(()=>[v("div",X,m(e.$t("t810")),1)]),_:1},8,["modelValue","configs","confirmText"]))}}),J=G(Z,[["__scopeId","data-v-6aea0e20"]]);export{J as default};
