perf: 优化 UI
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
import type { CardType } from '@mp-pilates/shared'
|
||||
import { CardTypeCategory } from '@mp-pilates/shared'
|
||||
|
||||
/** 格式化金额:分 → 元 */
|
||||
export function formatPrice(cents: number): string {
|
||||
return (cents / 100).toFixed(2)
|
||||
@@ -44,3 +47,20 @@ export function getDateRange(days: number): ReadonlyArray<{ readonly date: strin
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
/** 会员卡类型标签 */
|
||||
export function getCardTypeLabel(type: CardTypeCategory): string {
|
||||
const map: Record<CardTypeCategory, string> = {
|
||||
[CardTypeCategory.TIMES]: '次卡',
|
||||
[CardTypeCategory.DURATION]: '月卡',
|
||||
[CardTypeCategory.TRIAL]: '体验',
|
||||
}
|
||||
return map[type] ?? '会员'
|
||||
}
|
||||
|
||||
/** 会员卡封面 CSS 类名 */
|
||||
export function getCardCoverClass(type: CardTypeCategory): string {
|
||||
if (type === CardTypeCategory.TRIAL) return 'cover--trial'
|
||||
if (type === CardTypeCategory.DURATION) return 'cover--duration'
|
||||
return 'cover--times'
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user