InvitationCard.jsx 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. /*
  2. Copyright (C) 2025 QuantumNous
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU Affero General Public License as
  5. published by the Free Software Foundation, either version 3 of the
  6. License, or (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU Affero General Public License for more details.
  11. You should have received a copy of the GNU Affero General Public License
  12. along with this program. If not, see <https://www.gnu.org/licenses/>.
  13. For commercial licensing, please contact support@quantumnous.com
  14. */
  15. import React from 'react';
  16. import {
  17. Avatar,
  18. Typography,
  19. Card,
  20. Button,
  21. Input,
  22. Badge,
  23. Space,
  24. } from '@douyinfe/semi-ui';
  25. import { Copy, Users, BarChart2, TrendingUp, Gift, Zap } from 'lucide-react';
  26. const { Text } = Typography;
  27. const InvitationCard = ({
  28. t,
  29. userState,
  30. renderQuota,
  31. setOpenTransfer,
  32. affLink,
  33. handleAffLinkClick,
  34. }) => {
  35. return (
  36. <Card className="!rounded-2xl shadow-sm border-0">
  37. {/* 卡片头部 */}
  38. <div className="flex items-center mb-4">
  39. <Avatar size="small" color="green" className="mr-3 shadow-md">
  40. <Gift size={16} />
  41. </Avatar>
  42. <div>
  43. <Typography.Text className="text-lg font-medium">{t('邀请奖励')}</Typography.Text>
  44. <div className="text-xs">{t('邀请好友获得额外奖励')}</div>
  45. </div>
  46. </div>
  47. {/* 收益展示区域 */}
  48. <Space vertical style={{ width: '100%' }}>
  49. {/* 统计数据统一卡片 */}
  50. <Card
  51. className='!rounded-xl w-full'
  52. cover={
  53. <div
  54. className="relative h-30"
  55. style={{
  56. '--palette-primary-darkerChannel': '0 75 80',
  57. backgroundImage: `linear-gradient(0deg, rgba(var(--palette-primary-darkerChannel) / 80%), rgba(var(--palette-primary-darkerChannel) / 80%)), url('/cover-4.webp')`,
  58. backgroundSize: 'cover',
  59. backgroundPosition: 'center',
  60. backgroundRepeat: 'no-repeat'
  61. }}
  62. >
  63. {/* 标题和按钮 */}
  64. <div className="relative z-10 h-full flex flex-col justify-between p-4">
  65. <div className='flex justify-between items-center'>
  66. <Text strong style={{ color: 'white', fontSize: '16px' }}>{t('收益统计')}</Text>
  67. <Button
  68. type='primary'
  69. theme='solid'
  70. size='small'
  71. disabled={!userState?.user?.aff_quota || userState?.user?.aff_quota <= 0}
  72. onClick={() => setOpenTransfer(true)}
  73. className='!rounded-lg'
  74. >
  75. <Zap size={12} className="mr-1" />
  76. {t('划转到余额')}
  77. </Button>
  78. </div>
  79. {/* 统计数据 */}
  80. <div className='grid grid-cols-3 gap-6 mt-4'>
  81. {/* 待使用收益 */}
  82. <div className='text-center'>
  83. <div className='text-2xl font-bold mb-2' style={{ color: 'white' }}>
  84. {renderQuota(userState?.user?.aff_quota || 0)}
  85. </div>
  86. <div className='flex items-center justify-center text-sm'>
  87. <TrendingUp size={14} className="mr-1" style={{ color: 'rgba(255,255,255,0.8)' }} />
  88. <Text style={{ color: 'rgba(255,255,255,0.8)', fontSize: '12px' }}>{t('待使用收益')}</Text>
  89. </div>
  90. </div>
  91. {/* 总收益 */}
  92. <div className='text-center'>
  93. <div className='text-2xl font-bold mb-2' style={{ color: 'white' }}>
  94. {renderQuota(userState?.user?.aff_history_quota || 0)}
  95. </div>
  96. <div className='flex items-center justify-center text-sm'>
  97. <BarChart2 size={14} className="mr-1" style={{ color: 'rgba(255,255,255,0.8)' }} />
  98. <Text style={{ color: 'rgba(255,255,255,0.8)', fontSize: '12px' }}>{t('总收益')}</Text>
  99. </div>
  100. </div>
  101. {/* 邀请人数 */}
  102. <div className='text-center'>
  103. <div className='text-2xl font-bold mb-2' style={{ color: 'white' }}>
  104. {userState?.user?.aff_count || 0}
  105. </div>
  106. <div className='flex items-center justify-center text-sm'>
  107. <Users size={14} className="mr-1" style={{ color: 'rgba(255,255,255,0.8)' }} />
  108. <Text style={{ color: 'rgba(255,255,255,0.8)', fontSize: '12px' }}>{t('邀请人数')}</Text>
  109. </div>
  110. </div>
  111. </div>
  112. </div>
  113. </div>
  114. }
  115. >
  116. {/* 邀请链接部分 */}
  117. <Input
  118. value={affLink}
  119. readonly
  120. className='!rounded-lg'
  121. prefix={t('邀请链接')}
  122. suffix={
  123. <Button
  124. type='primary'
  125. theme='solid'
  126. onClick={handleAffLinkClick}
  127. icon={<Copy size={14} />}
  128. className='!rounded-lg'
  129. >
  130. {t('复制')}
  131. </Button>
  132. }
  133. />
  134. </Card>
  135. {/* 奖励说明 */}
  136. <Card
  137. className='!rounded-xl w-full'
  138. title={
  139. <Text type='tertiary'>
  140. {t('奖励说明')}
  141. </Text>
  142. }
  143. >
  144. <div className='space-y-3'>
  145. <div className='flex items-start gap-2'>
  146. <Badge dot type='success' />
  147. <Text type='tertiary' className='text-sm'>
  148. {t('邀请好友注册,好友充值后您可获得相应奖励')}
  149. </Text>
  150. </div>
  151. <div className='flex items-start gap-2'>
  152. <Badge dot type='success' />
  153. <Text type='tertiary' className='text-sm'>
  154. {t('通过划转功能将奖励额度转入到您的账户余额中')}
  155. </Text>
  156. </div>
  157. <div className='flex items-start gap-2'>
  158. <Badge dot type='success' />
  159. <Text type='tertiary' className='text-sm'>
  160. {t('邀请的好友越多,获得的奖励越多')}
  161. </Text>
  162. </div>
  163. </div>
  164. </Card>
  165. </Space>
  166. </Card>
  167. );
  168. };
  169. export default InvitationCard;