From 623e3d527f20135a61e0691d0bf079798b3b3d47 Mon Sep 17 00:00:00 2001 From: Eamon <17516219072@163.com> Date: Wed, 19 Aug 2026 13:45:18 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E7=AB=8B=E5=8D=B3=E8=B4=AD?= =?UTF-8?q?=E4=B9=B0=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/home/product/buy.tsx | 1057 +++++++++++-------------------- src/home/softDownload/index.tsx | 2 +- 2 files changed, 355 insertions(+), 704 deletions(-) diff --git a/src/home/product/buy.tsx b/src/home/product/buy.tsx index 9411583..463da99 100644 --- a/src/home/product/buy.tsx +++ b/src/home/product/buy.tsx @@ -1,15 +1,8 @@ -import { useCallback, useEffect, useRef, useState } from "react" +import { useState } from "react" import { useLocation, useNavigate } from "react-router-dom" import { toast } from "sonner" -import type { CreateOrderData } from "@/api/order" -import { checkPayStatus, createOrder, createTestAccount } from "@/api/order" +import { createOrder } from "@/api/order" import { Button } from "@/components/ui/button" -import { - Dialog, - DialogContent, - DialogHeader, - DialogTitle, -} from "@/components/ui/dialog" import { Input } from "@/components/ui/input" import { Label } from "@/components/ui/label" import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group" @@ -23,6 +16,9 @@ import { import Wrap from "@/components/wrap" import type { Product } from "@/lib/models/product" import { cn } from "@/lib/utils" +import alipay from "../_assets/alipay.svg" +import balance from "../_assets/balance.svg" +import wechat from "../_assets/wechat.svg" // ============ 工具函数 ============ function randomChars(length: number): string { @@ -42,46 +38,7 @@ function randomDigits(length: number): string { return result } -// ============ 类型定义 ============ -type PaymentState = { - orderData: CreateOrderData - polling: boolean -} - -// ============ 子组件 ============ - -// 价格卡片组件 -function PriceCard({ product, isTest }: { product: Product; isTest: boolean }) { - return ( -
-
- 套餐价格 - {isTest ? ( - 免费 - ) : ( -
- - ¥{product.price.toFixed(2)} - - {product.originalPrice !== undefined && - product.originalPrice > product.price && ( - - ¥{product.originalPrice.toFixed(2)} - - )} -
- )} -
- {product.duration && ( - - {product.duration} - - )} -
- ) -} - -// 模式切换 Tab 组件 +// ============ 模式切换 Tab ============ function ModeTabs({ mode, onModeChange, @@ -90,10 +47,10 @@ function ModeTabs({ onModeChange: (mode: "single" | "batch") => void }) { return ( -
+
- + {value} - {hint && {hint}} + {hint && {hint}}
) } -// 余额展示组件 -function BalanceDisplay({ balance }: { balance: number }) { - return ( -
- 余额 -
- - 当前账户余额 - - ¥{balance.toFixed(2)} - - - -
-
- ) -} - -// 支付方式选择组件 -function PaymentMethodSelector({ - value, - onChange, -}: { - value: string - onChange: (value: string) => void -}) { - return ( -
- - -
- - -
-
- - -
-
- - -
-
-
- ) -} - -// 金额汇总组件 -function PriceSummary({ total }: { total: number }) { - return ( -
-
- 总金额 - ¥{total.toFixed(2)} -
-
- 应付款 - - ¥{total.toFixed(2)} - -
-
- ) -} - -// 表单操作按钮组件 -function FormActions({ - onBack, - onSubmit, - submitText, - submitting, -}: { - onBack: () => void - onSubmit: () => void - submitText: string - submitting: boolean -}) { - return ( -
- - -
- ) -} - -// 优惠券选择组件 +// ============ 优惠券选择器 ============ function CouponSelector() { return ( -
-