|
@@ -4,6 +4,7 @@ import { state } from '@/state'
|
|
|
import request from '@/helpers/request'
|
|
|
import { browser } from '@/helpers/utils'
|
|
|
import { Dialog } from 'vant'
|
|
|
+import dayjs from 'dayjs'
|
|
|
type orderType =
|
|
|
| 'VIDEO'
|
|
|
| 'LIVE'
|
|
@@ -71,6 +72,29 @@ export const resestState = () => {
|
|
|
Object.assign(orderStatus, original())
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+// 购买会员多少数量满足条件
|
|
|
+export const memberNeedNumber = (item: any) => {
|
|
|
+ if (item.vipEndDays > 0) {
|
|
|
+ const endTime = dayjs(item.startTime).add(item.vipEndDays, 'day')
|
|
|
+ const unit = item.period === 'YEAR' ? 'years' : 'months'
|
|
|
+ const months = endTime.diff(dayjs(item.startTime), unit)
|
|
|
+ if (item.period === 'MONTH') {
|
|
|
+ return months + 1
|
|
|
+ } else if (item.period === 'QUARTERLY') {
|
|
|
+ return Math.ceil((months + 1) / 3)
|
|
|
+ } else if (item.period === 'YEAR_HALF') {
|
|
|
+ return Math.ceil((months + 1) / 6)
|
|
|
+ } else if (item.period === 'YEAR') {
|
|
|
+ return months + 1
|
|
|
+ } else {
|
|
|
+ return 1
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return 1
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
export const orderInfos = () => {
|
|
|
// 商品列表
|
|
|
const orderList = orderStatus.orderObject.orderList || []
|
|
@@ -114,7 +138,8 @@ export const orderInfos = () => {
|
|
|
params.bizContent = item.id
|
|
|
} else if (item.orderType === "SVIP") {
|
|
|
params.bizContent = item.id
|
|
|
- params.vipEndDays = item.vipEndDays
|
|
|
+ const needNumber = memberNeedNumber(item)
|
|
|
+ params.vipEndDays = item.num > needNumber ? item.vipEndDays : null
|
|
|
params.goodsNum = item.num
|
|
|
} else if (item.orderType === 'MUSIC') {
|
|
|
params.bizContent = {
|
|
@@ -160,7 +185,9 @@ export const orderTenantInfos = () => {
|
|
|
params.bizId = item.id
|
|
|
} else if (item.orderType === "SVIP") {
|
|
|
params.bizContent = item.id
|
|
|
- params.vipEndDays = item.vipEndDays
|
|
|
+ // params.vipEndDays = item.vipEndDays
|
|
|
+ const needNumber = memberNeedNumber(item)
|
|
|
+ params.vipEndDays = item.num > needNumber ? item.vipEndDays : null
|
|
|
params.goodsNum = item.num
|
|
|
} else if (item.orderType === 'MUSIC') {
|
|
|
params.bizContent = {
|