调整购买页面价格显示
This commit is contained in:
@@ -8,12 +8,14 @@ export type PurchaseSkuItem = {
|
||||
expire: string
|
||||
price: string
|
||||
count_min: number
|
||||
discount: number
|
||||
}
|
||||
|
||||
export type PurchaseSkuData = {
|
||||
items: PurchaseSkuItem[]
|
||||
priceMap: Map<string, string>
|
||||
countMinMap: Map<string, number>
|
||||
discountMap: Map<string, number>
|
||||
modeList: PurchaseMode[]
|
||||
liveList: string[]
|
||||
expireList: string[]
|
||||
@@ -27,6 +29,7 @@ export function parsePurchaseSkuList(kind: PurchaseKind, skuList: ProductItem['s
|
||||
const items: PurchaseSkuItem[] = []
|
||||
const priceMap = new Map<string, string>()
|
||||
const countMinMap = new Map<string, number>()
|
||||
const discountMap = new Map<string, number>()
|
||||
const modeSet = new Set<PurchaseMode>()
|
||||
const liveSet = new Set<number>()
|
||||
const expireSet = new Set<number>()
|
||||
@@ -51,6 +54,7 @@ export function parsePurchaseSkuList(kind: PurchaseKind, skuList: ProductItem['s
|
||||
const countMin = typeof sku.count_min === 'number' ? sku.count_min : Number(sku.count_min) || 0
|
||||
countMinMap.set(code, countMin)
|
||||
|
||||
const skuDiscount = sku.discount ?? 100
|
||||
items.push({
|
||||
code,
|
||||
mode,
|
||||
@@ -58,8 +62,10 @@ export function parsePurchaseSkuList(kind: PurchaseKind, skuList: ProductItem['s
|
||||
expire: expireValue,
|
||||
price: sku.price,
|
||||
count_min: countMin,
|
||||
discount: skuDiscount,
|
||||
})
|
||||
priceMap.set(code, sku.price)
|
||||
discountMap.set(code, skuDiscount)
|
||||
modeSet.add(mode)
|
||||
|
||||
liveSet.add(live)
|
||||
@@ -82,6 +88,7 @@ export function parsePurchaseSkuList(kind: PurchaseKind, skuList: ProductItem['s
|
||||
items,
|
||||
priceMap,
|
||||
countMinMap,
|
||||
discountMap,
|
||||
modeList: (['2', '1'] as const).filter(mode => modeSet.has(mode)),
|
||||
liveList: sortNumericValues(liveSet),
|
||||
expireList: sortNumericValues(expireSet),
|
||||
@@ -157,6 +164,14 @@ export function getPurchaseSkuPrice(priceMap: Map<string, string>, props: {
|
||||
return priceMap.get(getPurchaseSkuKey(props))
|
||||
}
|
||||
|
||||
export function getPurchaseSkuDiscount(discountMap: Map<string, number>, props: {
|
||||
mode: PurchaseMode
|
||||
live: string
|
||||
expire: string
|
||||
}) {
|
||||
return discountMap.get(getPurchaseSkuKey(props))
|
||||
}
|
||||
|
||||
export function formatPurchaseLiveLabel(live: string, kind: PurchaseKind) {
|
||||
const minutes = Number(live)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user