PageSourceSearch

https://peisa.com.pe/_nuxt/BX3OOcB8.js

js peisa.com.pe collected 2026-09-27 01:02:49 UTC 10,833 bytes, 1 lines download raw bytes

1import{_ as A}from"./D9LKWYn9.js";import{d as O,j as H,H as W,u as G,r as D,s as J,c as u,b as a,J as K,f as t,K as d,N as Y,t as N,L as g,G as b,g as w,ad as M,W as F,e as k,a as q,w as V,z as y,h as p,o as c,_ as Q}from"./C-pd9DEJ.js";import{i as X}from"./DHyWn9Or.js";import{d as Z,e as ee}from"./BnIg87eC.js";import{u as oe}from"./Duz9RtaY.js";const te={class:"auth-page"},ae={class:"auth-container"},se={class:"auth-card"},re={key:0,class:"form-row"},le={class:"form-group form-group--narrow"},ne={class:"form-group form-group--wide"},ie={class:"form-label",for:"documentNumber"},ue={class:"input-group"},de=["placeholder","maxlength","inputmode","pattern"],ce=["disabled"],me={key:0,class:"btn__spinner"},pe={key:1},ve={key:0,class:"form-error",role:"alert"},fe={key:1,class:"form-group"},be=["readonly"],ge={key:0,class:"form-help"},ye={class:"form-row"},he={class:"form-group"},_e=["placeholder","readonly","required"],Ne={class:"form-group"},we=["placeholder","readonly","required"],ke={class:"form-group"},Te={class:"form-group"},xe={class:"form-group"},Ce={class:"input-group"},Se=["type"],Ue={class:"form-group"},ze={class:"input-group"},Le=["type"],De={class:"form-group"},Me={class:"form-check"},qe={class:"form-check__label"},Ve=["disabled"],Ee={key:0,class:"btn__spinner"},Pe={key:1},Re={class:"auth-footer"},$e=O({__name:"registro",setup(Be){const E=H(),v=W(),r=oe(),{storeName:P,usesPeruvianBilling:S}=G(),e=y({documentType:"dni",documentNumber:"",firstName:"",lastName:"",razonSocial:"",invoiceDireccion:"",invoiceUbigeo:"",email:"",phone:"",password:"",confirmPassword:"",acceptTerms:!1}),x=y(!1),C=y(!1),h=y(!1),f=y(null),m=y(!1),R={dni:"DNI",ruc:"RUC",ce:"C.E.",passport:"Pasaporte"},i=p(()=>e.value.documentType==="ruc"),U=p(()=>R[e.value.documentType]),$=p(()=>e.value.documentType==="dni"?"12345678":i.value?"20123456789":"Número de documento"),B=p(()=>Z(e.value.documentType)),T=p(()=>e.value.documentType==="dni"||i.value),z=p(()=>ee(e.value.documentType,e.value.documentNumber)),L=p(()=>T.value&&z.value&&!h.value),_=p(()=>!i.value);D(()=>e.value.documentType,()=>{e.value.documentNumber="",e.value.firstName="",e.value.lastName="",e.value.razonSocial="",e.value.invoiceDireccion="",e.value.invoiceUbigeo="",f.value=null,m.value=!1}),D(()=>e.value.documentNumber,()=>{m.value=!1,f.value=null,i.value&&(e.value.razonSocial="",e.value.invoiceDireccion="",e.value.invoiceUbigeo="")});async function I(){if(L.value){h.value=!0,f.value=null;try{const n=await $fetch(`/api/storefront/document-lookup/${e.value.documentNumber}`,{params:{type:e.value.documentType}});if(!n.success||!n.data){const l=n.message||"No encontramos ese número de documento";f.value=l,r.error(l);return}const o=n.data;if(e.value.documentType==="dni")e.value.firstName=o.nombres||"",e.value.lastName=`${o.apellidoPaterno||""} ${o.apellidoMaterno||""}`.trim(),e.value.razonSocial="";else if(e.value.razonSocial=o.razonSocial||"",e.value.invoiceDireccion=o.direccion||"",e.value.invoiceUbigeo=o.ubigeo||"",e.value.documentNumber.startsWith("10")){const l=(o.razonSocial||"").split(" ");l.length>=2&&(e.value.lastName=l.slice(0,Math.ceil(l.length/2)).join(" "),e.value.firstName=l.slice(Math.ceil(l.length/2)).join(" "))}m.value=!0,r.success("Datos encontrados")}catch(n){const o=n instanceof Error?n.message:"Error al consultar documento";f.value=o,r.error(o)}finally{h.value=!1}}}async function j(){if(_.value&&(!e.value.firstName.trim()||!e.value.lastName.trim())){r.error("Nombre y apellido son obligatorios");return}if(i.value&&!e.value.razonSocial.trim()){r.error("La razón social es obligatoria para registrarte con RUC");return}if(!X(e.value.email)){r.error("Ingresa un email válido");return}if(e.value.password.length<8){r.error("La contraseña debe tener al menos 8 caracteres");return}if(e.value.password!==e.value.confirmPassword){r.error("Las contraseñas no coinciden");return}if(e.value.documentNumber&&!z.value){r.error(`El número de ${U.value} no es válido`);return}if(!e.value.acceptTerms){r.error("Debes aceptar los términos y condiciones");return}try{await v.register({email:e.value.email,password:e.value.password,firstName:e.value.firstName,lastName:e.value.lastName,phone:e.value.phone,documentType:e.value.documentType,documentNumber:e.value.documentNumber,razonSocial:e.value.razonSocial,invoiceDireccion:e.value.invoiceDireccion,invoiceUbigeo:e.value.invoiceUbigeo,acceptTerms:e.value.acceptTerms}),r.success("Cuenta creada exitosamente. Por favor inicia sesión."),E.push("/"),v.openLoginModal()}catch(n){const o=n;if(o.statusCode===409||o.data?.error?.includes("ya está registrado"))r.error("Este email ya está registrado. Intenta iniciar sesión.");else{const l=o.data?.error||(n instanceof Error?n.message:"Error al registrarse");r.error(l)}}}return J({title:()=>`Crear cuenta | ${P.value}`}),(n,o)=>{const l=A;return c(),u("div",te,[a("div",ae,[a("div",se,[o[27]||(o[27]=a("div",{class:"auth-header"},[a("h1",{class:"auth-title"},"Crear cuenta"),a("p",{class:"auth-subtitle"},"Regístrate para comenzar a comprar")],-1)),a("form",{class:"auth-form",onSubmit:K(j,["prevent"])},[t(S)?(c(),u("div",re,[a("div",le,[o[14]||(o[14]=a("label",{class:"form-label",for:"documentType"},"Tipo Doc.",-1)),d(a("select",{id:"documentType","onUpdate:modelValue":o[0]||(o[0]=s=>t(e).documentType=s),class:"form-select"},[...o[13]||(o[13]=[a("option",{value:"dni"},"DNI",-1),a("option",{value:"ruc"},"RUC",-1),a("option",{value:"ce"},"C.E.",-1),a("option",{value:"passport"},"Pasaporte",-1)])],512),[[Y,t(e).documentType]])]),a("div",ne,[a("label",ie,N(t(U)),1),a("div",ue,[d(a("input",{id:"documentNumber","onUpdate:modelValue":o[1]||(o[1]=s=>t(e).documentNumber=s),type:"text",class:"form-input",placeholder:t($),maxlength:t(B),inputmode:t(T)?"numeric":"text",pattern:t(T)?"[0-9]*":void 0},null,8,de),[[g,t(e).documentNumber]]),t(T)?(c(),u("button",{key:0,t
1ype:"button",class:b(["btn btn--secondary input-group__btn",{"btn--loading":t(h)}]),disabled:!t(L),onClick:I},[t(h)?(c(),u("span",me)):(c(),u("span",pe,"Consultar"))],10,ce)):w("",!0)]),t(f)?(c(),u("span",ve,N(t(f)),1)):w("",!0)])])):w("",!0),t(S)&&t(i)?(c(),u("div",fe,[o[15]||(o[15]=a("label",{class:"form-label form-label--required",for:"razonSocial"},"Razón Social",-1)),d(a("input",{id:"razonSocial","onUpdate:modelValue":o[2]||(o[2]=s=>t(e).razonSocial=s),type:"text",class:b(["form-input",{"form-input--readonly":t(m)}]),placeholder:"Nombre de la empresa",readonly:t(m),required:""},null,10,be),[[g,t(e).razonSocial]]),t(e).invoiceDireccion?(c(),u("span",ge," Domicilio fiscal: "+N(t(e).invoiceDireccion),1)):w("",!0)])):w("",!0),a("div",ye,[a("div",he,[a("label",{class:b(["form-label",{"form-label--required":t(_)}]),for:"firstName"},N(t(i)?"Nombre de contacto":"Nombre"),3),d(a("input",{id:"firstName","onUpdate:modelValue":o[3]||(o[3]=s=>t(e).firstName=s),type:"text",class:b(["form-input",{"form-input--readonly":t(m)&&t(e).firstName}]),placeholder:t(i)?"Opcional":"Tu nombre",readonly:t(m)&&!!t(e).firstName,required:t(_),autocomplete:"given-name"},null,10,_e),[[g,t(e).firstName]])]),a("div",Ne,[a("label",{class:b(["form-label",{"form-label--required":t(_)}]),for:"lastName"},N(t(i)?"Apellido de contacto":"Apellido"),3),d(a("input",{id:"lastName","onUpdate:modelValue":o[4]||(o[4]=s=>t(e).lastName=s),type:"text",class:b(["form-input",{"form-input--readonly":t(m)&&t(e).lastName}]),placeholder:t(i)?"Opcional":"Tu apellido",readonly:t(m)&&!!t(e).lastName,required:t(_),autocomplete:"family-name"},null,10,we),[[g,t(e).lastName]])])]),a("div",ke,[o[16]||(o[16]=a("label",{class:"form-label form-label--required",for:"email"},"Correo electrónico",-1)),d(a("input",{id:"email","onUpdate:modelValue":o[5]||(o[5]=s=>t(e).email=s),type:"email",class:"form-input",placeholder:"[email protected]",required:"",autocomplete:"email"},null,512),[[g,t(e).email]])]),a("div",Te,[o[17]||(o[17]=a("label",{class:"form-label",for:"phone"},"Teléfono (opcional)",-1)),d(a("input",{id:"phone","onUpdate:modelValue":o[6]||(o[6]=s=>t(e).phone=s),type:"tel",class:"form-input",placeholder:"+51 999 888 777",autocomplete:"tel"},null,512),[[g,t(e).phone]])]),a("div",xe,[o[19]||(o[19]=a("label",{class:"form-label form-label--required",for:"password"},"Contraseña",-1)),a("div",Ce,[d(a("input",{id:"password","onUpdate:modelValue":o[7]||(o[7]=s=>t(e).password=s),type:t(x)?"text":"password",class:"form-input",placeholder:"Mínimo 8 caracteres",required:"",minlength:"8",autocomplete:"new-password"},null,8,Se),[[M,t(e).password]]),a("button",{type:"button",class:"input-group__addon input-group__addon--clickable",onClick:o[8]||(o[8]=s=>x.value=!t(x))},[...o[18]||(o[18]=[a("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[a("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),a("circle",{cx:"12",cy:"12",r:"3"})],-1)])])])]),a("div",Ue,[o[21]||(o[21]=a("label",{class:"form-label form-label--required",for:"confirmPassword"},"Confirmar contraseña",-1)),a("div",ze,[d(a("input",{id:"confirmPassword","onUpdate:modelValue":o[9]||(o[9]=s=>t(e).confirmPassword=s),type:t(C)?"text":"password",class:"form-input",placeholder:"Repite tu contraseña",required:"",minlength:"8",autocomplete:"new-password"},null,8,Le),[[M,t(e).confirmPassword]]),a("button",{type:"button",class:"input-group__addon input-group__addon--clickable",onClick:o[10]||(o[10]=s=>C.value=!t(C))},[...o[20]||(o[20]=[a("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[a("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),a("circle",{cx:"12",cy:"12",r:"3"})],-1)])])])]),a("div",De,[a("label",Me,[d(a("input",{"onUpdate:modelValue":o[11]||(o[11]=s=>t(e).acceptTerms=s),type:"checkbox",class:"form-check__input",required:""},null,512),[[F,t(e).acceptTerms]]),a("span",qe,[o[24]||(o[24]=k(" Acepto los ",-1)),q(l,{to:"/politicas/terminos",class:"auth-link"},{default:V(()=>[...o[22]||(o[22]=[k("términos y condiciones",-1)])]),_:1}),o[25]||(o[25]=k(" y la ",-1)),q(l,{to:"/politicas/privacidad",class:"auth-link"},{default:V(()=>[...o[23]||(o[23]=[k("política de privacidad",-1)])]),_:1})])])]),a("button",{type:"submit",class:b(["btn btn--primary btn--block btn--lg",{"btn--loading":t(v).isLoading}]),disabled:t(v).isLoading},[t(v).isLoading?(c(),u("span",Ee)):(c(),u("span",Pe,"Crear cuenta"))],10,Ve)],32),a("div",Re,[a("p",null,[o[26]||(o[26]=k(" ¿Ya tienes una cuenta? ",-1)),a("button",{type:"button",class:"auth-link",onClick:o[12]||(o[12]=(...s)=>t(v).openLoginModal&&t(v).openLoginModal(...s))}," Iniciar sesión ")])])])])])}}}),We=Q($e,[["__scopeId","data-v-efccd40e"]]);export{We as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.