useLogin-ddffa293.js 1.9 KB

1
  1. var O=Object.defineProperty;var h=Object.getOwnPropertySymbols;var b=Object.prototype.hasOwnProperty,y=Object.prototype.propertyIsEnumerable;var p=(e,o,r)=>o in e?O(e,o,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[o]=r,F=(e,o)=>{for(var r in o||(o={}))b.call(o,r)&&p(e,r,o[r]);if(h)for(var r of h(o))y.call(o,r)&&p(e,r,o[r]);return e};var R=(e,o,r)=>new Promise((n,u)=>{var g=s=>{try{i(r.next(s))}catch(c){u(c)}},P=s=>{try{i(r.throw(s))}catch(c){u(c)}},i=s=>s.done?n(s.value):Promise.resolve(s.value).then(g,P);i((r=r.apply(e,o)).next())});import{r as I,e as l,l as t,f as a}from"./index-610a1d46.js";var _=(e=>(e[e.LOGIN=0]="LOGIN",e[e.REGISTER=1]="REGISTER",e[e.RESET_PASSWORD=2]="RESET_PASSWORD",e[e.MOBILE=3]="MOBILE",e[e.QR_CODE=4]="QR_CODE",e))(_||{});const w=I(0);function T(){function e(n){w.value=n}const o=l(()=>w.value);function r(){e(0)}return{setLoginState:e,getLoginState:o,handleBackLogin:r}}function j(e){function o(){return R(this,null,function*(){const r=a(e);return r?yield r.validate():void 0})}return{validForm:o}}function A(e){const o=l(()=>m(t.login.accountPlaceholder)),r=l(()=>m(t.login.passwordPlaceholder)),n=l(()=>m(t.login.smsPlaceholder)),u=l(()=>m(t.login.mobilePlaceholder)),g=(s,c)=>R(this,null,function*(){return c?Promise.resolve():Promise.reject(t.login.policyPlaceholder)}),P=s=>(c,d)=>R(this,null,function*(){return d?d!==s?Promise.reject(t.login.diffPwd):Promise.resolve():Promise.reject(t.login.passwordPlaceholder)});return{getFormRules:l(()=>{const s=a(o),c=a(r),d=a(n),v=a(u),f={sms:d,mobile:v};switch(a(w)){case 1:return F({account:s,password:c,confirmPassword:[{validator:P(e==null?void 0:e.password),trigger:"change"}],policy:[{validator:g,trigger:"change"}]},f);case 2:return F({account:s},f);case 3:return f;default:return{account:s,password:c}}})}}function m(e){return[{required:!0,message:e,trigger:"change"}]}export{_ as L,A as a,j as b,T as u};