Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
32bb9ff7
authored
Oct 11, 2023
by
CaIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 充值前弹窗确认
parent
ee1edbcc
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
5 deletions
+28
-5
web/src/pages/TopUp/index.js
+28
-5
No files found.
web/src/pages/TopUp/index.js
View file @
32bb9ff7
import
React
,
{
useEffect
,
useState
}
from
'react'
;
import
React
,
{
useEffect
,
useState
}
from
'react'
;
import
{
Button
,
Form
,
Grid
,
Header
,
Segment
,
Statistic
}
from
'semantic-ui-react'
;
import
{
Button
,
Confirm
,
Form
,
Grid
,
Header
,
Segment
,
Statistic
}
from
'semantic-ui-react'
;
import
{
API
,
showError
,
showInfo
,
showSuccess
}
from
'../../helpers'
;
import
{
API
,
showError
,
showInfo
,
showSuccess
}
from
'../../helpers'
;
import
{
renderNumber
,
renderQuota
}
from
'../../helpers/render'
;
import
{
renderNumber
,
renderQuota
}
from
'../../helpers/render'
;
...
@@ -11,6 +11,8 @@ const TopUp = () => {
...
@@ -11,6 +11,8 @@ const TopUp = () => {
const
[
topUpLink
,
setTopUpLink
]
=
useState
(
''
);
const
[
topUpLink
,
setTopUpLink
]
=
useState
(
''
);
const
[
userQuota
,
setUserQuota
]
=
useState
(
0
);
const
[
userQuota
,
setUserQuota
]
=
useState
(
0
);
const
[
isSubmitting
,
setIsSubmitting
]
=
useState
(
false
);
const
[
isSubmitting
,
setIsSubmitting
]
=
useState
(
false
);
const
[
open
,
setOpen
]
=
useState
(
false
);
const
[
payWay
,
setPayWay
]
=
useState
(
''
);
const
topUp
=
async
()
=>
{
const
topUp
=
async
()
=>
{
if
(
redemptionCode
===
''
)
{
if
(
redemptionCode
===
''
)
{
...
@@ -47,15 +49,24 @@ const TopUp = () => {
...
@@ -47,15 +49,24 @@ const TopUp = () => {
window
.
open
(
topUpLink
,
'_blank'
);
window
.
open
(
topUpLink
,
'_blank'
);
};
};
const
onlin
eTopUp
=
async
(
payment
)
=>
{
const
pr
eTopUp
=
async
(
payment
)
=>
{
if
(
amount
===
0
)
{
if
(
amount
===
0
)
{
await
getAmount
();
await
getAmount
();
}
}
setPayWay
(
payment
)
setOpen
(
true
);
}
const
onlineTopUp
=
async
()
=>
{
if
(
amount
===
0
)
{
await
getAmount
();
}
setOpen
(
false
);
try
{
try
{
const
res
=
await
API
.
post
(
'/api/user/pay'
,
{
const
res
=
await
API
.
post
(
'/api/user/pay'
,
{
amount
:
parseInt
(
topUpCount
),
amount
:
parseInt
(
topUpCount
),
top_up_code
:
topUpCode
,
top_up_code
:
topUpCode
,
PaymentMethod
:
pay
ment
PaymentMethod
:
pay
Way
});
});
if
(
res
!==
undefined
)
{
if
(
res
!==
undefined
)
{
const
{
message
,
data
}
=
res
.
data
;
const
{
message
,
data
}
=
res
.
data
;
...
@@ -145,9 +156,21 @@ const TopUp = () => {
...
@@ -145,9 +156,21 @@ const TopUp = () => {
}
}
}
}
const
handleCancel
=
()
=>
{
setOpen
(
false
);
}
return
(
return
(
<
div
>
<
div
>
<
Segment
>
<
Segment
>
<
Confirm
open
=
{
open
}
content
=
{
'充值数量:'
+
topUpCount
+
',充值金额:'
+
renderAmount
()
+
',是否确认充值?'
}
cancelButton
=
'取消充值'
confirmButton
=
"确定"
onCancel
=
{
handleCancel
}
onConfirm
=
{
onlineTopUp
}
/
>
<
Header
as
=
'h3'
>
充值额度
<
/Header
>
<
Header
as
=
'h3'
>
充值额度
<
/Header
>
<
Grid
columns
=
{
2
}
stackable
>
<
Grid
columns
=
{
2
}
stackable
>
<
Grid
.
Column
>
<
Grid
.
Column
>
...
@@ -204,14 +227,14 @@ const TopUp = () => {
...
@@ -204,14 +227,14 @@ const TopUp = () => {
{
/*/>*/
}
{
/*/>*/
}
<
Button
color
=
'blue'
onClick
=
{
<
Button
color
=
'blue'
onClick
=
{
async
()
=>
{
async
()
=>
{
onlin
eTopUp
(
'zfb'
)
pr
eTopUp
(
'zfb'
)
}
}
}
>
}
>
支付宝
支付宝
<
/Button
>
<
/Button
>
<
Button
color
=
'green'
onClick
=
{
<
Button
color
=
'green'
onClick
=
{
async
()
=>
{
async
()
=>
{
onlin
eTopUp
(
'wx'
)
pr
eTopUp
(
'wx'
)
}
}
}
>
}
>
微信
微信
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment