修复用户未/授权购买套餐价格计算 & 发布v1.6.0版本
This commit is contained in:
@@ -8,7 +8,7 @@ import {merge} from '@/lib/utils'
|
||||
import {useFormContext, useWatch} from 'react-hook-form'
|
||||
import {Schema} from '@/components/composites/purchase/long/form'
|
||||
import {Card} from '@/components/ui/card'
|
||||
import {getPrice} from '@/actions/resource'
|
||||
import {getPrice, getPriceHome} from '@/actions/resource'
|
||||
import {ExtraResp} from '@/lib/api'
|
||||
import {FieldPayment} from '../shared/field-payment'
|
||||
|
||||
@@ -25,19 +25,29 @@ export default function Right() {
|
||||
actual: '0.00',
|
||||
discounted: '0.00',
|
||||
})
|
||||
const profile = use(useProfileStore(store => store.profile))
|
||||
|
||||
useEffect(() => {
|
||||
const price = async () => {
|
||||
try {
|
||||
const resp = await getPrice({
|
||||
type: 2,
|
||||
long: {
|
||||
live: Number(live),
|
||||
mode: Number(mode),
|
||||
quota: mode === '1' ? Number(dailyLimit) : Number(quota),
|
||||
expire: mode === '1' ? Number(expire) : undefined,
|
||||
},
|
||||
})
|
||||
const resp = profile
|
||||
? await getPrice({
|
||||
type: 2,
|
||||
long: {
|
||||
live: Number(live),
|
||||
mode: Number(mode),
|
||||
quota: mode === '1' ? Number(dailyLimit) : Number(quota),
|
||||
expire: mode === '1' ? Number(expire) : undefined,
|
||||
},
|
||||
}) : await getPriceHome({
|
||||
type: 1,
|
||||
short: {
|
||||
live: Number(live),
|
||||
mode: Number(mode),
|
||||
quota: mode === '1' ? Number(dailyLimit) : Number(quota),
|
||||
expire: mode === '1' ? Number(expire) : undefined,
|
||||
},
|
||||
})
|
||||
if (!resp.success) {
|
||||
throw new Error('获取价格失败')
|
||||
}
|
||||
@@ -57,7 +67,7 @@ export default function Right() {
|
||||
}
|
||||
}
|
||||
price()
|
||||
}, [dailyLimit, expire, live, quota, mode])
|
||||
}, [dailyLimit, expire, live, quota, mode, profile])
|
||||
|
||||
const {price, actual: discountedPrice = ''} = priceData
|
||||
// 计算总折扣价(原价 - 实付价格)
|
||||
|
||||
Reference in New Issue
Block a user