修复表单响应性问题 & 更新套餐管理接口字段

This commit is contained in:
2025-12-16 17:10:30 +08:00
parent 427502489e
commit 1f9b6bb044
11 changed files with 77 additions and 98 deletions

View File

@@ -8,12 +8,12 @@ import FormOption from '@/components/composites/purchase/option'
import Image from 'next/image'
import check from '../_assets/check.svg'
import {Schema} from '@/components/composites/purchase/long/form'
import {useFormContext} from 'react-hook-form'
import {useFormContext, useWatch} from 'react-hook-form'
import {Card} from '@/components/ui/card'
export default function Center() {
const form = useFormContext<Schema>()
const type = form.watch('type')
const type = useWatch({name: 'type'})
return (
<Card className="flex-auto p-6 flex flex-col gap-6 relative">

View File

@@ -14,20 +14,18 @@ import Pay from '@/components/composites/purchase/pay'
import {buttonVariants} from '@/components/ui/button'
import Link from 'next/link'
import {merge} from '@/lib/utils'
import {useFormContext} from 'react-hook-form'
import {useFormContext, useWatch} from 'react-hook-form'
import {Schema} from '@/components/composites/purchase/long/form'
import {Card} from '@/components/ui/card'
export default function Right() {
const profile = useProfileStore(store => store.profile)
const form = useFormContext<Schema>()
const method = form.watch('pay_type')
const mode = form.watch('type')
const live = form.watch('live')
const quota = form.watch('quota')
const expire = form.watch('expire')
const dailyLimit = form.watch('daily_limit')
const {control} = useFormContext<Schema>()
const method = useWatch({control, name: 'pay_type'})
const mode = useWatch({control, name: 'type'})
const live = useWatch({control, name: 'live'})
const quota = useWatch({control, name: 'quota'})
const expire = useWatch({control, name: 'expire'})
const dailyLimit = useWatch({control, name: 'daily_limit'})
const price = useMemo(() => {
const base = {
@@ -173,9 +171,8 @@ function BalanceOrLogin(props: {
long: {
mode: Number(props.mode),
live: Number(props.live),
daily_limit: props.dailyLimit,
expire_at: Number(props.expire),
quota: props.quota,
expire: Number(props.expire),
quota: props.mode === '1' ? props.dailyLimit : props.quota,
},
}}/>
</>