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
63c4b162
authored
Nov 08, 2023
by
CaIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
钱包页面完善
parent
767c7e3e
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
132 additions
and
172 deletions
+132
-172
web/src/components/HeaderBar.js
+12
-25
web/src/components/LoginForm.js
+44
-44
web/src/components/SiderBar.js
+0
-28
web/src/pages/TopUp/index.js
+76
-75
No files found.
web/src/components/HeaderBar.js
View file @
63c4b162
import
React
,
{
useContext
,
useState
}
from
'react'
;
import
React
,
{
useContext
,
use
Effect
,
use
State
}
from
'react'
;
import
{
Link
,
useNavigate
}
from
'react-router-dom'
;
import
{
Link
,
useNavigate
}
from
'react-router-dom'
;
import
{
UserContext
}
from
'../context/User'
;
import
{
UserContext
}
from
'../context/User'
;
...
@@ -45,8 +45,10 @@ const HeaderBar = () => {
...
@@ -45,8 +45,10 @@ const HeaderBar = () => {
let
navigate
=
useNavigate
();
let
navigate
=
useNavigate
();
const
[
showSidebar
,
setShowSidebar
]
=
useState
(
false
);
const
[
showSidebar
,
setShowSidebar
]
=
useState
(
false
);
const
[
dark
,
setDark
]
=
useState
(
false
);
const
systemName
=
getSystemName
();
const
systemName
=
getSystemName
();
const
logo
=
getLogo
();
const
logo
=
getLogo
();
var
themeMode
=
localStorage
.
getItem
(
'theme-mode'
);
async
function
logout
()
{
async
function
logout
()
{
setShowSidebar
(
false
);
setShowSidebar
(
false
);
...
@@ -57,37 +59,22 @@ const HeaderBar = () => {
...
@@ -57,37 +59,22 @@ const HeaderBar = () => {
navigate
(
'/login'
);
navigate
(
'/login'
);
}
}
useEffect
(()
=>
{
if
(
themeMode
===
'dark'
)
{
switchMode
(
true
);
}
},
[]);
const
renderButtons
=
(
isMobile
)
=>
{
return
headerButtons
.
map
((
button
)
=>
{
if
(
button
.
admin
&&
!
isAdmin
())
return
<><
/>
;
if
(
isMobile
)
{
return
(
<
Menu
.
Item
onClick
=
{()
=>
{
navigate
(
button
.
to
);
setShowSidebar
(
false
);
}}
>
{
button
.
name
}
<
/Menu.Item
>
);
}
return
(
<
Menu
.
Item
key
=
{
button
.
name
}
as
=
{
Link
}
to
=
{
button
.
to
}
>
<
Icon
name
=
{
button
.
icon
}
/
>
{
button
.
name
}
<
/Menu.Item
>
);
});
};
const
switchMode
=
(
model
)
=>
{
const
switchMode
=
(
model
)
=>
{
const
body
=
document
.
body
;
const
body
=
document
.
body
;
if
(
!
model
)
{
if
(
!
model
)
{
body
.
removeAttribute
(
'theme-mode'
);
body
.
removeAttribute
(
'theme-mode'
);
localStorage
.
setItem
(
'theme-mode'
,
'light'
);
}
else
{
}
else
{
body
.
setAttribute
(
'theme-mode'
,
'dark'
);
body
.
setAttribute
(
'theme-mode'
,
'dark'
);
localStorage
.
setItem
(
'theme-mode'
,
'dark'
);
}
}
setDark
(
model
);
};
};
return
(
return
(
<>
<>
...
@@ -119,7 +106,7 @@ const HeaderBar = () => {
...
@@ -119,7 +106,7 @@ const HeaderBar = () => {
footer
=
{
footer
=
{
<>
<>
<
Nav
.
Item
itemKey
=
{
'about'
}
icon
=
{
<
IconHelpCircle
/>
}
/
>
<
Nav
.
Item
itemKey
=
{
'about'
}
icon
=
{
<
IconHelpCircle
/>
}
/
>
<
Switch
checkedText
=
"🌞"
size
=
{
'large'
}
uncheckedText
=
"🌙"
onChange
=
{
switchMode
}
/
>
<
Switch
checkedText
=
"🌞"
size
=
{
'large'
}
checked
=
{
dark
}
uncheckedText
=
"🌙"
onChange
=
{
switchMode
}
/
>
{
userState
.
user
?
{
userState
.
user
?
<>
<>
<
Dropdown
<
Dropdown
...
...
web/src/components/LoginForm.js
View file @
63c4b162
...
@@ -163,55 +163,55 @@ const LoginForm = () => {
...
@@ -163,55 +163,55 @@ const LoginForm = () => {
)
:
(
)
:
(
<><
/
>
<><
/
>
)}
)}
{
status
.
wechat_login
?
(
{
/*{status.wechat_login ? (*/
}
<
Button
{
/* <Button*/
}
circular
{
/* circular*/
}
color
=
'green'
{
/* color='green'*/
}
icon
=
'wechat'
{
/* icon='wechat'*/
}
onClick
=
{
onWeChatLoginClicked
}
{
/* onClick={onWeChatLoginClicked}*/
}
/
>
{
/* />*/
}
)
:
(
{
/*) : (*/
}
<><
/
>
{
/* <></>*/
}
)
}
{
/*)}*/
}
<
/div
>
<
/div
>
<
/
>
<
/
>
)
:
(
)
:
(
<><
/
>
<><
/
>
)}
)}
<
Modal
{
/*<Modal*/
}
onClose
=
{()
=>
setShowWeChatLoginModal
(
false
)
}
{
/* onClose={() => setShowWeChatLoginModal(false)}*/
}
onOpen
=
{()
=>
setShowWeChatLoginModal
(
true
)
}
{
/* onOpen={() => setShowWeChatLoginModal(true)}*/
}
open
=
{
showWeChatLoginModal
}
{
/* open={showWeChatLoginModal}*/
}
size
=
{
'mini'
}
{
/* size={'mini'}*/
}
>
{
/*>*/
}
<
Modal
.
Content
>
{
/* <Modal.Content>*/
}
<
Modal
.
Description
>
{
/* <Modal.Description>*/
}
<
Image
src
=
{
status
.
wechat_qrcode
}
fluid
/>
{
/* <Image src={status.wechat_qrcode} fluid/>*/
}
<
div
style
=
{{
textAlign
:
'center'
}}
>
{
/* <div style={{textAlign: 'center'}}>*/
}
<
p
>
{
/* <p>*/
}
微信扫码关注公众号,输入「验证码」获取验证码(三分钟内有效)
{
/* 微信扫码关注公众号,输入「验证码」获取验证码(三分钟内有效)*/
}
<
/p
>
{
/* </p>*/
}
<
/div
>
{
/* </div>*/
}
<
Form
size
=
'large'
>
{
/* <Form size='large'>*/
}
<
Form
.
Input
{
/* <Form.Input*/
}
field
=
{
'wechat_verification_code'
}
{
/* field={'wechat_verification_code'}*/
}
placeholder
=
'验证码'
{
/* placeholder='验证码'*/
}
name
=
'wechat_verification_code'
{
/* name='wechat_verification_code'*/
}
value
=
{
inputs
.
wechat_verification_code
}
{
/* value={inputs.wechat_verification_code}*/
}
onChange
=
{
handleChange
}
{
/* onChange={handleChange}*/
}
/
>
{
/* />*/
}
<
Button
{
/* <Button*/
}
color
=
''
{
/* color=''*/
}
fluid
{
/* fluid*/
}
size
=
'large'
{
/* size='large'*/
}
onClick
=
{
onSubmitWeChatVerificationCode
}
{
/* onClick={onSubmitWeChatVerificationCode}*/
}
>
{
/* >*/
}
登录
{
/* 登录*/
}
<
/Button
>
{
/* </Button>*/
}
<
/Form
>
{
/* </Form>*/
}
<
/Modal.Description
>
{
/* </Modal.Description>*/
}
<
/Modal.Content
>
{
/* </Modal.Content>*/
}
<
/Modal
>
{
/*</Modal>*/
}
<
/Card
>
<
/Card
>
{
turnstileEnabled
?
(
{
turnstileEnabled
?
(
<
div
style
=
{{
display
:
'flex'
,
justifyContent
:
'center'
,
marginTop
:
20
}}
>
<
div
style
=
{{
display
:
'flex'
,
justifyContent
:
'center'
,
marginTop
:
20
}}
>
...
...
web/src/components/SiderBar.js
View file @
63c4b162
...
@@ -114,34 +114,6 @@ const HeaderBar = () => {
...
@@ -114,34 +114,6 @@ const HeaderBar = () => {
navigate
(
'/login'
);
navigate
(
'/login'
);
}
}
const
toggleSidebar
=
()
=>
{
setShowSidebar
(
!
showSidebar
);
};
const
renderButtons
=
(
isMobile
)
=>
{
return
headerButtons
.
map
((
button
)
=>
{
if
(
button
.
admin
&&
!
isAdmin
())
return
<><
/>
;
if
(
isMobile
)
{
return
(
<
Menu
.
Item
onClick
=
{()
=>
{
navigate
(
button
.
to
);
setShowSidebar
(
false
);
}}
>
{
button
.
name
}
<
/Menu.Item
>
);
}
return
(
<
Menu
.
Item
key
=
{
button
.
name
}
as
=
{
Link
}
to
=
{
button
.
to
}
>
<
Icon
name
=
{
button
.
icon
}
/
>
{
button
.
name
}
<
/Menu.Item
>
);
});
};
return
(
return
(
<>
<>
<
Layout
>
<
Layout
>
...
...
web/src/pages/TopUp/index.js
View file @
63c4b162
import
React
,
{
useEffect
,
useState
}
from
'react'
;
import
React
,
{
useEffect
,
useState
}
from
'react'
;
import
{
Button
,
Card
,
Confirm
,
Form
,
Grid
,
Header
,
Segment
,
Statistic
}
from
'semantic-ui-react'
;
import
{
Confirm
}
from
'semantic-ui-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
}
from
'../../helpers/render'
;
import
{
Col
,
Layout
,
Row
,
Typography
}
from
"@douyinfe/semi-ui"
;
import
{
Col
,
Layout
,
Row
,
Typography
,
Card
,
Button
,
Form
,
Divider
,
Space
,
Modal
}
from
"@douyinfe/semi-ui"
;
import
Title
from
"@douyinfe/semi-ui/lib/es/typography/title"
;
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
(
10
);
const
[
amount
,
setAmount
]
=
useState
(
0
);
const
[
amount
,
setAmount
]
=
useState
(
0
.0
);
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
);
...
@@ -17,7 +18,7 @@ const TopUp = () => {
...
@@ -17,7 +18,7 @@ const TopUp = () => {
const
topUp
=
async
()
=>
{
const
topUp
=
async
()
=>
{
if
(
redemptionCode
===
''
)
{
if
(
redemptionCode
===
''
)
{
showInfo
(
'请输入
充值
码!'
)
showInfo
(
'请输入
兑换
码!'
)
return
;
return
;
}
}
setIsSubmitting
(
true
);
setIsSubmitting
(
true
);
...
@@ -27,7 +28,8 @@ const TopUp = () => {
...
@@ -27,7 +28,8 @@ const TopUp = () => {
});
});
const
{
success
,
message
,
data
}
=
res
.
data
;
const
{
success
,
message
,
data
}
=
res
.
data
;
if
(
success
)
{
if
(
success
)
{
showSuccess
(
'充值成功!'
);
showSuccess
(
'兑换成功!'
);
Modal
.
success
({
title
:
'兑换成功!'
,
content
:
'成功兑换额度:'
+
renderQuota
(
data
),
centered
:
true
});
setUserQuota
((
quota
)
=>
{
setUserQuota
((
quota
)
=>
{
return
quota
+
data
;
return
quota
+
data
;
});
});
...
@@ -142,7 +144,7 @@ const TopUp = () => {
...
@@ -142,7 +144,7 @@ const TopUp = () => {
const
{
message
,
data
}
=
res
.
data
;
const
{
message
,
data
}
=
res
.
data
;
// showInfo(message);
// showInfo(message);
if
(
message
===
'success'
)
{
if
(
message
===
'success'
)
{
setAmount
(
parse
In
t
(
data
));
setAmount
(
parse
Floa
t
(
data
));
}
else
{
}
else
{
showError
(
data
);
showError
(
data
);
// setTopUpCount(parseInt(res.data.count));
// setTopUpCount(parseInt(res.data.count));
...
@@ -168,91 +170,90 @@ const TopUp = () => {
...
@@ -168,91 +170,90 @@ const TopUp = () => {
<
h3
>
我的钱包
<
/h3
>
<
h3
>
我的钱包
<
/h3
>
<
/Layout.Header
>
<
/Layout.Header
>
<
Layout
.
Content
>
<
Layout
.
Content
>
<
div
style
=
{{
marginTop
:
20
,
paddingLeft
:
isMobile
()?
0
:
200
,
paddingRight
:
isMobile
()?
0
:
200
}}
>
<
Modal
title
=
"确定要充值吗"
visible
=
{
open
}
onOk
=
{
onlineTopUp
}
onCancel
=
{
handleCancel
}
maskClosable
=
{
false
}
size
=
{
'small'
}
centered
=
{
true
}
>
<
p
>
充值数量:
{
topUpCount
}
<
/p
>
<
p
>
充值金额:
{
renderAmount
()}
<
/p
>
<
p
>
是否确认充值?
<
/p
>
<
/Modal
>
<
div
style
=
{{
marginTop
:
20
,
display
:
'flex'
,
justifyContent
:
'center'
}}
>
<
Card
<
Card
style
=
{{
width
:
'
100%
'
,
padding
:
'20px'
}}
style
=
{{
width
:
'
500px
'
,
padding
:
'20px'
}}
>
>
<
Confirm
<
Title
level
=
{
3
}
style
=
{{
textAlign
:
'center'
}}
>
余额
{
renderQuota
(
userQuota
)}
<
/Title
>
open
=
{
open
}
<
div
style
=
{{
marginTop
:
20
}}
>
content
=
{
'充值数量:'
+
topUpCount
+
',充值金额:'
+
renderAmount
()
+
',是否确认充值?'
}
<
Divider
>
cancelButton
=
'取消充值'
兑换余额
confirmButton
=
"确定"
<
/Divider
>
onCancel
=
{
handleCancel
}
<
Form
>
onConfirm
=
{
onlineTopUp
}
<
Form
.
Input
/
>
field
=
{
'redemptionCode'
}
<
h3
>
兑换
<
/h3
>
label
=
{
'兑换码'
}
<
Grid
columns
=
{
2
}
stackable
>
placeholder
=
'兑换码'
<
Grid
.
Column
>
name
=
'redemptionCode'
<
Form
>
value
=
{
redemptionCode
}
<
Form
.
Input
onChange
=
{(
value
)
=>
{
placeholder
=
'兑换码'
setRedemptionCode
(
value
);
name
=
'redemptionCode'
}}
value
=
{
redemptionCode
}
/
>
onChange
=
{(
e
)
=>
{
<
Space
>
setRedemptionCode
(
e
.
target
.
value
);
{
}}
topUpLink
?
/
>
<
Button
type
=
{
'primary'
}
theme
=
{
'solid'
}
onClick
=
{
openTopUpLink
}
>
<
Button
color
=
'green'
onClick
=
{
openTopUpLink
}
>
获取兑换码
获取兑换码
<
/Button> : nul
l
<
/Button
>
}
<
Button
color
=
'yellow'
onClick
=
{
topUp
}
disabled
=
{
isSubmitting
}
>
<
Button
type
=
{
"warning"
}
theme
=
{
'solid'
}
onClick
=
{
topUp
}
disabled
=
{
isSubmitting
}
>
{
isSubmitting
?
'兑换中...'
:
'兑换'
}
{
isSubmitting
?
'兑换中...'
:
'兑换'
}
<
/Button
>
<
/Button
>
<
/Form
>
<
/Space
>
<
/Grid.Column
>
<
/Form
>
<
Grid
.
Column
>
<
/div
>
<
Statistic
.
Group
widths
=
'one'
>
<
div
style
=
{{
marginTop
:
20
}}
>
<
Statistic
>
<
Divider
>
<
Statistic
.
Value
>
{
renderQuota
(
userQuota
)}
<
/Statistic.Value
>
在线充值
<
Statistic
.
Label
>
剩余额度
<
/Statistic.Label
>
<
/Divider
>
<
/Statistic
>
<
Form
>
<
/Statistic.Group
>
<
Form
.
Input
<
/Grid.Column
>
field
=
{
'redemptionCount'
}
<
/Grid
>
label
=
{
'充值金额:'
+
renderAmount
()}
<
/Card
>
placeholder
=
'充值数量'
<
Card
name
=
'redemptionCount'
style
=
{{
width
:
'100%'
,
padding
:
'20px'
}}
type
=
{
'number'
}
>
value
=
{
topUpCount
}
<
Header
as
=
'h3'
>
在线充值,最低
1
<
/Header
>
onChange
=
{
async
(
value
)
=>
{
<
Grid
columns
=
{
2
}
stackable
>
setTopUpCount
(
value
);
<
Grid
.
Column
>
await
getAmount
(
value
);
<
Form
>
}}
<
Form
.
Input
/
>
placeholder
=
'充值金额,最低1'
<
Space
>
name
=
'redemptionCount'
<
Button
type
=
{
'primary'
}
theme
=
{
'solid'
}
onClick
=
{
type
=
{
'number'
}
value
=
{
topUpCount
}
autoComplete
=
{
'off'
}
onChange
=
{
async
(
e
)
=>
{
setTopUpCount
(
e
.
target
.
value
);
await
getAmount
(
e
.
target
.
value
);
}}
/
>
<
Button
color
=
'blue'
onClick
=
{
async
()
=>
{
async
()
=>
{
preTopUp
(
'zfb'
)
preTopUp
(
'zfb'
)
}
}
}
>
}
>
支付宝
支付宝
<
/Button
>
<
/Button
>
<
Button
color
=
'green'
onClick
=
{
<
Button
style
=
{{
backgroundColor
:
'rgba(var(--semi-green-5), 1)'
}}
type
=
{
'primary'
}
theme
=
{
'solid'
}
onClick
=
{
async
()
=>
{
async
()
=>
{
preTopUp
(
'wx'
)
preTopUp
(
'wx'
)
}
}
}
>
}
>
微信
微信
<
/Button
>
<
/Button
>
<
/Form
>
<
/Space
>
<
/Grid.Column
>
<
/Form
>
<
Grid
.
Column
>
<
/div
>
<
Statistic
.
Group
widths
=
'one'
>
<
Statistic
>
<
Statistic
.
Value
>
{
renderAmount
()}
<
/Statistic.Value
>
<
Statistic
.
Label
>
支付金额
<
/Statistic.Label
>
<
/Statistic
>
<
/Statistic.Group
>
<
/Grid.Column
>
<
/Grid
>
<
/Card
>
<
/Card
>
<
/div
>
<
/div
>
...
...
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