Files
gitlab-instance-0a899031_no…/app/cloudphone/lib/payment.ts
2026-03-13 21:38:04 -05:00

24 lines
782 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* 支付状态 - 适配 nomadvip paidType克隆自 nomadlms
*
* CTA 校验逻辑:有本地 paidType=vip 时优先使用;无则点击「立即加入」直接进入支付流程
*/
/** nomadvip 使用 paidType=vip 表示已支付 */
export function isPaid(): boolean {
if (typeof window === "undefined") return false;
return localStorage.getItem("paidType") === "vip";
}
/** 前 2 节为试看,无需支付 */
export function isFreeTrial(moduleIndex: number, lessonIndex: number): boolean {
if (moduleIndex === 0 && lessonIndex < 2) return true;
return false;
}
/** 章节是否可观看 */
export function canWatchLesson(moduleIndex: number, lessonIndex: number): boolean {
if (isFreeTrial(moduleIndex, lessonIndex)) return true;
return isPaid();
}