全新popiart网站 react项目重构
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

2 lines
7.9 KiB

import{j as e}from"./markdown-vendor-DnN-_XEd.js";import{u as se,r as s}from"./data-vendor-DOiUz3Tw.js";import{bh as ne,bi as re,R as ie,bj as le,bk as oe,bl as ce,bm as de,bn as ue,bo as ge}from"./index-D1KhT7yD.js";import{E as F,B as N}from"./arco-vendor-Cm-ntj-q.js";import"./react-vendor-B8OyfHW2.js";function we({onClose:S,onSelect:_e}){const{t:a}=se(),V=s.useMemo(()=>new URL("/assets/popiart-Cj-fCJLG.png",import.meta.url).href,[]),[n,G]=s.useState(2),[i,E]=s.useState(""),[u,H]=s.useState(""),[g,J]=s.useState(""),[x,T]=s.useState(!1),[K,L]=s.useState(!1),[he,X]=s.useState(!1),l=s.useRef(null),[f,R]=s.useState(""),[O,I]=s.useState(""),[b,w]=s.useState(""),[o,P]=s.useState(0);s.useEffect(()=>{if(o<=0)return;const t=window.setTimeout(()=>P(r=>r-1),1e3);return()=>window.clearTimeout(t)},[o]);const[y,j]=s.useState(!1),[v,z]=s.useState(""),[q,Y]=s.useState(""),[C,A]=s.useState(""),[W,_]=s.useState(""),[M,Q]=s.useState(!1),U=async()=>{try{const t=await le();z(t.data.id),Y(t.data.data),A(""),_("")}catch{_(a("captcha.load_failed"))}};s.useEffect(()=>{y&&U()},[y]);const[Z,h]=s.useState(!1),d=()=>{l.current!=null&&(window.clearInterval(l.current),l.current=null)},B=s.useCallback(async()=>{d(),w("");try{const t=await ne(),r=t?.data??t,c=String(r?.sceneCode??r?.scene??""),m=String(r?.qrCodeUrl??r?.qrUrl??r?.url??r?.qr_code??"");R(c),I(m)}catch{w(a("auth.wxgh_qr_load_failed"))}},[a]),p=s.useCallback(async t=>{const r=t?.data??t,c=r?.token??t?.token,m=r?.user??t?.user;c&&re(c),typeof window<"u"&&window!==window.parent&&window.parent.postMessage({type:"login",status:"success",data:{token:c??"",user:m??{}}},"*"),S(),window.location.href=ie.EXPLORE},[S]);s.useEffect(()=>()=>{l.current!=null&&(window.clearInterval(l.current),l.current=null)},[]),s.useEffect(()=>{if(n!==3){d(),R(""),I(""),w("");return}B()},[n,B]),s.useEffect(()=>{if(n!==3||!f)return;const t=async()=>{try{const r=await oe(f);(r?.data??r)?.token&&(d(),await p(r))}catch{}};return d(),l.current=window.setInterval(()=>void t(),2e3),()=>d()},[n,f,p]);const k=t=>{G(t)},ee=async()=>{!i||o>0||j(!0)},D=async()=>{const t=C.trim();if(!(!v||!t||M)){Q(!0);try{if((await ue(v,t))?.data?.err===0){await ge(i,"LOGIN",v,t),X(!0),P(60),j(!1);return}_(a("captcha.invalid"))}catch{_(a("captcha.invalid"))}finally{Q(!1)}}},te=async()=>{if(n!==3&&!(n===1&&(!i||!u))&&!(n===2&&(!i||!g))){if(!x){h(!0);return}L(!0);try{if(n===1){const t=await ce(i,u);await p(t)}else if(n===2){const t=await de(i,g);await p(t)}}finally{L(!1)}}},$=!i||o>0,ae=K||n===3||n===1&&(!i||!u)||n===2&&(!i||!g);return e.jsxs("div",{className:"login_register_modal",children:[e.jsxs("header",{className:"login_register_modal_header",children:[e.jsx("img",{src:V,alt:"popiart",className:"login_register_modal_brand_logo"}),e.jsx("p",{className:"login_register_modal_slogan",children:a("auth.slogan")})]}),e.jsxs("section",{className:"login_register_modal_form",children:[e.jsxs("nav",{className:"login_register_modal_tabs",role:"tablist",children:[e.jsx("button",{type:"button",className:`login_register_modal_tab ${n===2?"is_active":""}`,"aria-selected":n===2,onClick:()=>k(2),children:a("auth.login_with_phone_number")}),e.jsx("button",{type:"button",className:`login_register_modal_tab ${n===3?"is_active":""}`,"aria-selected":n===3,onClick:()=>k(3),children:a("auth.login_with_wechat")}),e.jsx("button",{type:"button",className:`login_register_modal_tab ${n===1?"is_active":""}`,"aria-selected":n===1,onClick:()=>k(1),children:a("auth.login_with_password")})]}),e.jsx("div",{className:"login_register_modal_fields",children:n===3?e.jsxs("div",{className:"login_register_modal_wx",children:[b?e.jsx("p",{className:"login_register_modal_wx_error",children:b}):null,O?e.jsx("div",{className:"login_register_modal_wx_qr_wrap",children:e.jsx("img",{src:O,alt:"",className:"login_register_modal_wx_qr"})}):b?null:e.jsx("div",{className:"login_register_modal_wx_placeholder",children:a("common.loading")}),e.jsx("p",{className:"login_register_modal_wx_tip",children:a("auth.login_with_wechat_tip")})]}):n===1?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"login_register_modal_field",children:e.jsx("input",{type:"tel",name:"phoneNumber",placeholder:a("auth.phone_number_input_placeholder"),value:i,onChange:t=>E(t.target.value)})}),e.jsx("div",{className:"login_register_modal_field",children:e.jsx("input",{type:"password",name:"password",placeholder:a("auth.password_input_placeholder"),value:u,onChange:t=>H(t.target.value)})})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"login_register_modal_field login_register_modal_field_with_prefix",children:[e.jsx("input",{type:"tel",name:"phoneNumber",placeholder:a("auth.phone_number_input_placeholder"),value:i,onChange:t=>E(t.target.value)}),e.jsx("span",{className:"login_register_modal_prefix",children:"+86"})]}),e.jsxs("div",{className:"login_register_modal_field login_register_modal_field_with_suffix",children:[e.jsx("input",{type:"text",name:"code",placeholder:a("auth.verification_code_input_placeholder"),value:g,onChange:t=>J(t.target.value)}),e.jsx("span",{className:`login_register_modal_suffix ${$?"is_disabled":""}`,onClick:()=>{$||ee()},role:"button",tabIndex:0,children:o>0?o:a("auth.send_verification_code")})]})]})}),n===3?e.jsx("div",{className:"login_register_modal_wechat_agreement",children:e.jsxs("p",{className:"login_register_modal_wechat_agreement_text",children:[a("auth.agreement_sub1"),e.jsxs("a",{href:"/content/userTerms",target:"_blank",rel:"noreferrer",children:["《",a("app.user_terms"),"》"]}),a("auth.agreement_sub2"),e.jsxs("a",{href:"/content/privacyPolicy",target:"_blank",rel:"noreferrer",children:["《",a("app.privacy_policy"),"》"]})]})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"login_register_modal_agreement",children:[e.jsx("span",{className:`login_register_modal_checkbox ${x?"is_checked":""}`,onClick:()=>T(t=>!t),role:"checkbox","aria-checked":x,tabIndex:0}),e.jsxs("p",{className:"login_register_modal_agreement_text",children:[e.jsx("span",{className:"login_register_modal_agreement_toggle",onClick:()=>T(t=>!t),children:a("auth.agreement_sub1")}),e.jsxs("a",{href:"/content/userTerms",target:"_blank",rel:"noreferrer",children:["《",a("app.user_terms"),"》"]}),a("auth.agreement_sub2"),e.jsxs("a",{href:"/content/privacyPolicy",target:"_blank",rel:"noreferrer",children:["《",a("app.privacy_policy"),"》"]}),a("auth.agreement_sub3")]})]}),e.jsx("button",{type:"button",className:"login_register_modal_submit_btn",onClick:()=>void te(),disabled:ae,children:a(n===1?"auth.login":"auth.login_or_register")})]})]}),e.jsx(F,{visible:y,title:a("captcha.title"),onCancel:()=>j(!1),footer:null,closable:!0,maskClosable:!0,alignCenter:!0,style:{width:660},unmountOnExit:!0,children:e.jsxs("div",{style:{textAlign:"center"},children:[q?e.jsx("img",{src:q,alt:"captcha",style:{height:75,cursor:"pointer",display:"block",margin:"0 auto"},onClick:()=>void U()}):null,e.jsx("div",{style:{marginTop:16},children:e.jsx("input",{value:C,placeholder:a("captcha.input_placeholder"),onChange:t=>A(t.target.value),onKeyDown:t=>{t.key==="Enter"&&D()},style:{width:240,height:44,borderRadius:8,border:"1px solid rgba(0, 0, 0, 0.12)",background:"#eee",padding:"0 12px",outline:"none",textAlign:"center"}})}),W?e.jsx("div",{style:{marginTop:8,minHeight:22,color:"#F14A2B"},children:W}):e.jsx("div",{style:{marginTop:8,minHeight:22}}),e.jsx("div",{style:{marginTop:16,display:"flex",justifyContent:"center"},children:e.jsx(N,{type:"primary",onClick:()=>void D(),loading:M,disabled:!C.trim(),children:a("button.confirm")})})]})}),e.jsxs(F,{visible:Z,title:a("alert.notification"),onCancel:()=>h(!1),footer:null,closable:!0,maskClosable:!0,alignCenter:!0,unmountOnExit:!0,style:{width:560},children:[e.jsx("div",{style:{textAlign:"center"},children:a("alert.please_read_and_agree_terms")}),e.jsxs("div",{style:{marginTop:16,display:"flex",justifyContent:"center",gap:16},children:[e.jsx(N,{onClick:()=>h(!1),children:a("button.cancel")}),e.jsx(N,{type:"primary",onClick:()=>h(!1),children:a("button.okay")})]})]})]})}export{we as LoginRegisterModal};
//# sourceMappingURL=index-DRMBLEuE.js.map