市场夺宝奇兵
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.
 
 

1 lines
2.5 KiB

import{r as y}from"./member-CDNIPHgK.js";const E=50,I=100,L=20,m=document.getElementById("registrationForm"),l=document.getElementById("successModal"),h=document.getElementById("closeModal"),a=document.getElementById("submitBtn"),u=document.getElementById("loadingOverlay");let c=!1;function B(){u.style.display="flex",a.disabled=!0,a.textContent="提交中...",c=!0}function v(){u.style.display="none",a.disabled=!1,a.textContent="提交注册",c=!1}function o(e){alert(e)}function M(e){const{name:t,tel:s,email:n}=e;return!t||t.length>E?(o("请输入有效的姓名(最多50个字符)"),document.getElementById("userNameInfo").focus(),!1):!s||s.length>L?(o("请输入有效的电话号码"),document.getElementById("userMobile").focus(),!1):!n||n.length>I?(o("请输入电子邮箱"),document.getElementById("userEmail").focus(),!1):/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(n)?!0:(o("请输入有效的电子邮箱地址"),document.getElementById("userEmail").focus(),!1)}async function b(e){if(e.preventDefault(),c)return;const t=document.getElementById("userNameInfo").value.trim(),s=document.getElementById("countryInfo").value,n=document.getElementById("userMobile").value.trim(),d=document.getElementById("userWechat").value.trim(),g=document.getElementById("userEmail").value.trim(),r={name:t,code:s,tel:n,wechat:d,email:g};if(M(r))try{B();const i=await y(r);i.code===200?(l.classList.remove("hidden"),m.reset()):o("注册失败: "+(i.msg||"未知错误"))}catch(i){console.error("请求失败:",i),o("网络错误,请稍后重试")}finally{v()}}function w(){document.getElementById("mobileMenu").classList.toggle("hidden");const t=document.getElementById("menuBtn").querySelector("i");t.classList.contains("fa-bars")?t.classList.replace("fa-bars","fa-times"):t.classList.replace("fa-times","fa-bars")}function p(){const e=document.querySelector("header");window.scrollY>50?(e.classList.add("py-2","shadow"),e.classList.remove("py-3")):(e.classList.add("py-3"),e.classList.remove("py-2","shadow"))}function f(){document.querySelectorAll(".animate-fade-in").forEach(t=>{const s=t.getBoundingClientRect().top,n=window.innerHeight;s<n-100&&(t.style.opacity="1",t.style.transform="translateY(0)")})}m.addEventListener("submit",b);h.addEventListener("click",()=>{l.classList.add("hidden")});l.addEventListener("click",e=>{e.target===l&&l.classList.add("hidden")});document.getElementById("menuBtn").addEventListener("click",w);window.addEventListener("scroll",p);window.addEventListener("load",()=>{f(),document.getElementById("loadingOverlay").style.display="none"});window.addEventListener("scroll",f);