Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
GeekLearnMathWeapp
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
frontend
GeekLearnMathWeapp
Commits
ca005426
Commit
ca005426
authored
Jun 19, 2023
by
raca
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 优化
parent
1118e50d
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
82 additions
and
55 deletions
+82
-55
pk.ts
src/api/pk.ts
+4
-4
battles-modal.tsx
src/pages/battles/components/battles-modal.tsx
+15
-17
game-result.tsx
src/pages/battles/components/game-result.tsx
+4
-3
player-details.tsx
src/pages/battles/components/player-details.tsx
+6
-5
index.tsx
src/pages/battles/index.tsx
+6
-9
model.ts
src/pages/battles/model.ts
+10
-10
utils.ts
src/pages/battles/utils.ts
+27
-0
exchange-rename-card.tsx
src/pages/market/components/exchange-rename-card.tsx
+1
-1
top-bar.tsx
src/pages/prepare/components/top-bar.tsx
+2
-1
user.ts
src/store/modules/user.ts
+7
-5
No files found.
src/api/pk.ts
View file @
ca005426
...
...
@@ -45,19 +45,19 @@ export type PkRecord = {
recipientErrNum
:
number
,
recipientName
:
string
,
recipientResultTime
:
number
,
result
:
string
,
result
:
'LOSE'
|
'WIN'
,
stageName
:
string
}
export
type
Pk
Records
=
{
export
type
Pk
Summary
=
{
records
:
PkRecord
[]
}
&
Pick
<
PkDetails
,
'allPkNum'
|
'userRanks'
|
'winPkNum'
>
export
function
fetchUser
Records
(
data
:
PkParams
)
{
export
function
fetchUser
Summary
(
data
:
PkParams
)
{
if
(
!
data
.
stageId
)
{
delete
data
.
stageId
}
return
requestAfterSilentLogin
<
Pk
Records
,
PkParams
>
((
userInfo
)
=>
{
return
requestAfterSilentLogin
<
Pk
Summary
,
PkParams
>
((
userInfo
)
=>
{
data
.
userId
=
data
.
userId
||
userInfo
?.
userId
return
{
method
:
'GET'
,
...
...
src/pages/battles/components/battles-modal.tsx
View file @
ca005426
...
...
@@ -10,23 +10,20 @@ import { UserInfo, GameResultProps } from './game-result'
import
styles
from
'./battles-modal.module.scss'
import
gameResultStyles
from
'./game-result.module.scss'
import
{
rankTranslate
}
from
'../utils'
const
BattlesModal
=
()
=>
{
const
isVisible
=
useStoreState
(
state
=>
state
.
battlesModel
.
modalIsVisible
)
const
setModalIsVisible
=
useStoreActions
(
actions
=>
actions
.
battlesModel
.
setModalIsVisible
)
const
details
=
useStoreState
((
state
)
=>
state
.
battlesModel
.
details
)
const
records
=
useStoreState
((
state
)
=>
state
.
battlesModel
.
records
)
const
summary
=
useStoreState
((
state
)
=>
state
.
battlesModel
.
summary
)
const
fetchUserDetails
=
useStoreActions
(
(
actions
)
=>
actions
.
battlesModel
.
fetchUserDetails
)
const
fetchUserRecords
=
useStoreActions
(
(
actions
)
=>
actions
.
battlesModel
.
fetchUserRecords
const
fetchUserSummary
=
useStoreActions
(
(
actions
)
=>
actions
.
battlesModel
.
fetchUserSummary
)
useEffect
(()
=>
{
Promise
.
allSettled
([
fetchUserDetails
({}),
fetchUserRecords
({})]
)
},
[
fetchUser
Details
,
fetchUserRecords
])
fetchUserSummary
({}
)
},
[
fetchUser
Summary
])
return
(
<
Modal
...
...
@@ -56,7 +53,7 @@ const BattlesModal = () => {
/>
<
View
className=
{
styles
.
detailsRight
}
>
<
Text
className=
{
styles
.
badgeText
}
>
{
details
?.
userRanks
.
level
||
'-'
}
{
rankTranslate
(
summary
?.
userRanks
.
level
)
}
</
Text
>
<
View
className=
{
styles
.
badgeBar
}
>
{
[...
Array
(
3
)].
map
((
_
,
index
)
=>
(
...
...
@@ -64,7 +61,7 @@ const BattlesModal = () => {
key=
{
index
}
className=
{
classNames
(
styles
.
badgeBarItem
,
index
<
(
details
?.
userRanks
.
star
||
0
)
?
styles
.
active
:
null
index
<
(
summary
?.
userRanks
.
star
||
0
)
?
styles
.
active
:
null
)
}
></
Text
>
))
}
...
...
@@ -73,8 +70,8 @@ const BattlesModal = () => {
</
View
>
<
ScrollView
className=
{
styles
.
gameResult
}
scrollY
>
{
records
.
length
>
0
?
records
.
map
((
item
)
=>
<
GameResult
key=
{
item
.
id
}
record=
{
item
}
/>)
{
summary
&&
summary
?.
records
.
length
>
0
?
summary
?.
records
.
map
((
item
)
=>
<
GameResult
key=
{
item
.
id
}
record=
{
item
}
/>)
:
<
Text
className=
{
styles
.
emptyText
}
>
暂无PK记录
</
Text
>
}
</
ScrollView
>
...
...
@@ -84,18 +81,19 @@ const BattlesModal = () => {
}
const
GameResult
=
({
record
}:
GameResultProps
)
=>
{
const
wined
=
record
.
result
===
'WIN'
return
(
<
View
className=
{
gameResultStyles
.
gameResult
}
>
<
View
className=
{
classNames
(
gameResultStyles
.
levelInfo
,
record
.
result
?
gameResultStyles
.
win
:
gameResultStyles
.
lose
wined
?
gameResultStyles
.
win
:
gameResultStyles
.
lose
)
}
>
<
Text
className=
{
gameResultStyles
.
levelName
}
>
{
record
.
stageName
}
</
Text
>
<
Image
mode=
"widthFix"
src=
{
record
.
result
?
assets
[
'win.png'
].
u
:
assets
[
'lose.png'
].
u
}
src=
{
wined
?
assets
[
'win.png'
].
u
:
assets
[
'lose.png'
].
u
}
className=
{
gameResultStyles
.
levelResult
}
/>
<
Text
className=
{
gameResultStyles
.
levelDate
}
>
{
convertDateTime
(
record
.
createTime
)
}
</
Text
>
...
...
@@ -103,11 +101,11 @@ const GameResult = ({ record }: GameResultProps) => {
<
View
className=
{
styles
.
gameBody
}
>
<
View
className=
{
styles
.
playerSection
}
>
<
View
className=
{
classNames
(
styles
.
userInfo
,
record
.
result
?
styles
.
win
:
styles
.
lose
)
}
>
<
View
className=
{
classNames
(
styles
.
userInfo
,
wined
?
styles
.
win
:
styles
.
lose
)
}
>
<
UserInfo
name=
{
record
.
initiatorName
}
/>
</
View
>
<
Image
className=
{
gameResultStyles
.
vs
}
src=
{
assets
[
'vs.png'
].
u
}
/>
<
View
className=
{
classNames
(
styles
.
userInfo
,
!
record
.
result
?
styles
.
win
:
styles
.
lose
)
}
>
<
View
className=
{
classNames
(
styles
.
userInfo
,
!
wined
?
styles
.
win
:
styles
.
lose
)
}
>
<
UserInfo
style=
{
{
alignItems
:
'flex-end'
}
}
name=
{
record
.
recipientName
}
/>
</
View
>
</
View
>
...
...
src/pages/battles/components/game-result.tsx
View file @
ca005426
...
...
@@ -14,18 +14,19 @@ export interface GameResultProps {
}
const
GameResult
=
({
record
}:
GameResultProps
)
=>
{
const
wined
=
record
.
result
===
'WIN'
return
(
<
View
className=
{
styles
.
gameResult
}
>
<
View
className=
{
classNames
(
styles
.
levelInfo
,
record
.
result
?
styles
.
win
:
styles
.
lose
wined
?
styles
.
win
:
styles
.
lose
)
}
>
<
Text
className=
{
styles
.
levelName
}
>
{
record
.
stageName
}
</
Text
>
<
Image
mode=
"widthFix"
src=
{
assets
[
record
.
result
?
'win.png'
:
'lose.png'
].
u
}
src=
{
assets
[
wined
?
'win.png'
:
'lose.png'
].
u
}
className=
{
styles
.
levelResult
}
/>
<
Text
className=
{
styles
.
levelDate
}
>
{
convertDateTime
(
record
.
createTime
)
}
</
Text
>
...
...
@@ -41,7 +42,7 @@ const GameResult = ({ record }: GameResultProps) => {
/>
</
View
>
<
GameStats
result=
{
record
.
result
}
result=
{
wined
}
initiator=
{
{
err
:
record
.
initiatorErrNum
,
time
:
record
.
initiatorResultTime
,
...
...
src/pages/battles/components/player-details.tsx
View file @
ca005426
...
...
@@ -5,9 +5,10 @@ import assets from '@/assets/oss/assets-pk'
import
styles
from
'./player-details.module.scss'
import
{
badgeImages
}
from
'../const'
import
{
rankTranslate
}
from
'../utils'
const
PlayerDetails
=
()
=>
{
const
details
=
useStoreState
((
state
)
=>
state
.
battlesModel
.
details
)
const
summary
=
useStoreState
((
state
)
=>
state
.
battlesModel
.
summary
)
return
(
<
View
className=
{
styles
.
player
}
>
<
View
className=
{
styles
.
playerHeader
}
>
...
...
@@ -16,7 +17,7 @@ const PlayerDetails = () => {
className=
{
styles
.
badgeIcon
}
></
Image
>
<
Text
className=
{
styles
.
badgeText
}
>
{
details
?.
userRanks
.
level
||
'-'
}
{
rankTranslate
(
summary
?.
userRanks
.
level
)
}
</
Text
>
<
View
className=
{
styles
.
badgeBar
}
>
{
[...
Array
(
3
)].
map
((
_
,
index
)
=>
(
...
...
@@ -24,7 +25,7 @@ const PlayerDetails = () => {
key=
{
index
}
className=
{
classNames
(
styles
.
badgeBarItem
,
index
<
(
details
?.
userRanks
.
star
||
0
)
?
styles
.
active
:
null
index
<
(
summary
?.
userRanks
.
star
||
0
)
?
styles
.
active
:
null
)
}
></
Text
>
))
}
...
...
@@ -33,13 +34,13 @@ const PlayerDetails = () => {
<
View
className=
{
styles
.
playerFooter
}
>
<
View
className=
{
styles
.
stats
}
>
<
View
>
胜
<
Text
className=
{
styles
.
winText
}
>
{
details
?.
winPkNum
||
0
}
</
Text
>
胜
<
Text
className=
{
styles
.
winText
}
>
{
summary
?.
winPkNum
||
0
}
</
Text
>
</
View
>
<
Image
className=
{
styles
.
icon
}
src=
{
assets
[
'stats.png'
].
u
}
/>
<
View
>
负
<
Text
className=
{
styles
.
loseText
}
>
{
(
details
?.
allPkNum
||
0
)
-
(
details
?.
winPkNum
||
0
)
}
{
(
summary
?.
allPkNum
||
0
)
-
(
summary
?.
winPkNum
||
0
)
}
</
Text
>
</
View
>
</
View
>
...
...
src/pages/battles/index.tsx
View file @
ca005426
...
...
@@ -12,17 +12,14 @@ import styles from './index.module.scss'
const
Battles
=
()
=>
{
const
nav
=
useMemo
(
getMenuButtonBoundingClientRect
,
[])
const
records
=
useStoreState
((
state
)
=>
state
.
battlesModel
.
records
)
const
summary
=
useStoreState
((
state
)
=>
state
.
battlesModel
.
summary
)
const
fetchUserDetails
=
useStoreActions
(
(
actions
)
=>
actions
.
battlesModel
.
fetchUserDetails
)
const
fetchUserRecords
=
useStoreActions
(
(
actions
)
=>
actions
.
battlesModel
.
fetchUserRecords
const
fetchUserSummary
=
useStoreActions
(
(
actions
)
=>
actions
.
battlesModel
.
fetchUserSummary
)
useDidShow
(()
=>
{
Promise
.
allSettled
([
fetchUserDetails
({}),
fetchUserRecords
({})]
)
fetchUserSummary
({}
)
})
return
(
...
...
@@ -49,8 +46,8 @@ const Battles = () => {
</
View
>
<
View
className=
{
styles
.
gameResult
}
>
{
records
.
length
>
0
?
records
.
map
((
item
)
=>
<
GameResult
key=
{
item
.
id
}
record=
{
item
}
/>)
{
summary
&&
summary
.
records
.
length
>
0
?
summary
.
records
.
map
((
item
)
=>
<
GameResult
key=
{
item
.
id
}
record=
{
item
}
/>)
:
<
Text
className=
{
styles
.
emptyText
}
>
暂无PK记录
</
Text
>
}
</
View
>
...
...
src/pages/battles/model.ts
View file @
ca005426
import
{
Action
,
Thunk
,
action
,
thunk
}
from
'easy-peasy'
import
{
fetchUserDetails
,
fetchUser
Records
,
type
PkParams
,
type
PkDetails
,
type
PkRecord
}
from
'@/api/pk'
import
{
fetchUserDetails
,
fetchUser
Summary
,
type
PkParams
,
type
PkDetails
,
type
PkSummary
}
from
'@/api/pk'
interface
BattlesModel
{
details
:
PkDetails
|
null
,
records
:
PkRecord
[]
;
summary
:
PkSummary
|
null
;
modalIsVisible
:
boolean
;
setModalIsVisible
:
Action
<
BattlesModel
,
boolean
>
;
setUserDetails
:
Action
<
BattlesModel
,
PkDetails
>
;
setUser
Records
:
Action
<
BattlesModel
,
PkRecord
[]
>
;
setUser
Summary
:
Action
<
BattlesModel
,
PkSummary
>
;
fetchUserDetails
:
Thunk
<
BattlesModel
,
PkParams
>
;
fetchUser
Records
:
Thunk
<
BattlesModel
,
PkParams
>
;
fetchUser
Summary
:
Thunk
<
BattlesModel
,
PkParams
>
;
}
const
battlesModel
:
BattlesModel
=
{
details
:
null
,
records
:
[]
,
summary
:
null
,
modalIsVisible
:
true
,
setModalIsVisible
:
action
((
state
,
payload
)
=>
{
...
...
@@ -25,8 +25,8 @@ const battlesModel: BattlesModel = {
state
.
details
=
payload
}),
setUser
Records
:
action
((
state
,
payload
)
=>
{
state
.
records
=
payload
setUser
Summary
:
action
((
state
,
payload
)
=>
{
state
.
summary
=
payload
}),
fetchUserDetails
:
thunk
(
async
(
actions
,
payload
)
=>
{
...
...
@@ -37,10 +37,10 @@ const battlesModel: BattlesModel = {
}
}),
fetchUser
Records
:
thunk
(
async
(
actions
,
payload
)
=>
{
fetchUser
Summary
:
thunk
(
async
(
actions
,
payload
)
=>
{
try
{
const
res
=
await
fetchUser
Records
(
payload
)
actions
.
setUser
Records
(
res
.
data
.
records
)
const
res
=
await
fetchUser
Summary
(
payload
)
actions
.
setUser
Summary
(
res
.
data
)
}
catch
(
err
)
{
}
}),
...
...
src/pages/battles/utils.ts
0 → 100644
View file @
ca005426
type
Rank
=
'BRONZE'
|
'SILVER'
|
'GOLD'
|
'PLATINUM'
|
'DIAMOND'
function
toRomanNumeral
(
num
:
number
):
string
{
const
roman
:
{
[
key
:
number
]:
string
}
=
{
1
:
'I'
,
2
:
'II'
,
3
:
'III'
,
}
return
roman
[
num
]
}
export
function
rankTranslate
(
rankWithLevel
:
string
|
undefined
):
string
{
if
(
!
rankWithLevel
)
{
return
'-'
}
const
[
rank
,
level
]
=
rankWithLevel
.
split
(
'_'
)
const
rankName
:
{
[
key
in
Rank
]?:
string
}
=
{
BRONZE
:
'青铜'
,
SILVER
:
'白银'
,
GOLD
:
'黄金'
,
PLATINUM
:
'铂金'
,
DIAMOND
:
'钻石'
,
}
return
`
${
rankName
[
rank
as
Rank
]}
${
toRomanNumeral
(
Number
(
level
))}
`
}
src/pages/market/components/exchange-rename-card.tsx
View file @
ca005426
...
...
@@ -79,7 +79,7 @@ const ExchangeRenameCard = (props: ExchangeItemProps) => {
})
.
then
(()
=>
{
changeNickName
(
name
).
then
(()
=>
{
showToast
({
title
:
'
操作
成功'
,
icon
:
'success'
})
showToast
({
title
:
'
修改
成功'
,
icon
:
'success'
})
onCancel
&&
onCancel
()
})
})
...
...
src/pages/prepare/components/top-bar.tsx
View file @
ca005426
import
{
View
,
Image
,
Text
}
from
'@tarojs/components'
import
{
useMemo
}
from
'react'
import
{
navigateTo
,
getMenuButtonBoundingClientRect
,
navigateBack
,
getSystemInfoSync
}
from
'@tarojs/taro'
import
assets
from
'@/assets/oss/assets-main-next'
import
{
useStoreState
}
from
'@/store/hooks'
import
Scene3
from
'../guide/complete/scene-3'
...
...
@@ -42,7 +43,7 @@ export default () => {
<
Text
>
{
point
}
</
Text
>
</
Scene3
>
<
View
className=
{
styles
.
ph
}
onClick=
{
goStore
}
>
<
Image
src=
{
require
(
'@/pages/main/assets/ph.png'
)
}
className=
{
styles
.
icon
}
/>
<
Image
src=
{
assets
[
'star.png'
].
u
}
className=
{
styles
.
icon
}
/>
<
Text
>
{
cardNum
}
</
Text
>
</
View
>
</
View
>
...
...
src/store/modules/user.ts
View file @
ca005426
...
...
@@ -179,22 +179,24 @@ const userModel: UserModel = {
const
{
data
:
list
}
=
await
accountExchange
(
payload
)
const
point
=
list
.
find
(
c
=>
c
.
accountType
===
'POINT'
)?.
amount
??
0
actions
.
updateState
({
point
})
hideLoading
()
}
catch
(
err
)
{
hideLoading
()
showModal
({
title
:
'提示'
,
content
:
err
.
message
,
showCancel
:
false
})
throw
err
}
finally
{
hideLoading
()
}
}),
changeNickName
:
thunk
(
async
(
_
,
payload
)
=>
{
changeNickName
:
thunk
(
async
(
actions
,
payload
)
=>
{
try
{
const
{
data
}
=
await
changeNickName
(
payload
)
console
.
log
(
data
)
const
{
code
}
=
await
changeNickName
(
payload
)
if
(
code
===
0
)
{
actions
.
updateUserInfo
({
nickName
:
payload
})
}
}
catch
(
err
)
{
showModal
({
title
:
'提示'
,
...
...
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