s''
This commit is contained in:
@@ -1,143 +1,77 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import { useEffect, useState } from "react";
|
||||
import { useTranslation, Link } from "@/i18n/navigation";
|
||||
import Footer from "@/app/components/Footer";
|
||||
import { apiFetch } from "@/app/lib/api-client";
|
||||
|
||||
interface Service {
|
||||
id: string;
|
||||
slug: string;
|
||||
icon: string;
|
||||
titleZh: string;
|
||||
titleEn: string;
|
||||
descZh: string;
|
||||
descEn: string;
|
||||
features: { zh: string; en: string }[];
|
||||
priceZh: string;
|
||||
priceEn: string;
|
||||
color: string;
|
||||
title: string;
|
||||
titleEn?: string;
|
||||
description: string;
|
||||
descriptionEn?: string;
|
||||
features: string[];
|
||||
price: number;
|
||||
priceLabel: string;
|
||||
category: string;
|
||||
gradientFrom: string;
|
||||
gradientTo: string;
|
||||
}
|
||||
|
||||
const SERVICES: Service[] = [
|
||||
const FALLBACK_SERVICES: Service[] = [
|
||||
{
|
||||
id: "insurance",
|
||||
id: "remote-health-insurance",
|
||||
slug: "remote-health-insurance",
|
||||
icon: "🛡️",
|
||||
titleZh: "旅行保险",
|
||||
titleEn: "Travel Insurance",
|
||||
descZh: "数字游民定制方案,覆盖全球",
|
||||
descEn: "Global coverage for digital nomads",
|
||||
features: [
|
||||
{ zh: "覆盖中国 + 境外", en: "Coverage in China + overseas" },
|
||||
{ zh: "远程工作专属条款", en: "Remote work specific terms" },
|
||||
{ zh: "医疗直付服务", en: "Direct medical payment" },
|
||||
{ zh: "24/7 中文客服", en: "24/7 Chinese support" },
|
||||
],
|
||||
priceZh: "¥15/天起",
|
||||
priceEn: "From ¥15/day",
|
||||
color: "emerald",
|
||||
gradientFrom: "from-emerald-500",
|
||||
gradientTo: "to-teal-500",
|
||||
},
|
||||
{
|
||||
id: "chat",
|
||||
icon: "💬",
|
||||
titleZh: "社区聊天",
|
||||
titleEn: "Community Chat",
|
||||
descZh: "与全球数字游民实时交流",
|
||||
descEn: "Connect with nomads worldwide in real-time",
|
||||
features: [
|
||||
{ zh: "3,200+ 在线成员", en: "3,200+ members online" },
|
||||
{ zh: "城市群/兴趣群", en: "City & interest groups" },
|
||||
{ zh: "即时信息对接", en: "Instant networking" },
|
||||
{ zh: "经验分享互助", en: "Experience sharing" },
|
||||
],
|
||||
priceZh: "免费",
|
||||
priceEn: "Free",
|
||||
color: "violet",
|
||||
gradientFrom: "from-violet-500",
|
||||
gradientTo: "to-purple-500",
|
||||
},
|
||||
{
|
||||
id: "tools",
|
||||
icon: "🧰",
|
||||
titleZh: "工具箱",
|
||||
titleEn: "Tools",
|
||||
descZh: "汇率、税务、签证一站式",
|
||||
descEn: "Exchange, tax & visa in one place",
|
||||
features: [
|
||||
{ zh: "实时汇率计算", en: "Real-time exchange rates" },
|
||||
{ zh: "税务估算器", en: "Tax calculator" },
|
||||
{ zh: "签证倒计时", en: "Visa countdown" },
|
||||
{ zh: "FIRE 计算器", en: "FIRE calculator" },
|
||||
],
|
||||
priceZh: "免费",
|
||||
priceEn: "Free",
|
||||
color: "blue",
|
||||
gradientFrom: "from-blue-500",
|
||||
gradientTo: "to-cyan-500",
|
||||
},
|
||||
{
|
||||
id: "coworking",
|
||||
icon: "🏢",
|
||||
titleZh: "共享办公",
|
||||
titleEn: "Coworking",
|
||||
descZh: "全球优质办公空间推荐",
|
||||
descEn: "Premium workspace recommendations",
|
||||
features: [
|
||||
{ zh: "全球 10,000+ 空间", en: "10,000+ spaces worldwide" },
|
||||
{ zh: "会员专属折扣", en: "Member discounts" },
|
||||
{ zh: "实地考察报告", en: "On-site reviews" },
|
||||
{ zh: "预订直通车", en: "Direct booking" },
|
||||
],
|
||||
priceZh: "¥99/月起",
|
||||
priceEn: "From ¥99/month",
|
||||
color: "orange",
|
||||
gradientFrom: "from-orange-500",
|
||||
gradientTo: "to-amber-500",
|
||||
},
|
||||
{
|
||||
id: "visa",
|
||||
icon: "📋",
|
||||
titleZh: "签证服务",
|
||||
titleEn: "Visa Services",
|
||||
descZh: "专业签证顾问全程护航",
|
||||
descEn: "Professional visa consultants",
|
||||
features: [
|
||||
{ zh: "全球签证办理", en: "Global visa processing" },
|
||||
{ zh: "材料翻译公证", en: "Translation & notarization" },
|
||||
{ zh: "加急服务", en: "Expedited service" },
|
||||
{ zh: "拒签退款保障", en: "Refund guarantee" },
|
||||
],
|
||||
priceZh: "咨询报价",
|
||||
priceEn: "Contact for quote",
|
||||
color: "rose",
|
||||
gradientFrom: "from-rose-500",
|
||||
gradientTo: "to-pink-500",
|
||||
},
|
||||
{
|
||||
id: "mentor",
|
||||
icon: "🎓",
|
||||
titleZh: "导师计划",
|
||||
titleEn: "Mentor Program",
|
||||
descZh: "资深游民一对一指导",
|
||||
descEn: "1-on-1 guidance from experienced nomads",
|
||||
features: [
|
||||
{ zh: "职业规划建议", en: "Career planning" },
|
||||
{ zh: "创业经验分享", en: "Startup experience" },
|
||||
{ zh: "远程工作技巧", en: "Remote work tips" },
|
||||
{ zh: "人脉资源对接", en: "Network access" },
|
||||
],
|
||||
priceZh: "¥299/次",
|
||||
priceEn: "¥299/session",
|
||||
color: "indigo",
|
||||
gradientFrom: "from-indigo-500",
|
||||
gradientTo: "to-violet-500",
|
||||
title: "远程工作者医疗与旅行保障",
|
||||
titleEn: "Remote Health & Travel Coverage",
|
||||
description: "覆盖国内旅居、短期出境、设备丢失和紧急医疗咨询。",
|
||||
features: ["国内外医疗协助", "设备丢失补偿", "7x24 中文支持", "城市风险提醒"],
|
||||
price: 15,
|
||||
priceLabel: "¥15/天起",
|
||||
category: "保障",
|
||||
gradientFrom: "#10b981",
|
||||
gradientTo: "#0f766e",
|
||||
},
|
||||
];
|
||||
|
||||
export default function ServicesPage() {
|
||||
const { t } = useTranslation("services");
|
||||
const [services, setServices] = useState<Service[]>(FALLBACK_SERVICES);
|
||||
const [activeSlug, setActiveSlug] = useState<string | null>(null);
|
||||
const [message, setMessage] = useState("");
|
||||
|
||||
useEffect(() => {
|
||||
apiFetch<{ items: Service[] }>("/api/services")
|
||||
.then((data) => {
|
||||
if (data.items?.length) {
|
||||
setServices(data.items);
|
||||
}
|
||||
})
|
||||
.catch(() => setServices(FALLBACK_SERVICES));
|
||||
}, []);
|
||||
|
||||
const submitLead = async (service: Service) => {
|
||||
setActiveSlug(service.slug);
|
||||
setMessage("");
|
||||
try {
|
||||
await apiFetch("/api/services/leads", {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
serviceSlug: service.slug,
|
||||
note: `用户从服务页咨询:${service.title}`,
|
||||
}),
|
||||
});
|
||||
setMessage(`${service.title} 已记录咨询线索,可在 PocketBase 查看。`);
|
||||
} catch (error) {
|
||||
setMessage(error instanceof Error ? error.message : "提交失败");
|
||||
} finally {
|
||||
setActiveSlug(null);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-[#fafafa] dark:bg-gray-950">
|
||||
@@ -151,69 +85,91 @@ export default function ServicesPage() {
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{message && (
|
||||
<div className="mb-6 rounded-xl border border-emerald-200 bg-emerald-50 px-4 py-3 text-sm text-emerald-800 dark:border-emerald-800/60 dark:bg-emerald-950/30 dark:text-emerald-200">
|
||||
{message}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-5 sm:gap-6">
|
||||
{SERVICES.map((service) => (
|
||||
<div
|
||||
key={service.id}
|
||||
{services.map((service) => (
|
||||
<article
|
||||
key={service.slug}
|
||||
className="bg-white dark:bg-gray-900 rounded-2xl overflow-hidden shadow-sm border border-gray-100 dark:border-gray-800 hover:shadow-lg transition-shadow"
|
||||
>
|
||||
<div className={`h-2 bg-gradient-to-r ${service.gradientFrom} ${service.gradientTo}`} />
|
||||
<div
|
||||
className="h-2"
|
||||
style={{ background: `linear-gradient(90deg, ${service.gradientFrom}, ${service.gradientTo})` }}
|
||||
/>
|
||||
<div className="p-5 sm:p-6">
|
||||
<div className="flex items-start justify-between mb-4">
|
||||
<div className="flex items-center gap-3">
|
||||
<span className="text-3xl">{service.icon}</span>
|
||||
<div>
|
||||
<h3 className="font-bold text-gray-900 dark:text-gray-100 text-lg">
|
||||
{service.titleZh}
|
||||
{service.title}
|
||||
</h3>
|
||||
<p className="text-xs text-gray-500 dark:text-gray-400">
|
||||
{service.titleEn}
|
||||
{service.titleEn || service.category}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p className="text-sm text-gray-600 dark:text-gray-400 mb-4">
|
||||
{service.descZh}
|
||||
<p className="text-sm text-gray-600 dark:text-gray-400 mb-4 line-clamp-3">
|
||||
{service.description}
|
||||
</p>
|
||||
|
||||
<ul className="space-y-2 mb-5">
|
||||
{service.features.map((feature, i) => (
|
||||
<li key={i} className="flex items-center gap-2 text-xs sm:text-sm text-gray-500 dark:text-gray-400">
|
||||
{(service.features || []).slice(0, 5).map((feature) => (
|
||||
<li
|
||||
key={feature}
|
||||
className="flex items-center gap-2 text-xs sm:text-sm text-gray-500 dark:text-gray-400"
|
||||
>
|
||||
<span className="text-[#ff4d4f]">✓</span>
|
||||
{feature.zh}
|
||||
{feature}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
|
||||
<div className="flex items-center justify-between pt-4 border-t border-gray-100 dark:border-gray-800">
|
||||
<div className="flex items-center justify-between gap-3 pt-4 border-t border-gray-100 dark:border-gray-800">
|
||||
<span className="font-bold text-gray-900 dark:text-gray-100">
|
||||
{service.priceZh}
|
||||
{service.priceLabel || `¥${service.price}`}
|
||||
</span>
|
||||
<Link
|
||||
href="/join"
|
||||
className="text-sm font-medium text-[#ff4d4f] hover:text-[#ff7a45] transition-colors"
|
||||
>
|
||||
{t("learnMore")} →
|
||||
</Link>
|
||||
<div className="flex items-center gap-2">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => submitLead(service)}
|
||||
disabled={activeSlug === service.slug}
|
||||
className="rounded-lg bg-[#ff4d4f] px-3 py-2 text-xs font-medium text-white hover:bg-[#ff3333] disabled:cursor-not-allowed disabled:bg-gray-300"
|
||||
>
|
||||
{activeSlug === service.slug ? "提交中" : "咨询"}
|
||||
</button>
|
||||
<Link
|
||||
href="/join"
|
||||
className="text-sm font-medium text-[#ff4d4f] hover:text-[#ff7a45] transition-colors"
|
||||
>
|
||||
{t("learnMore")} →
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<div className="mt-12 sm:mt-16 bg-gradient-to-r from-[#ff4d4f] to-[#ff7a45] rounded-2xl p-6 sm:p-10 text-center">
|
||||
<h2 className="text-xl sm:text-2xl font-bold text-white mb-3">
|
||||
还没有找到需要的服务?
|
||||
需要定制落地方案?
|
||||
</h2>
|
||||
<p className="text-white/80 mb-5 text-sm sm:text-base">
|
||||
联系我们的客服,获取定制化解决方案
|
||||
服务咨询会写入数据库,后续可按城市、预算、路线和会员状态继续分配。
|
||||
</p>
|
||||
<Link
|
||||
href="/contact"
|
||||
className="inline-block bg-white text-[#ff4d4f] px-6 py-2.5 rounded-full font-medium hover:bg-gray-100 transition-colors"
|
||||
>
|
||||
联系客服
|
||||
{t("contactSupport")}
|
||||
</Link>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
Reference in New Issue
Block a user