import { Globe, Mail, MapPin } from "lucide-react"; import { motion } from "motion/react"; import { useEffect, useRef, useState } from "react"; import { Button, Checkbox, Form, Input, message } from "antd"; import { apiRequest, type ApiResponse } from "../../services/request"; const sectionReveal = { initial: { opacity: 0, y: 40 }, whileInView: { opacity: 1, y: 0 }, viewport: { once: true, amount: 0.25 }, transition: { duration: 0.7, ease: "easeOut" as const }, }; /** 与 Tailwind lg 断点一致:窄屏下表单在首屏下方,whileInView 可能长期不触发,改为进场动画直接播放 */ const formColumnRevealMobile = { initial: { opacity: 0, y: 40 }, animate: { opacity: 1, y: 0 }, transition: { duration: 0.7, ease: "easeOut" as const }, }; type SubmittedLeadSnapshot = { user_name: string; company_name: string; phone: string; code: string; position?: string; }; export default function ContactPage() { const [form] = Form.useForm(); const [messageApi, contextHolder] = message.useMessage(); const [sendingCode, setSendingCode] = useState(false); const [countdown, setCountdown] = useState(0); const [submitting, setSubmitting] = useState(false); const [sentJustNow, setSentJustNow] = useState(false); const [submitSuccess, setSubmitSuccess] = useState(false); const [submittedSnapshot, setSubmittedSnapshot] = useState( null, ); const [isNarrowViewport, setIsNarrowViewport] = useState(() => typeof window !== "undefined" ? window.matchMedia("(max-width: 1023px)").matches : false, ); const sentTimerRef = useRef(null); useEffect(() => { if (countdown <= 0) return; const timer = window.setInterval(() => { setCountdown((prev) => (prev <= 1 ? 0 : prev - 1)); }, 1000); return () => window.clearInterval(timer); }, [countdown]); useEffect(() => { return () => { if (sentTimerRef.current) window.clearTimeout(sentTimerRef.current); }; }, []); useEffect(() => { const mq = window.matchMedia("(max-width: 1023px)"); const sync = () => setIsNarrowViewport(mq.matches); sync(); mq.addEventListener("change", sync); return () => mq.removeEventListener("change", sync); }, []); const isSuccessResponse = (res: ApiResponse) => { if (res?.code === undefined || res?.code === null || res?.code === "") return true; return ["success"].includes(res.code as string); }; const handleSendCode = async () => { try { const { phone } = await form.validateFields(["phone"]); setSendingCode(true); const res = await apiRequest("/api/website/lead_message/send_code", { method: "POST", data: { phone }, }); if (!isSuccessResponse(res)) { messageApi.error(res?.msg || "验证码发送失败,请稍后重试"); return; } messageApi.success(res?.msg || "验证码发送成功"); setSentJustNow(true); if (sentTimerRef.current) window.clearTimeout(sentTimerRef.current); sentTimerRef.current = window.setTimeout(() => { setSentJustNow(false); setCountdown(60); }, 900); } catch { // form 校验失败时不提示额外文案 } finally { setSendingCode(false); } }; const handleSubmit = async (values: { user_name: string; position?: string; phone: string; code: string; company_name: string; privacy: boolean; }) => { try { setSubmitting(true); const { privacy, ...payload } = values; const res = await apiRequest("/api/website/lead_message/add", { method: "POST", data: payload, }); if (!isSuccessResponse(res)) { messageApi.error(res?.msg || "提交失败,请稍后重试"); return; } messageApi.success(res?.msg || "提交成功"); setSubmittedSnapshot({ user_name: payload.user_name, company_name: payload.company_name, phone: payload.phone, code: payload.code, position: payload.position, }); setSubmitSuccess(true); } finally { setSubmitting(false); } }; const handleBackFromSuccess = () => { form.resetFields([ "user_name", "position", "phone", "code", "company_name", "privacy", ]); setSubmittedSnapshot(null); setSubmitSuccess(false); setCountdown(0); }; return (
{contextHolder}

联系我们
开启企微私域一体化增长之旅

填写您的信息,专业顾问将在24小时内与您取得联系,为您提供专属的解决方案。

{/*
{[ // { // icon: Globe, // title: "公司名称", // value: "深圳大方无隅科技有限公司", // color: "bg-blue-500/15 text-blue-400", // }, // { // icon: MapPin, // title: "公司地址", // value: "深圳市龙华区", // color: "bg-slate-800 text-slate-300", // }, { icon: Mail, title: "商务合作", value: "bd@dotouch.tech", color: "bg-slate-800 text-slate-300", }, ].map((item, i) => (

{item.title}

{item.value}

))}
*/}
{submitSuccess && submittedSnapshot ? (

信息提交成功,专业顾问将在24小时内与您取得联系,为您提供专属的解决方案。

您提交的信息

姓名
{submittedSnapshot.user_name}
公司名称
{submittedSnapshot.company_name}
手机号
{submittedSnapshot.phone}
部门和职务
{submittedSnapshot.position?.trim() ? submittedSnapshot.position : "—"}
) : ( <>

留下您的信息

value ? Promise.resolve() : Promise.reject( new Error("请先阅读并同意隐私协议与用户协议"), ), }, ]} > 我已阅读并同意 《隐私协议》 《用户协议》
)}
); }