From fa942d4b99a7601fcd246e29b725552ca5af063e Mon Sep 17 00:00:00 2001 From: Eamon-meng <17516219072@163.com> Date: Thu, 18 Dec 2025 17:11:19 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=BA=95=E9=83=A8=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E4=BF=9D=E9=9A=9C=E8=B7=B3=E8=BD=AC=E9=93=BE=E6=8E=A5?= =?UTF-8?q?=20&=20=E8=B4=AD=E4=B9=B0=E5=A5=97=E9=A4=90=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=8A=98=E6=89=A3=E5=AD=97=E6=AE=B5=20&=20=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E6=80=BB=E8=A7=88=E6=B7=BB=E5=8A=A0=E9=95=BF=E6=95=88=E5=8A=A8?= =?UTF-8?q?=E6=80=81=E5=9B=BE=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/(home)/footer.tsx | 22 +++--- src/app/admin/(dashboard)/_client/charts.tsx | 33 +++++++- src/components/composites/purchase/index.tsx | 2 - .../composites/purchase/long/right.tsx | 75 ++++++++++++++---- .../composites/purchase/short/right.tsx | 79 +++++++++++++++---- 5 files changed, 163 insertions(+), 48 deletions(-) diff --git a/src/app/(home)/footer.tsx b/src/app/(home)/footer.tsx index 1331932..9bc8e43 100644 --- a/src/app/(home)/footer.tsx +++ b/src/app/(home)/footer.tsx @@ -19,7 +19,7 @@ export default function Footer(props: FooterProps) {

QQ: 70177252

服务保障

@@ -56,14 +56,14 @@ export default function Footer(props: FooterProps) { } - coming soon -

敬请期待

+
@@ -184,3 +183,33 @@ function DashboardChart(props: DashboardChartProps) { ) } + +function LongChart() { + return ( + + + + + + `日期: ${chartData.find(item => item.formattedTime === value)?.fullDate || value}`} + formatter={value => [`${value}`, '套餐使用量']} + /> + + + + + ) +} diff --git a/src/components/composites/purchase/index.tsx b/src/components/composites/purchase/index.tsx index 326ba18..9508b95 100644 --- a/src/components/composites/purchase/index.tsx +++ b/src/components/composites/purchase/index.tsx @@ -4,8 +4,6 @@ import {merge} from '@/lib/utils' import {Tabs, TabsContent, TabsList, TabsTrigger} from '@/components/ui/tabs' import LongForm from '@/components/composites/purchase/long/form' import ShortForm from '@/components/composites/purchase/short/form' -import FixedForm from '@/components/composites/purchase/fixed/form' -import Custom from '@/components/composites/purchase/custom/page' import {usePathname, useRouter, useSearchParams} from 'next/navigation' import SelfDesc from '@/components/features/self-desc' export type TabType = 'short' | 'long' | 'fixed' | 'custom' diff --git a/src/components/composites/purchase/long/right.tsx b/src/components/composites/purchase/long/right.tsx index 1a5cae8..6dee7ef 100644 --- a/src/components/composites/purchase/long/right.tsx +++ b/src/components/composites/purchase/long/right.tsx @@ -19,6 +19,12 @@ import {Schema} from '@/components/composites/purchase/long/form' import {Card} from '@/components/ui/card' import {getPrice, CreateResourceReq} from '@/actions/resource' +interface PriceData { + price: string + discounted_price?: string + discounted?: number +} + export default function Right() { const {control} = useFormContext() const method = useWatch({control, name: 'pay_type'}) @@ -27,7 +33,11 @@ export default function Right() { const quota = useWatch({control, name: 'quota'}) const expire = useWatch({control, name: 'expire'}) const dailyLimit = useWatch({control, name: 'daily_limit'}) - const [price, setPrice] = useState('') + const [priceData, setPriceData] = useState({ + price: '0.00', + discounted_price: '0.00', + discounted: 0, + }) useEffect(() => { const price = async () => { @@ -42,17 +52,31 @@ export default function Right() { } try { const priceValue = await getPrice(params) + console.log(priceValue, 'priceValue') + if (priceValue.success && priceValue.data?.price) { - setPrice(priceValue.data.price) + const data: PriceData = priceValue.data + setPriceData({ + price: data.price, + discounted_price: data.discounted_price ?? data.price ?? '', + discounted: data.discounted, + }) } } catch (error) { console.error('获取价格失败:', error) - setPrice('0.00') + setPriceData({ + price: '0.00', + discounted_price: '0.00', + discounted: 0, + }) } } price() }, [dailyLimit, expire, live, quota, mode]) + + const {price, discounted_price: discountedPrice = '', discounted} = priceData + return ( {mode === '2' ? ( -
  • - 购买 IP 量 - - {quota} - 个 - -
  • + <> +
  • + 购买 IP 量 + + {quota} + 个 + +
  • +
  • + 实价 + + ¥{price} + +
  • + ) : ( <>
  • @@ -97,19 +129,30 @@ export default function Right() { 个
  • +
  • + 原价 + + ¥{price} + +
  • +
  • + 总折扣 + + -¥{discounted} + +
  • )}

    - 价格 + 实付价格 - ¥ - {price} + ¥{discountedPrice}

    - +
    ) @@ -117,7 +160,7 @@ export default function Right() { function BalanceOrLogin(props: { method: 'wechat' | 'alipay' | 'balance' - price: string + discountedPrice: string mode: string live: string quota: number @@ -176,7 +219,7 @@ function BalanceOrLogin(props: { () const method = useWatch({control, name: 'pay_type'}) @@ -25,7 +32,11 @@ export default function Right() { const expire = useWatch({control, name: 'expire'}) const quota = useWatch({control, name: 'quota'}) const dailyLimit = useWatch({control, name: 'daily_limit'}) - const [price, setPrice] = useState('') + const [priceData, setPriceData] = useState({ + price: '0.00', + discounted_price: '0.00', + discounted: 0, + }) useEffect(() => { const price = async () => { @@ -40,18 +51,31 @@ export default function Right() { } try { const priceResponse = await getPrice(params) - if (priceResponse.success && priceResponse.data?.price) { - setPrice(priceResponse.data.price) + console.log(priceResponse, 'priceResponse') + + if (priceResponse.success && priceResponse.data) { + const data: PriceData = priceResponse.data + setPriceData({ + price: data.price, + discounted_price: data.discounted_price ?? data.price ?? '', + discounted: data.discounted, + }) } } catch (error) { console.error('获取价格失败:', error) - setPrice('0.00') + setPriceData({ + price: '0.00', + discounted_price: '0.00', + discounted: 0, + }) } } price() }, [expire, live, quota, mode, dailyLimit]) + const {price, discounted_price: discountedPrice = '', discounted} = priceData + return ( {mode === '2' ? ( -
  • - 购买 IP 量 - - {quota} - 个 - -
  • + <> +
  • + 购买 IP 量 + + {quota} + 个 + +
  • +
  • + 实价 + + ¥{price} + +
  • + ) : ( <>
  • @@ -96,19 +128,32 @@ export default function Right() { 个
  • +
  • + 原价 + + ¥{price} + +
  • + {discounted === 1 ? '' : ( +
  • + 总折扣 + + -¥{discounted === 1 ? '' : discounted} + +
  • + )} )}

    - 价格 + 实付价格 - ¥ - {price} + ¥{discountedPrice}

    - +
    ) @@ -116,7 +161,7 @@ export default function Right() { function BalanceOrLogin(props: { method: 'wechat' | 'alipay' | 'balance' - price: string + discountedPrice: string mode: string live: string quota: number @@ -175,7 +220,7 @@ function BalanceOrLogin(props: {