chore: initialize qiming workspace repository
This commit is contained in:
64
qiming-mobile/subpackages/pages/my-subscriptions/utils.uts
Normal file
64
qiming-mobile/subpackages/pages/my-subscriptions/utils.uts
Normal file
@@ -0,0 +1,64 @@
|
||||
import { useI18n } from "@/utils/i18n";
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
export function getPeriodUnit(period: string | null): string {
|
||||
if (period == null) return "";
|
||||
const map: Record<string, string> = {
|
||||
MONTH: t("Mobile.MySubscriptions.perMonth"),
|
||||
"1": t("Mobile.MySubscriptions.perMonth"),
|
||||
QUARTER: t("Mobile.MySubscriptions.perQuarter"),
|
||||
"3": t("Mobile.MySubscriptions.perQuarter"),
|
||||
YEAR: t("Mobile.MySubscriptions.perYear"),
|
||||
"12": t("Mobile.MySubscriptions.perYear"),
|
||||
FOREVER: t("Mobile.MySubscriptions.perForever"),
|
||||
};
|
||||
return map[period] || "";
|
||||
}
|
||||
|
||||
export function getFeeLabel(period: string | null): string {
|
||||
if (period == null) return "";
|
||||
const map: Record<string, string> = {
|
||||
MONTH: t("Mobile.MySubscriptions.feeMonth"),
|
||||
"1": t("Mobile.MySubscriptions.feeMonth"),
|
||||
QUARTER: t("Mobile.MySubscriptions.feeQuarter"),
|
||||
"3": t("Mobile.MySubscriptions.feeQuarter"),
|
||||
YEAR: t("Mobile.MySubscriptions.feeYear"),
|
||||
"12": t("Mobile.MySubscriptions.feeYear"),
|
||||
};
|
||||
return map[period] || "";
|
||||
}
|
||||
|
||||
export function getPayTypeText(period: string | null): string {
|
||||
if (period == null) return "";
|
||||
const map: Record<string, string> = {
|
||||
MONTH: t("Mobile.MySubscriptions.monthlyPayment"),
|
||||
"1": t("Mobile.MySubscriptions.monthlyPayment"),
|
||||
QUARTER: t("Mobile.MySubscriptions.quarterlyPayment"),
|
||||
"3": t("Mobile.MySubscriptions.quarterlyPayment"),
|
||||
YEAR: t("Mobile.MySubscriptions.yearlyPayment"),
|
||||
"12": t("Mobile.MySubscriptions.yearlyPayment"),
|
||||
};
|
||||
return map[period] || "";
|
||||
}
|
||||
|
||||
export function getStatusText(status: string): string {
|
||||
const map: Record<string, string> = {
|
||||
ACTIVE: t("Mobile.MySubscriptions.subscribing"),
|
||||
EXPIRED: t("Mobile.MySubscriptions.expired"),
|
||||
CANCELLED: t("Mobile.MySubscriptions.expired"),
|
||||
};
|
||||
return map[status] || "";
|
||||
}
|
||||
|
||||
export function isActive(status: string): boolean {
|
||||
return status === "ACTIVE";
|
||||
}
|
||||
|
||||
export function isForever(period: string | null): boolean {
|
||||
return period === "FOREVER";
|
||||
}
|
||||
|
||||
export function formatMoney(amount: number): string {
|
||||
return `¥${amount}`;
|
||||
}
|
||||
Reference in New Issue
Block a user