|
|
|
@ -2,10 +2,10 @@ import { Button } from "@arco-design/web-react"; |
|
|
|
import { Fragment, useCallback, useEffect, useMemo, useState } from "react"; |
|
|
|
import { useTranslation } from "react-i18next"; |
|
|
|
import { getPlanList } from "@/api/api"; |
|
|
|
import type { ProductPlan } from "@/api/api"; |
|
|
|
// import { memberLevelMap } from "@/constants";
|
|
|
|
import type { ProductPlan, ProductPlanCustomInfo } from "@/api/api"; |
|
|
|
import { getMemberLevelLabel } from "@/constants"; |
|
|
|
import { openPaySubscribeDialog } from "@/dialog"; |
|
|
|
import { useParamConfigStore } from "@/store/useParamConfigStore"; |
|
|
|
import { useMemberLevelStore } from "@/store/useMemberLevelStore"; |
|
|
|
import { useUserStore } from "@/store/useUserStore"; |
|
|
|
|
|
|
|
import "./index.scss"; |
|
|
|
@ -191,7 +191,7 @@ function getPlanDescriptionSegments(line: string): PlanDescriptionSegment[] { |
|
|
|
export default function SubscribePlanList({ embedded = false, onBillingCycleChange }: SubscribePlanListProps) { |
|
|
|
const { t } = useTranslation(); |
|
|
|
const user = useUserStore((s) => s.user); |
|
|
|
const serviceQrCode = useParamConfigStore((s) => s.config?.systemConfig?.serviceQrCode ?? ""); |
|
|
|
const memberLevelMap = useMemberLevelStore((s) => s.memberLevelMap); |
|
|
|
|
|
|
|
const [billingCycle, setBillingCycleState] = useState<SubscribeBillingCycle>("monthly"); |
|
|
|
const [planList, setPlanList] = useState<ProductPlan[]>([]); |
|
|
|
@ -311,6 +311,7 @@ export default function SubscribePlanList({ embedded = false, onBillingCycleChan |
|
|
|
const original = Number(plan.original_price_amount) > 0 ? Number(plan.original_price_amount) : null; // 原价
|
|
|
|
const level = Number(plan.level ?? -1); // 会员等级
|
|
|
|
const isFreePlan = price <= 0; |
|
|
|
const isLevel4Plan = level === 4; |
|
|
|
const isPurchasedLevel4Plan = isLevel4Plan && userMemberLevel === 4; // 已购买4级会员 Future Creator 课程
|
|
|
|
const ctaDisabled = isPurchasedLevel4Plan ? false : userMemberLevel === level || userMemberLevel > level; // 按钮是否禁用
|
|
|
|
const ctaLabel = isPurchasedLevel4Plan |
|
|
|
@ -318,7 +319,7 @@ export default function SubscribePlanList({ embedded = false, onBillingCycleChan |
|
|
|
: userMemberLevel === level // 当前会员等级
|
|
|
|
? t("subscribe.current_plan") |
|
|
|
: userMemberLevel > level // 当前会员等级大于计划等级
|
|
|
|
? t("subscribe.already_member_level", { level: t(memberLevelMap[userMemberLevel] ?? memberLevelMap[0]) }) |
|
|
|
? t("subscribe.already_member_level", { level: getMemberLevelLabel(memberLevelMap, userMemberLevel, t) }) |
|
|
|
: t("subscribe.subscribe_now"); // 订阅按钮文本
|
|
|
|
|
|
|
|
// 点击CTA按钮
|
|
|
|
|