修复自定义充值和立即充值部分
This commit is contained in:
@@ -193,8 +193,8 @@ export default function IpLinePage() {
|
||||
return (
|
||||
<>
|
||||
<Toaster position="top-center" richColors />
|
||||
<Wrap className="flex flex-col gap-4 mt-30 max-w-6xl mx-auto px-4 pb-20 bg-white">
|
||||
<div className="grid grid-cols-3">
|
||||
<Wrap className="flex flex-col gap-4 mt-20 max-w-6xl mx-auto px-4 pb-20 bg-white">
|
||||
<div className="grid grid-cols-3 mt-3">
|
||||
<div></div>
|
||||
<h3 className="text-3xl font-bold text-gray-800 text-center">
|
||||
IP线路表
|
||||
|
||||
@@ -84,6 +84,7 @@ export default function HttpPage() {
|
||||
|
||||
// 支付弹窗状态
|
||||
const [payDialogOpen, setPayDialogOpen] = useState(false)
|
||||
const [payAmount, setPayAmount] = useState(0)
|
||||
const [payMethod, setPayMethod] = useState("2")
|
||||
const [isRecharge] = useState(true)
|
||||
const [isLoading, setIsLoading] = useState(false)
|
||||
@@ -94,10 +95,9 @@ export default function HttpPage() {
|
||||
let price = 0
|
||||
switch (activeTab) {
|
||||
case "prepaid":
|
||||
price = Number(customAmount) || 0
|
||||
price = Number(customAmount) || 1
|
||||
break
|
||||
case "unlimited":
|
||||
// 简化计算
|
||||
price = whitelistCount * periodCount * 0.5
|
||||
break
|
||||
case "daily":
|
||||
@@ -124,16 +124,18 @@ export default function HttpPage() {
|
||||
setTimeout(() => {
|
||||
setIsLoading(false)
|
||||
setPayDialogOpen(false)
|
||||
toast.success(`支付成功!支付金额:¥${totalPrice.toFixed(2)}`)
|
||||
toast.success(`支付成功!支付金额:¥${payAmount.toFixed(2)}`)
|
||||
}, 1500)
|
||||
}
|
||||
|
||||
// 打开支付弹窗
|
||||
const openPayDialog = () => {
|
||||
if (totalPrice <= 0) {
|
||||
const openPayDialog = (amount?: number) => {
|
||||
const effectivePrice = Number(amount ?? totalPrice)
|
||||
if (effectivePrice <= 0) {
|
||||
toast.error("请输入有效的充值金额")
|
||||
return
|
||||
}
|
||||
setPayAmount(effectivePrice)
|
||||
setPayDialogOpen(true)
|
||||
}
|
||||
|
||||
@@ -541,7 +543,7 @@ export default function HttpPage() {
|
||||
<DialogContent className="sm:max-w-md">
|
||||
<DialogHeader>
|
||||
<DialogTitle className="text-center">
|
||||
待支付:¥{totalPrice.toFixed(2)}元
|
||||
待支付:¥{payAmount.toFixed(2)}元
|
||||
</DialogTitle>
|
||||
</DialogHeader>
|
||||
|
||||
@@ -585,7 +587,7 @@ export default function HttpPage() {
|
||||
</a>
|
||||
</p>
|
||||
<p className="text-gray-600 mt-2">
|
||||
本次支付H币:{totalPrice.toFixed(2)}
|
||||
本次支付H币:{payAmount.toFixed(2)}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
@@ -614,7 +616,7 @@ function PrepaidCardCustom({
|
||||
}: {
|
||||
amount: string
|
||||
onAmountChange: (v: string) => void
|
||||
onPay: () => void
|
||||
onPay: (amount: number) => void
|
||||
}) {
|
||||
return (
|
||||
<Card className="relative text-center border-0 shadow-md overflow-visible">
|
||||
@@ -643,7 +645,7 @@ function PrepaidCardCustom({
|
||||
<li>支持购买任意套餐</li>
|
||||
</ul>
|
||||
<Button
|
||||
onClick={onPay}
|
||||
onClick={() => onPay(Number(amount) || 1)}
|
||||
className="w-full rounded-md bg-linear-to-r from-blue-500 to-cyan-400 text-white hover:opacity-90"
|
||||
>
|
||||
自定义充值
|
||||
@@ -657,7 +659,7 @@ function PrepaidCard({
|
||||
onPay,
|
||||
}: {
|
||||
plan: { amount: number; bonus: string; total: number; tag: string }
|
||||
onPay: () => void
|
||||
onPay: (amount: number) => void
|
||||
}) {
|
||||
return (
|
||||
<Card className="relative text-center border-0 shadow-md overflow-visible">
|
||||
@@ -677,7 +679,7 @@ function PrepaidCard({
|
||||
<li>支持购买任意套餐</li>
|
||||
</ul>
|
||||
<Button
|
||||
onClick={onPay}
|
||||
onClick={() => onPay(plan.amount)}
|
||||
className="w-full rounded-md bg-linear-to-r from-blue-500 to-cyan-400 text-white hover:opacity-90"
|
||||
>
|
||||
立即充值
|
||||
@@ -692,7 +694,7 @@ function PrepaidCardLarge({
|
||||
onPay,
|
||||
}: {
|
||||
plan: { amount: number; bonus: string; total: number; tag: string }
|
||||
onPay: () => void
|
||||
onPay: (amount: number) => void
|
||||
}) {
|
||||
return (
|
||||
<Card className="relative text-center border-0 shadow-md bg-white overflow-visible">
|
||||
@@ -703,7 +705,7 @@ function PrepaidCardLarge({
|
||||
<div className="text-3xl font-bold">¥{plan.amount}</div>
|
||||
<p className="text-sm text-muted-foreground">实到{plan.total}H币</p>
|
||||
<Button
|
||||
onClick={onPay}
|
||||
onClick={() => onPay(plan.amount)}
|
||||
className="rounded-md bg-linear-to-r from-blue-500 to-cyan-400 text-white hover:opacity-90 px-10"
|
||||
>
|
||||
立即充值
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
import { zodResolver } from "@hookform/resolvers/zod"
|
||||
import { useEffect, useState } from "react"
|
||||
import { Controller, useForm } from "react-hook-form"
|
||||
import { z } from "zod"
|
||||
import { useState } from "react"
|
||||
import { Badge } from "@/components/ui/badge"
|
||||
import { Button } from "@/components/ui/button"
|
||||
import { Card, CardContent } from "@/components/ui/card"
|
||||
@@ -12,7 +9,6 @@ import {
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
} from "@/components/ui/dialog"
|
||||
import { FieldError } from "@/components/ui/field"
|
||||
import { Input } from "@/components/ui/input"
|
||||
import { Label } from "@/components/ui/label"
|
||||
import { Separator } from "@/components/ui/separator"
|
||||
@@ -22,14 +18,6 @@ import alipay from "../_assets/alipay.svg"
|
||||
import balance from "../_assets/balance.svg"
|
||||
import wechat from "../_assets/wechat.svg"
|
||||
|
||||
const shippingSchema = z.object({
|
||||
name: z.string().trim().min(1, "请输入收货人"),
|
||||
phone: z.string().regex(/^1\d{10}$/, "请输入正确的手机号"),
|
||||
address: z.string().trim().min(1, "请输入地址"),
|
||||
})
|
||||
|
||||
type ShippingValues = z.infer<typeof shippingSchema>
|
||||
|
||||
const PRODUCT_VARIANTS = [
|
||||
{
|
||||
id: 1,
|
||||
|
||||
@@ -24,17 +24,17 @@ export default function SoftDownloadPage() {
|
||||
|
||||
return (
|
||||
<Wrap className="flex flex-col gap-6 mt-20 bg-white">
|
||||
<div className="grid grid-cols-3">
|
||||
<div className="grid grid-cols-3 mt-3">
|
||||
<div></div>
|
||||
<h3 className="text-3xl font-bold text-gray-800 text-center">
|
||||
软件下载
|
||||
</h3>
|
||||
<div className="flex gap-4 text-sm justify-end items-end text-blue-500">
|
||||
<a
|
||||
href="/softDownload"
|
||||
href="/ipline"
|
||||
className="no-underline hover:text-blue-700 active:no-underline focus:no-underline"
|
||||
>
|
||||
下载客户端
|
||||
IP线路表
|
||||
</a>
|
||||
<a
|
||||
href="/help"
|
||||
|
||||
Reference in New Issue
Block a user