PaymentConfirmModal.jsx 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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. Modal,
  18. Typography,
  19. Card,
  20. Skeleton,
  21. } from '@douyinfe/semi-ui';
  22. import { SiAlipay, SiWechat, SiStripe } from 'react-icons/si';
  23. import { CreditCard } from 'lucide-react';
  24. const { Text } = Typography;
  25. const PaymentConfirmModal = ({
  26. t,
  27. open,
  28. onlineTopUp,
  29. handleCancel,
  30. confirmLoading,
  31. topUpCount,
  32. renderQuotaWithAmount,
  33. amountLoading,
  34. renderAmount,
  35. payWay,
  36. payMethods,
  37. }) => {
  38. return (
  39. <Modal
  40. title={
  41. <div className='flex items-center'>
  42. <CreditCard className='mr-2' size={18} />
  43. {t('充值确认')}
  44. </div>
  45. }
  46. visible={open}
  47. onOk={onlineTopUp}
  48. onCancel={handleCancel}
  49. maskClosable={false}
  50. size='small'
  51. centered
  52. confirmLoading={confirmLoading}
  53. >
  54. <div className='space-y-4'>
  55. <Card className='!rounded-xl !border-0 bg-slate-50 dark:bg-slate-800'>
  56. <div className='space-y-3'>
  57. <div className='flex justify-between items-center'>
  58. <Text strong className='text-slate-700 dark:text-slate-200'>{t('充值数量')}:</Text>
  59. <Text className='text-slate-900 dark:text-slate-100'>{renderQuotaWithAmount(topUpCount)}</Text>
  60. </div>
  61. <div className='flex justify-between items-center'>
  62. <Text strong className='text-slate-700 dark:text-slate-200'>{t('实付金额')}:</Text>
  63. {amountLoading ? (
  64. <Skeleton.Title style={{ width: '60px', height: '16px' }} />
  65. ) : (
  66. <Text strong className='font-bold' style={{ color: 'red' }}>
  67. {renderAmount()}
  68. </Text>
  69. )}
  70. </div>
  71. <div className='flex justify-between items-center'>
  72. <Text strong className='text-slate-700 dark:text-slate-200'>{t('支付方式')}:</Text>
  73. <div className='flex items-center'>
  74. {(() => {
  75. const payMethod = payMethods.find(
  76. (method) => method.type === payWay,
  77. );
  78. if (payMethod) {
  79. return (
  80. <>
  81. {payMethod.type === 'alipay' ? (
  82. <SiAlipay className='mr-2' size={16} color="#1677FF" />
  83. ) : payMethod.type === 'wxpay' ? (
  84. <SiWechat className='mr-2' size={16} color="#07C160" />
  85. ) : payMethod.type === 'stripe' ? (
  86. <SiStripe className='mr-2' size={16} color="#635BFF" />
  87. ) : (
  88. <CreditCard className='mr-2' size={16} color={payMethod.color || 'var(--semi-color-text-2)'} />
  89. )}
  90. <Text className='text-slate-900 dark:text-slate-100'>{payMethod.name}</Text>
  91. </>
  92. );
  93. } else {
  94. // 默认充值方式
  95. if (payWay === 'alipay') {
  96. return (
  97. <>
  98. <SiAlipay className='mr-2' size={16} color="#1677FF" />
  99. <Text className='text-slate-900 dark:text-slate-100'>{t('支付宝')}</Text>
  100. </>
  101. );
  102. } else if (payWay === 'stripe') {
  103. return (
  104. <>
  105. <SiStripe className='mr-2' size={16} color="#635BFF" />
  106. <Text className='text-slate-900 dark:text-slate-100'>Stripe</Text>
  107. </>
  108. );
  109. } else {
  110. return (
  111. <>
  112. <SiWechat className='mr-2' size={16} color="#07C160" />
  113. <Text className='text-slate-900 dark:text-slate-100'>{t('微信')}</Text>
  114. </>
  115. );
  116. }
  117. }
  118. })()}
  119. </div>
  120. </div>
  121. </div>
  122. </Card>
  123. </div>
  124. </Modal>
  125. );
  126. };
  127. export default PaymentConfirmModal;