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