'use client'; import { AffiliateDialog, AffiliateDialogRef, } from '@/components/affiliate/components/AffiliateDialog'; import { Display } from '@/components/display'; import { Empty } from '@/components/empty'; import SvgIcon from '@/components/SvgIcon'; import useGlobalStore from '@/config/use-global'; import { queryUserAffiliate, queryUserAffiliateList } from '@/services/user/user'; import { useQuery } from '@tanstack/react-query'; import { Button } from '@workspace/ui/components/button'; import { Card, CardContent } from '@workspace/ui/components/card'; import { Input } from '@workspace/ui/components/input'; import { formatDate } from '@workspace/ui/utils'; import { useTranslations } from 'next-intl'; import { useRef, useState } from 'react'; import { CopyToClipboard } from 'react-copy-to-clipboard'; import { toast } from 'sonner'; export default function Affiliate() { const t = useTranslations('affiliate'); const { user, common } = useGlobalStore(); const [sum, setSum] = useState(); const { data } = useQuery({ queryKey: ['queryUserAffiliate'], queryFn: async () => { const response = await queryUserAffiliate(); return response.data.data; }, }); const { data: inviteList = [] } = useQuery({ queryKey: ['queryUserAffiliateList'], queryFn: async () => { const response = await queryUserAffiliateList({ page: 1, size: 3, }); return response.data.data?.list || []; }, }); const dialogRef = useRef(null); return (
{t('totalCommission')}
佣金金额,邀请成功后自动转入钱包余额
历史推荐用户:7

佣金总额

返佣邀请码 { if (result) { toast.success(t('copySuccess')); } }} >

{user?.refer_code} { if (result) { toast.success(t('copySuccess')); } }} >

邀请记录

dialogRef.current.open()} > 更多
{inviteList?.length ? (
{inviteList?.map((invite) => { return (
用户识别代码
{invite.identifier}
时间
{formatDate(invite.registered_at)}
); })}
) : ( )}

佣金计算

在下方填入对应邀请用户数量,即可计算不同比例返佣金额 *该表以Pro Plan计算,其它套餐比例不变,以实际金额计算为准
{(() => { // 假设以 Pro 计划计算:$60/月,$576/年 const MONTHLY_PRICE = 60; const YEARLY_PRICE = 576; const [count, setCount] = useState(10); const clamp = (n: number) => Math.max(0, Math.min(10000, Math.floor(n))); const firstMonth = count * MONTHLY_PRICE * 0.5; // 50% const firstYear = count * YEARLY_PRICE * 0.3; // 30% const recurMonth = count * MONTHLY_PRICE * 0.2; // 20% const recurYear = count * YEARLY_PRICE * 0.2; // 20% return (
{/* 计算面板容器 */}
{/* 左:行表头(月付套餐 / 年付套餐) */}
月付套餐
年付套餐
{/* 中:首充用户(双层圆角 + 三行) */}
首充用户
50%
up to{' '}
30%
up to{' '}
{/* 蓝色投影块 */}
{/* 右:再次充值用户(灰卡 + 三行) */}
再次充值用户
20%
up to{' '} {' '} / 月
20%
up to{' '} {' '} / 年
{/* 用户数调节 */}
setCount(clamp(Number(e.target.value) || 0))} className='h-6 border-0 p-0 text-center text-sm focus-visible:ring-0 sm:h-8' style={{ width: `${Math.max(3, String(count).length + 1)}ch` }} /> Users
); })()}
); }