暂无可用套餐时取消加载中 & 登录页加返回首页 & 加联系专属客服 & 修改白名单上限10个

This commit is contained in:
Eamon-meng
2026-04-21 16:42:37 +08:00
parent a0b0956677
commit eb4c2d2d5f
9 changed files with 146 additions and 132 deletions

View File

@@ -379,12 +379,10 @@ function SelectResource() {
</div>
) : !profile ? (
<div className="p-4 flex gap-1 items-center">
{/* <Loader className="animate-spin" size={20}/> */}
<span className="text-gray-600"><Link href="/login" className="text-blue-600 hover:text-blue-700 font-medium"></Link></span>
</div>
) : resources.length === 0 ? (
<div className="p-4 flex gap-1 items-center">
<Loader className="animate-spin" size={20}/>
<span></span>
</div>
) : (

View File

@@ -30,7 +30,6 @@ export default function Purchase() {
const res = profile
? await listProduct({})
: await listProductHome({})
console.log(res, 'res')
if (res.success) {
setProductList(res.data)

View File

@@ -167,14 +167,14 @@ export default function Center({skuData}: {
<NumberStepperField
name="daily_limit"
label="每日提取上限"
min={currentCountMin || 100}
min={currentCountMin}
step={100}
/>
) : (
<NumberStepperField
name="quota"
label="IP 购买数量"
min={currentCountMin || 500}
min={currentCountMin}
step={100}
/>
)}

View File

@@ -11,9 +11,9 @@ import {PurchaseSidePanel} from '../shared/side-panel'
const schema = z.object({
type: z.enum(['1', '2']).default('2'),
live: z.string(),
quota: z.number().min(500, '购买数量不能少于 500 个'),
quota: z.number().min(1, '购买数量不能少于 1 个'),
expire: z.string(),
daily_limit: z.number().min(100, '每日限额不能少于 100 个'),
daily_limit: z.number().min(1, '每日限额不能少于 1 个'),
pay_type: z.enum(['wechat', 'alipay', 'balance']),
})
export type Schema = z.infer<typeof schema>
@@ -37,8 +37,8 @@ export default function LongForm({skuList}: {skuList: ProductItem['skus']}) {
type: defaultMode,
live: defaultLive,
expire: defaultExpire,
quota: defaultMode === '2' ? Math.max(defaultCountMin, 500) : 500,
daily_limit: defaultMode === '1' ? Math.max(defaultCountMin, 100) : 100,
quota: defaultCountMin,
daily_limit: defaultCountMin,
pay_type: 'balance', // 余额支付
},
})

View File

@@ -16,7 +16,6 @@ export default function Center({
}: {
skuData: PurchaseSkuData
}) {
// const {setValue} = useFormContext<Schema>()
const {setValue, getValues} = useFormContext<Schema>()
const type = useWatch<Schema>({name: 'type'}) as Schema['type']
const live = useWatch<Schema>({name: 'live'}) as Schema['live']
@@ -34,18 +33,13 @@ export default function Center({
const expireValue = type === '1' ? expire : '0'
return getPurchaseSkuCountMin(skuData, {mode: type, live, expire: expireValue})
}, [type, live, expire, skuData])
useEffect(() => {
if (type === '1') {
const current = getValues('daily_limit')
if (current < currentCountMin) {
setValue('daily_limit', currentCountMin)
}
}
else {
const current = getValues('quota')
if (current < currentCountMin) {
setValue('quota', currentCountMin)
}
if (currentCountMin <= 0) return
const targetField = type === '1' ? 'daily_limit' : 'quota'
const currentValue = getValues(targetField)
if (currentValue < currentCountMin) {
setValue(targetField, currentCountMin, {shouldValidate: true})
}
}, [currentCountMin, type, setValue, getValues])
useEffect(() => {
@@ -171,14 +165,14 @@ export default function Center({
<NumberStepperField
name="daily_limit"
label="每日提取上限"
min={currentCountMin || 2000}
min={currentCountMin}
step={1000}
/>
) : (
<NumberStepperField
name="quota"
label="IP 购买数量"
min={currentCountMin || 10000}
min={currentCountMin}
step={5000}
/>
)}

View File

@@ -11,9 +11,9 @@ import {PurchaseSidePanel} from '../shared/side-panel'
const schema = z.object({
type: z.enum(['1', '2']).default('2'),
live: z.string(),
quota: z.number().min(10000, '购买数量不能少于 10000 个'),
quota: z.number(),
expire: z.string(),
daily_limit: z.number().min(2000, '每日限额不能少于 2000 个'),
daily_limit: z.number(),
pay_type: z.enum(['wechat', 'alipay', 'balance']).default('balance'),
})
export type Schema = z.infer<typeof schema>
@@ -30,14 +30,15 @@ export default function ShortForm({skuList}: {skuList: ProductItem['skus']}) {
live: defaultLive,
expire: defaultExpire,
})
const form = useForm<Schema>({
resolver: zodResolver(schema),
defaultValues: {
type: defaultMode,
live: defaultLive,
expire: defaultExpire,
quota: defaultMode === '2' ? defaultCountMin || 10000 : 10000,
daily_limit: defaultMode === '1' ? defaultCountMin || 2000 : 2000,
quota: defaultCountMin,
daily_limit: defaultCountMin,
pay_type: 'balance', // 余额支付
},
})