Files
gitlab-instance-0a899031_no…/.next/server/chunks/ssr/app_58044fe8._.js
2026-03-23 21:52:01 -05:00

1 line
8.3 KiB
JavaScript

module.exports=[50044,a=>{"use strict";var b=a.i(84365);let c="nomadvip_pay_order";function d(a){if("u"<typeof document)return null;let b=document.cookie.match(RegExp(`(?:^|; )${a}=([^;]*)`));return b?decodeURIComponent(b[1]):null}function e(){"u">typeof document&&(document.cookie=`${c}=; path=/; max-age=0`)}function f(a){if(!a?.trim())return[null,!1];let b=a.split("|"),c=b[0]?.trim()||a.trim(),d=b[1]?parseInt(b[1],10):NaN;return c?Number.isNaN(d)||Date.now()-d>9e5?[c,!1]:[c,!0]:[null,!1]}function g(a,g,h){let[i,j]=(0,b.useState)(!1),k=(0,b.useRef)(a),l=(0,b.useRef)(g);return k.current=a,l.current=g,(0,b.useEffect)(()=>{let a,b=void 0!==h?h?.trim()||null:(()=>{let[a,b]=f(d(c));if(b)return a;let[e,g]=f(null);return g?e:null})();if(!b){void 0===h&&(d(c)||0)&&e();return}j(!0);let g=0,i=!1,m=!1,n=()=>{i=!0,a&&window.clearTimeout(a)},o=async()=>{if(!i){if(m)return void p();if((g+=1)>30){n(),e(),j(!1),l.current?.();return}m=!0;try{let a=await fetch(`/api/pay/status?order_id=${encodeURIComponent(b)}`,{cache:"no-store"}),c=await a.json().catch(()=>({}));if(c?.ok&&c?.paid){n(),e(),j(!1),k.current(b);return}}catch{}finally{m=!1}p()}},p=()=>{i||(a=window.setTimeout(o,1200))},q=()=>{("u"<typeof document||"hidden"!==document.visibilityState)&&o()};return document.addEventListener("visibilitychange",q),window.addEventListener("pageshow",q),window.addEventListener("focus",q),o(),()=>{document.removeEventListener("visibilitychange",q),window.removeEventListener("pageshow",q),window.removeEventListener("focus",q),n()}},[h]),i}a.s(["usePayStatusPoll",()=>g])},94642,a=>{"use strict";var b=a.i(81629),c=a.i(84365),d=a.i(50044);let e="12345678";function f(a){return!!a&&/^user\d+$/.test(a)}async function g(a,b){for(let c=0;c<3;c++){try{let c=await fetch("/api/pay/confirm",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({order_id:a,user_id:b})}),d=await c.json().catch(()=>({}));if(d?.ok)return!0}catch(a){console.error("pay/confirm request error:",a)}c<2&&await new Promise(a=>setTimeout(a,1e3))}return!1}function h({anonymousUserId:d}){let[g,h]=(0,c.useState)(""),[i,j]=(0,c.useState)(!1),[k,l]=(0,c.useState)(null);(0,c.useEffect)(()=>{if(!d||!f(d)){let a=window.setTimeout(()=>{window.location.href="/"},600);return()=>window.clearTimeout(a)}},[d]);let m=async b=>{b.preventDefault();let c=g.trim().toLowerCase();if(c&&d){j(!0),l(null);try{let b=await fetch("/api/auth/link-email",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:c,password:e,anonymousUserId:d})}),f=await b.json().catch(()=>({}));if(!b.ok||!f?.ok||!f?.token||!f?.record?.id)return void l(f?.error||"绑定邮箱失败");let{pbSaveAuth:g}=await a.A(20551);g(f.token,f.record),await fetch("/api/auth/sync-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:f.token,record:f.record,anonymousUserId:d}),credentials:"include"}),localStorage.setItem("memosAccount",d),localStorage.setItem("userId",f.record.id),localStorage.setItem("userEmail",f.record.email||c),localStorage.setItem("userName",f.record.email||c),localStorage.setItem("emailLinked","1"),localStorage.setItem("paidType","vip"),window.location.href="/"}catch(a){console.error("link-email failed:",a),l("绑定邮箱失败")}finally{j(!1)}}};return(0,b.jsx)("div",{className:"flex min-h-screen flex-col items-center justify-center bg-[#f0f4f8] px-4",children:(0,b.jsxs)("div",{className:"animate__animated animate__zoomIn w-full max-w-md rounded-2xl bg-white p-10 text-center shadow-lg",style:{animationFillMode:"both"},children:[(0,b.jsx)("div",{className:"mx-auto mb-5 flex h-20 w-20 items-center justify-center rounded-full bg-emerald-50 text-5xl",children:"✓"}),(0,b.jsx)("h2",{className:"text-2xl font-bold text-slate-800",children:"支付成功"}),(0,b.jsx)("p",{className:"mt-3 text-slate-500",children:"最后一步,绑定邮箱后再进入 VIP。后续可以在多个站点共用同一账号。"}),f(d)?(0,b.jsxs)("form",{onSubmit:m,className:"mt-6 text-left",children:[(0,b.jsxs)("p",{className:"mb-2 text-sm text-slate-600",children:["默认密码为 ",e,"。绑定后会把当前匿名会员迁移到统一邮箱账号。"]}),(0,b.jsx)("input",{type:"email",value:g,onChange:a=>h(a.target.value),placeholder:"your@email.com",required:!0,disabled:i,className:"mb-3 w-full rounded-lg border border-slate-300 px-4 py-2 text-slate-800"}),k?(0,b.jsx)("p",{className:"mb-3 text-sm text-red-500",children:k}):null,(0,b.jsx)("button",{type:"submit",disabled:i,className:"w-full rounded-full bg-sky-500 px-6 py-2 font-semibold text-white hover:bg-sky-600 disabled:opacity-60",children:i?"处理中...":"绑定邮箱并进入 VIP"})]}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("p",{className:"mt-2 text-xs text-slate-400",children:"正在返回首页"}),(0,b.jsx)("a",{href:"/",onClick:a=>{a.preventDefault(),window.location.href="/"},className:"mt-8 inline-flex items-center gap-2 rounded-full bg-sky-500 px-8 py-3 font-semibold text-white transition-colors hover:bg-sky-600",children:"返回首页"})]})]})})}function i(){let[a,e]=(0,c.useState)("pending"),[f,i]=(0,c.useState)(null);return((0,d.usePayStatusPoll)(async a=>{let b=(a||"").trim(),c=function(a){if(!a?.includes("_order_"))return"";let b=a.split("_order_")[0].split("_");return b.length>=2?b.slice(0,-1).join("_"):""}(b)||localStorage.getItem("userId");if(!b||!c)return void e("confirm_fail");let d=await g(b,c);d&&i(c),e(d?"success":"confirm_fail")},()=>{window.location.href="/"},null),(0,c.useEffect)(()=>{let a=new URLSearchParams(window.location.search);"1"===a.get("fail")?e("fail"):"1"!==a.get("paid")||(localStorage.getItem("userId"),e("confirm_fail"))},[]),"pending"===a)?(0,b.jsx)("div",{className:"flex min-h-screen flex-col items-center justify-center bg-[#f0f4f8] px-4",children:(0,b.jsxs)("div",{className:"animate__animated animate__fadeInUp w-full max-w-md rounded-2xl bg-white p-10 text-center shadow-lg",style:{animationFillMode:"both"},children:[(0,b.jsx)("div",{className:"mx-auto mb-5 flex h-16 w-16 animate-spin items-center justify-center rounded-full border-4 border-sky-200 border-t-sky-500"}),(0,b.jsx)("h2",{className:"text-xl font-bold text-slate-800",children:"正在确认支付结果"}),(0,b.jsxs)("p",{className:"mt-3 text-sm text-slate-500",children:["正在写入会员记录,请稍候。",(0,b.jsx)("br",{}),"支付完成后会继续进入邮箱绑定。"]})]})}):"success"===a?(0,b.jsx)(h,{anonymousUserId:f||null}):"confirm_fail"===a?(0,b.jsx)("div",{className:"flex min-h-screen flex-col items-center justify-center bg-[#f0f4f8] px-4",children:(0,b.jsxs)("div",{className:"animate__animated animate__zoomIn w-full max-w-md rounded-2xl bg-white p-10 text-center shadow-lg",style:{animationFillMode:"both"},children:[(0,b.jsx)("div",{className:"mx-auto mb-5 flex h-20 w-20 items-center justify-center rounded-full bg-amber-50 text-5xl",children:"!"}),(0,b.jsx)("h2",{className:"text-2xl font-bold text-slate-800",children:"支付已确认,权益开通中"}),(0,b.jsx)("p",{className:"mt-3 text-slate-500",children:"订单已支付,但会员写入可能有延迟。请稍后刷新首页,或联系管理员处理。"}),(0,b.jsx)("a",{href:"/",onClick:a=>{a.preventDefault(),window.location.href="/"},className:"mt-8 inline-flex items-center gap-2 rounded-full bg-sky-500 px-8 py-3 font-semibold text-white transition-colors hover:bg-sky-600",children:"返回首页"})]})}):(0,b.jsx)("div",{className:"flex min-h-screen flex-col items-center justify-center bg-[#f0f4f8] px-4",children:(0,b.jsxs)("div",{className:"animate__animated animate__zoomIn w-full max-w-md rounded-2xl bg-white p-10 text-center shadow-lg",style:{animationFillMode:"both"},children:[(0,b.jsx)("div",{className:"mx-auto mb-5 flex h-20 w-20 items-center justify-center rounded-full bg-rose-50 text-5xl",children:"!"}),(0,b.jsx)("h2",{className:"text-2xl font-bold text-slate-800",children:"支付未完成"}),(0,b.jsx)("p",{className:"mt-3 text-slate-500",children:"当前没有确认到成功支付记录。你可以返回首页重新发起支付。"}),(0,b.jsx)("a",{href:"/",onClick:a=>{a.preventDefault(),window.location.href="/"},className:"mt-8 inline-flex items-center gap-2 rounded-full bg-sky-500 px-8 py-3 font-semibold text-white transition-colors hover:bg-sky-600",children:"返回首页"})]})})}a.s(["default",()=>i])},20551,a=>{a.v(b=>Promise.all(["server/chunks/ssr/_f2f04a94._.js"].map(b=>a.l(b))).then(()=>b(90416)))}];