fix: 新购订单自动计算到期时间
This commit is contained in:
@@ -1405,6 +1405,19 @@ const handleDurationChange = (value) => {
|
||||
orderForm.pay_num = duration
|
||||
}
|
||||
|
||||
const calculateExpireTime = (months) => {
|
||||
const duration = Math.max(1, Math.floor(Number(months) || 1))
|
||||
const expireDate = new Date()
|
||||
const originalDay = expireDate.getDate()
|
||||
|
||||
expireDate.setDate(1)
|
||||
expireDate.setMonth(expireDate.getMonth() + duration)
|
||||
const lastDay = new Date(expireDate.getFullYear(), expireDate.getMonth() + 1, 0).getDate()
|
||||
expireDate.setDate(Math.min(originalDay, lastDay))
|
||||
|
||||
return expireDate.getTime()
|
||||
}
|
||||
|
||||
// 分步导航
|
||||
const handleNextStep = async () => {
|
||||
if (currentStep.value === 0) {
|
||||
@@ -1420,6 +1433,7 @@ const handleNextStep = async () => {
|
||||
if (isAutoPriceMode.value) {
|
||||
const priced = await fetchOrderPrice()
|
||||
if (!priced) return
|
||||
orderForm.expire_time = calculateExpireTime(orderForm.pay_num)
|
||||
}
|
||||
}
|
||||
currentStep.value++
|
||||
|
||||
Reference in New Issue
Block a user