|
@@ -1,6 +1,10 @@
|
|
|
import React, { useEffect, useState } from 'react';
|
|
import React, { useEffect, useState } from 'react';
|
|
|
import { API, isMobile, showError, showInfo, showSuccess } from '../../helpers';
|
|
import { API, isMobile, showError, showInfo, showSuccess } from '../../helpers';
|
|
|
-import { renderNumber, renderQuota } from '../../helpers/render';
|
|
|
|
|
|
|
+import {
|
|
|
|
|
+ renderNumber,
|
|
|
|
|
+ renderQuota,
|
|
|
|
|
+ renderQuotaWithAmount,
|
|
|
|
|
+} from '../../helpers/render';
|
|
|
import {
|
|
import {
|
|
|
Col,
|
|
Col,
|
|
|
Layout,
|
|
Layout,
|
|
@@ -12,6 +16,7 @@ import {
|
|
|
Divider,
|
|
Divider,
|
|
|
Space,
|
|
Space,
|
|
|
Modal,
|
|
Modal,
|
|
|
|
|
+ Toast,
|
|
|
} from '@douyinfe/semi-ui';
|
|
} from '@douyinfe/semi-ui';
|
|
|
import Title from '@douyinfe/semi-ui/lib/es/typography/title';
|
|
import Title from '@douyinfe/semi-ui/lib/es/typography/title';
|
|
|
import Text from '@douyinfe/semi-ui/lib/es/typography/text';
|
|
import Text from '@douyinfe/semi-ui/lib/es/typography/text';
|
|
@@ -20,7 +25,7 @@ import { Link } from 'react-router-dom';
|
|
|
const TopUp = () => {
|
|
const TopUp = () => {
|
|
|
const [redemptionCode, setRedemptionCode] = useState('');
|
|
const [redemptionCode, setRedemptionCode] = useState('');
|
|
|
const [topUpCode, setTopUpCode] = useState('');
|
|
const [topUpCode, setTopUpCode] = useState('');
|
|
|
- const [topUpCount, setTopUpCount] = useState(10);
|
|
|
|
|
|
|
+ const [topUpCount, setTopUpCount] = useState(0);
|
|
|
const [minTopupCount, setMinTopUpCount] = useState(1);
|
|
const [minTopupCount, setMinTopUpCount] = useState(1);
|
|
|
const [amount, setAmount] = useState(0.0);
|
|
const [amount, setAmount] = useState(0.0);
|
|
|
const [minTopUp, setMinTopUp] = useState(1);
|
|
const [minTopUp, setMinTopUp] = useState(1);
|
|
@@ -76,11 +81,9 @@ const TopUp = () => {
|
|
|
showError('管理员未开启在线充值!');
|
|
showError('管理员未开启在线充值!');
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- if (amount === 0) {
|
|
|
|
|
- await getAmount();
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ await getAmount();
|
|
|
if (topUpCount < minTopUp) {
|
|
if (topUpCount < minTopUp) {
|
|
|
- showInfo('充值数量不能小于' + minTopUp);
|
|
|
|
|
|
|
+ showError('充值数量不能小于' + minTopUp);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
setPayWay(payment);
|
|
setPayWay(payment);
|
|
@@ -92,7 +95,7 @@ const TopUp = () => {
|
|
|
await getAmount();
|
|
await getAmount();
|
|
|
}
|
|
}
|
|
|
if (topUpCount < minTopUp) {
|
|
if (topUpCount < minTopUp) {
|
|
|
- showInfo('充值数量不能小于' + minTopUp);
|
|
|
|
|
|
|
+ showError('充值数量不能小于' + minTopUp);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
setOpen(false);
|
|
setOpen(false);
|
|
@@ -189,7 +192,8 @@ const TopUp = () => {
|
|
|
if (message === 'success') {
|
|
if (message === 'success') {
|
|
|
setAmount(parseFloat(data));
|
|
setAmount(parseFloat(data));
|
|
|
} else {
|
|
} else {
|
|
|
- showError(data);
|
|
|
|
|
|
|
+ setAmount(0);
|
|
|
|
|
+ Toast.error({ content: '错误:' + data, id: 'getAmount' });
|
|
|
// setTopUpCount(parseInt(res.data.count));
|
|
// setTopUpCount(parseInt(res.data.count));
|
|
|
// setAmount(parseInt(data));
|
|
// setAmount(parseInt(data));
|
|
|
}
|
|
}
|
|
@@ -222,7 +226,7 @@ const TopUp = () => {
|
|
|
size={'small'}
|
|
size={'small'}
|
|
|
centered={true}
|
|
centered={true}
|
|
|
>
|
|
>
|
|
|
- <p>充值数量:{topUpCount}$</p>
|
|
|
|
|
|
|
+ <p>充值数量:{topUpCount}</p>
|
|
|
<p>实付金额:{renderAmount()}</p>
|
|
<p>实付金额:{renderAmount()}</p>
|
|
|
<p>是否确认充值?</p>
|
|
<p>是否确认充值?</p>
|
|
|
</Modal>
|
|
</Modal>
|
|
@@ -274,21 +278,16 @@ const TopUp = () => {
|
|
|
disabled={!enableOnlineTopUp}
|
|
disabled={!enableOnlineTopUp}
|
|
|
field={'redemptionCount'}
|
|
field={'redemptionCount'}
|
|
|
label={'实付金额:' + renderAmount()}
|
|
label={'实付金额:' + renderAmount()}
|
|
|
- placeholder={'充值数量,最低' + minTopUp + '$'}
|
|
|
|
|
|
|
+ placeholder={
|
|
|
|
|
+ '充值数量,最低 ' + renderQuotaWithAmount(minTopUp)
|
|
|
|
|
+ }
|
|
|
name='redemptionCount'
|
|
name='redemptionCount'
|
|
|
type={'number'}
|
|
type={'number'}
|
|
|
value={topUpCount}
|
|
value={topUpCount}
|
|
|
- suffix={'$'}
|
|
|
|
|
- min={minTopUp}
|
|
|
|
|
- defaultValue={minTopUp}
|
|
|
|
|
- max={100000}
|
|
|
|
|
onChange={async (value) => {
|
|
onChange={async (value) => {
|
|
|
if (value < 1) {
|
|
if (value < 1) {
|
|
|
value = 1;
|
|
value = 1;
|
|
|
}
|
|
}
|
|
|
- if (value > 100000) {
|
|
|
|
|
- value = 100000;
|
|
|
|
|
- }
|
|
|
|
|
setTopUpCount(value);
|
|
setTopUpCount(value);
|
|
|
await getAmount(value);
|
|
await getAmount(value);
|
|
|
}}
|
|
}}
|