's'
This commit is contained in:
49
app/orders/[id]/page.tsx
Normal file
49
app/orders/[id]/page.tsx
Normal file
@@ -0,0 +1,49 @@
|
||||
import Link from "next/link";
|
||||
import { getOrderById } from "@/services/order.service";
|
||||
import { OrderActivation } from "@/components/order-activation";
|
||||
|
||||
const statusMap = {
|
||||
pending: { label: "待支付确认", color: "text-amber-200", tips: "系统正在等待支付回调,请稍后刷新。" },
|
||||
success: { label: "支付成功", color: "text-emerald-200", tips: "会员权益已激活,可返回资源详情页下载。" },
|
||||
failed: { label: "支付失败", color: "text-rose-200", tips: "支付未完成,请重试或更换支付方式。" },
|
||||
} as const;
|
||||
|
||||
export default async function OrderStatusPage({
|
||||
params,
|
||||
searchParams,
|
||||
}: {
|
||||
params: Promise<{ id: string }>;
|
||||
searchParams: Promise<{ status?: "pending" | "success" | "failed"; plan?: string; slug?: string }>;
|
||||
}) {
|
||||
const { id } = await params;
|
||||
const { status: rawStatus = "pending", plan: rawPlan = "pro", slug = "unknown-app" } = await searchParams;
|
||||
const status = rawStatus === "pending" || rawStatus === "success" || rawStatus === "failed" ? rawStatus : "pending";
|
||||
const plan = rawPlan === "free" || rawPlan === "pro" || rawPlan === "ultra" ? rawPlan : "pro";
|
||||
const order = await getOrderById({ id, plan, slug, status });
|
||||
const info = statusMap[order.status] ?? statusMap.pending;
|
||||
|
||||
return (
|
||||
<div className="space-y-6 py-8">
|
||||
<section className="card-glass">
|
||||
<p className="text-xs text-cyan-300">订单状态页(占位)</p>
|
||||
<h1 className="mt-1 text-3xl font-bold">订单 {order.id}</h1>
|
||||
<p className={`mt-2 text-lg font-semibold ${info.color}`}>{info.label}</p>
|
||||
<p className="mt-2 text-sm text-slate-300">{info.tips}</p>
|
||||
</section>
|
||||
|
||||
<section className="card-glass text-sm text-slate-300">
|
||||
<p>套餐:{order.plan.toUpperCase()}</p>
|
||||
<p>目标资源:{order.slug}</p>
|
||||
<p>回调状态:{order.status}</p>
|
||||
<p>订单金额:¥{order.amount}</p>
|
||||
</section>
|
||||
|
||||
<section className="card-glass flex flex-wrap gap-2">
|
||||
<OrderActivation slug={order.slug} canActivate={order.status === "success"} />
|
||||
<Link href="/pricing" className="cta-sub">查看套餐页</Link>
|
||||
<Link href={`/orders/${order.id}?status=success&plan=${order.plan}&slug=${order.slug}`} className="cta-sub">模拟成功</Link>
|
||||
<Link href={`/orders/${order.id}?status=failed&plan=${order.plan}&slug=${order.slug}`} className="cta-sub">模拟失败</Link>
|
||||
</section>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user