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
8988d1f8
Commit
8988d1f8
authored
Jun 19, 2023
by
raca
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 星星
parent
12f3db6c
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
89 additions
and
36 deletions
+89
-36
auth.ts
src/api/auth.ts
+17
-0
pk.ts
src/api/pk.ts
+3
-1
battles-modal.tsx
src/pages/battles/components/battles-modal.tsx
+39
-21
game-result.module.scss
src/pages/battles/components/game-result.module.scss
+2
-0
game-result.tsx
src/pages/battles/components/game-result.tsx
+12
-4
header.tsx
src/pages/main/main-underground/header.tsx
+2
-2
top-bar.tsx
src/pages/prepare/components/top-bar.tsx
+2
-2
user.ts
src/store/modules/user.ts
+12
-6
No files found.
src/api/auth.ts
View file @
8988d1f8
...
...
@@ -2,6 +2,7 @@ import { request, requestAfterSilentLogin } from '@/utils/request'
import
{
request
as
requesNative
}
from
'@tarojs/taro'
import
{
getCurrentShareId
}
from
'@/utils/share'
import
type
{
UserInfo
}
from
'@/types'
import
{
PkDetails
,
PkRecord
}
from
'./pk'
type
LoginResult
=
UserInfo
...
...
@@ -130,3 +131,19 @@ export function changeNickName (nickName: string) {
}
}))
}
export
type
AccountInfo
=
{
accounts
:
AccountOut
[];
pkList
:
PkRecord
[];
stars
:
number
;
}
&
Pick
<
PkDetails
,
'userRanks'
|
'winPkNum'
>
export
const
fetchAccountInfo
=
()
=>
{
return
requestAfterSilentLogin
<
AccountInfo
,
{
userId
?:
number
}
>
((
userInfo
)
=>
({
url
:
'/service-idea/home/index'
,
method
:
'GET'
,
data
:
{
userId
:
userInfo
?.
userId
,
},
}))
}
src/api/pk.ts
View file @
8988d1f8
...
...
@@ -32,9 +32,10 @@ export function fetchUserDetails (data: PkParams) {
}
export
type
PkRecord
=
{
createTime
:
string
;
createTime
:
string
,
id
:
number
,
initiator
:
number
,
initiatorLevel
:
string
,
initiatorAvatar
:
string
,
initiatorErrNum
:
number
,
initiatorName
:
string
,
...
...
@@ -45,6 +46,7 @@ export type PkRecord = {
recipientErrNum
:
number
,
recipientName
:
string
,
recipientResultTime
:
number
,
recipientLevel
:
string
,
result
:
'LOSE'
|
'WIN'
,
stageName
:
string
}
...
...
src/pages/battles/components/battles-modal.tsx
View file @
8988d1f8
...
...
@@ -13,18 +13,12 @@ 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
summary
=
useStoreState
((
state
)
=>
state
.
battlesModel
.
summary
)
const
fetchUserSummary
=
useStoreActions
(
(
actions
)
=>
actions
.
battlesModel
.
fetchUserSummary
const
pkDetails
=
useStoreState
((
state
)
=>
state
.
userModel
.
pkDetails
)
const
isVisible
=
useStoreState
((
state
)
=>
state
.
battlesModel
.
modalIsVisible
)
const
setModalIsVisible
=
useStoreActions
(
(
actions
)
=>
actions
.
battlesModel
.
setModalIsVisible
)
useEffect
(()
=>
{
fetchUserSummary
({})
},
[
fetchUserSummary
])
return
(
<
Modal
isVisible=
{
isVisible
}
...
...
@@ -53,7 +47,7 @@ const BattlesModal = () => {
/>
<
View
className=
{
styles
.
detailsRight
}
>
<
Text
className=
{
styles
.
badgeText
}
>
{
rankTranslate
(
summary
?.
userRanks
.
level
)
}
{
rankTranslate
(
pkDetails
?.
userRanks
.
level
)
}
</
Text
>
<
View
className=
{
styles
.
badgeBar
}
>
{
[...
Array
(
3
)].
map
((
_
,
index
)
=>
(
...
...
@@ -61,7 +55,9 @@ const BattlesModal = () => {
key=
{
index
}
className=
{
classNames
(
styles
.
badgeBarItem
,
index
<
(
summary
?.
userRanks
.
star
||
0
)
?
styles
.
active
:
null
index
<
(
pkDetails
?.
userRanks
.
star
||
0
)
?
styles
.
active
:
null
)
}
></
Text
>
))
}
...
...
@@ -70,10 +66,13 @@ const BattlesModal = () => {
</
View
>
<
ScrollView
className=
{
styles
.
gameResult
}
scrollY
>
{
summary
&&
summary
?.
records
.
length
>
0
?
summary
?.
records
.
map
((
item
)
=>
<
GameResult
key=
{
item
.
id
}
record=
{
item
}
/>)
:
<
Text
className=
{
styles
.
emptyText
}
>
暂无PK记录
</
Text
>
}
{
pkDetails
&&
pkDetails
?.
pkList
.
length
>
0
?
(
pkDetails
?.
pkList
.
map
((
item
)
=>
(
<
GameResult
key=
{
item
.
id
}
record=
{
item
}
/>
))
)
:
(
<
Text
className=
{
styles
.
emptyText
}
>
暂无PK记录
</
Text
>
)
}
</
ScrollView
>
</
View
>
</
Modal
>
...
...
@@ -96,17 +95,36 @@ const GameResult = ({ record }: GameResultProps) => {
src=
{
wined
?
assets
[
'win.png'
].
u
:
assets
[
'lose.png'
].
u
}
className=
{
gameResultStyles
.
levelResult
}
/>
<
Text
className=
{
gameResultStyles
.
levelDate
}
>
{
convertDateTime
(
record
.
createTime
)
}
</
Text
>
<
Text
className=
{
gameResultStyles
.
levelDate
}
>
{
convertDateTime
(
record
.
createTime
)
}
</
Text
>
</
View
>
<
View
className=
{
styles
.
gameBody
}
>
<
View
className=
{
styles
.
playerSection
}
>
<
View
className=
{
classNames
(
styles
.
userInfo
,
wined
?
styles
.
win
:
styles
.
lose
)
}
>
<
UserInfo
name=
{
record
.
initiatorName
}
/>
<
View
className=
{
classNames
(
styles
.
userInfo
,
wined
?
styles
.
win
:
styles
.
lose
)
}
>
<
UserInfo
level=
{
record
.
initiatorLevel
}
name=
{
record
.
initiatorName
}
/>
</
View
>
<
Image
className=
{
gameResultStyles
.
vs
}
src=
{
assets
[
'vs.png'
].
u
}
/>
<
View
className=
{
classNames
(
styles
.
userInfo
,
!
wined
?
styles
.
win
:
styles
.
lose
)
}
>
<
UserInfo
style=
{
{
alignItems
:
'flex-end'
}
}
name=
{
record
.
recipientName
}
/>
<
View
className=
{
classNames
(
styles
.
userInfo
,
!
wined
?
styles
.
win
:
styles
.
lose
)
}
>
<
UserInfo
style=
{
{
alignItems
:
'flex-end'
}
}
level=
{
record
.
recipientLevel
}
name=
{
record
.
recipientName
}
/>
</
View
>
</
View
>
</
View
>
...
...
src/pages/battles/components/game-result.module.scss
View file @
8988d1f8
...
...
@@ -64,6 +64,8 @@
.userName
{
font-weight
:
600
;
max-width
:
220px
;
height
:
44px
;
line-height
:
44px
;
@include
ellipsis
();
}
...
...
src/pages/battles/components/game-result.tsx
View file @
8988d1f8
...
...
@@ -8,6 +8,7 @@ import { PkRecord } from '@/api/pk'
import
{
badgeImages
}
from
'../const'
import
styles
from
'./game-result.module.scss'
import
{
rankTranslate
}
from
'../utils'
export
interface
GameResultProps
{
record
:
PkRecord
...
...
@@ -29,15 +30,18 @@ const GameResult = ({ record }: GameResultProps) => {
src=
{
assets
[
wined
?
'win.png'
:
'lose.png'
].
u
}
className=
{
styles
.
levelResult
}
/>
<
Text
className=
{
styles
.
levelDate
}
>
{
convertDateTime
(
record
.
createTime
)
}
</
Text
>
<
Text
className=
{
styles
.
levelDate
}
>
{
convertDateTime
(
record
.
createTime
)
}
</
Text
>
</
View
>
<
View
className=
{
styles
.
gameBody
}
>
<
View
className=
{
styles
.
playerSection
}
>
<
UserInfo
name=
{
record
.
initiatorName
}
/>
<
UserInfo
level=
{
record
.
recipientLevel
}
name=
{
record
.
initiatorName
}
/>
<
Image
className=
{
styles
.
vs
}
src=
{
assets
[
'vs.png'
].
u
}
/>
<
UserInfo
style=
{
{
alignItems
:
'flex-end'
}
}
level=
{
record
.
recipientLevel
}
name=
{
record
.
recipientName
}
/>
</
View
>
...
...
@@ -57,7 +61,11 @@ const GameResult = ({ record }: GameResultProps) => {
)
}
export
const
UserInfo
=
(
user
:
{
name
:
string
;
style
?:
CSSProperties
})
=>
(
export
const
UserInfo
=
(
user
:
{
name
:
string
level
:
string
style
?:
CSSProperties
})
=>
(
<
View
style=
{
user
.
style
}
className=
{
styles
.
userInfo
}
>
<
Text
className=
{
styles
.
userName
}
>
{
user
.
name
}
</
Text
>
<
View
className=
{
styles
.
userBadge
}
>
...
...
@@ -65,7 +73,7 @@ export const UserInfo = (user: { name: string; style?: CSSProperties }) => (
className=
{
styles
.
userIcon
}
src=
{
assets
[
badgeImages
.
diamond
.
small
].
u
}
/>
<
Text
className=
{
styles
.
userLevel
}
>
{
user
.
name
}
</
Text
>
<
Text
className=
{
styles
.
userLevel
}
>
{
rankTranslate
(
user
.
level
)
}
</
Text
>
</
View
>
</
View
>
)
...
...
src/pages/main/main-underground/header.tsx
View file @
8988d1f8
...
...
@@ -27,7 +27,7 @@ const MainHeader = () => {
}
},
[
sys
,
nav
])
const
cardNum
=
useStoreState
(
state
=>
state
.
userModel
.
cardNum
)
const
pkDetails
=
useStoreState
(
state
=>
state
.
userModel
.
pkDetails
)
const
point
=
useStoreState
(
state
=>
state
.
userModel
.
point
)
const
userInfo
=
useStoreState
(
state
=>
state
.
userModel
.
userInfo
)
...
...
@@ -51,7 +51,7 @@ const MainHeader = () => {
</
View
>
<
View
className=
{
classNames
(
styles
.
ph
,
cs
.
bounce_btn
)
}
onClick=
{
goStore
}
hoverClass=
{
cs
.
bounce_btn_hover
}
id=
"main_header_ph"
>
<
Image
src=
{
assets
[
'star.png'
].
u
}
className=
{
styles
.
icon
}
/>
<
Text
>
{
cardNum
}
</
Text
>
<
Text
>
{
pkDetails
?.
stars
}
</
Text
>
</
View
>
</
View
>
</
View
>
...
...
src/pages/prepare/components/top-bar.tsx
View file @
8988d1f8
...
...
@@ -15,7 +15,7 @@ const goStore = () => {
export
default
({
isFirstStage
}:
{
isFirstStage
:
boolean
})
=>
{
const
nav
=
useMemo
(
getMenuButtonBoundingClientRect
,
[])
const
cardNum
=
useStoreState
(
state
=>
state
.
userModel
.
cardNum
)
const
pkDetails
=
useStoreState
(
state
=>
state
.
userModel
.
pkDetails
)
const
point
=
useStoreState
(
state
=>
state
.
userModel
.
point
)
const
sys
=
useMemo
(
getSystemInfoSync
,
[])
...
...
@@ -44,7 +44,7 @@ export default ({ isFirstStage }: { isFirstStage: boolean }) => {
</
Scene3
>
<
View
className=
{
styles
.
ph
}
onClick=
{
goStore
}
>
<
Image
src=
{
assets
[
'star.png'
].
u
}
className=
{
styles
.
icon
}
/>
<
Text
>
{
cardNum
}
</
Text
>
<
Text
>
{
pkDetails
?.
stars
}
</
Text
>
</
View
>
</
View
>
<
View
style=
{
rightStyle
}
className=
{
styles
.
right
}
></
View
>
...
...
src/store/modules/user.ts
View file @
8988d1f8
import
{
action
,
Action
,
Thunk
,
thunk
,
State
}
from
'easy-peasy'
import
{
getAccountInfo
,
getSetting
,
type
SettintType
,
updateUserInfo
,
type
UpdateUserInfoIn
,
updateUserPhone
,
changeNickName
}
from
'@/api'
import
{
fetchAccountInfo
,
getSetting
,
type
SettintType
,
updateUserInfo
,
type
UpdateUserInfoIn
,
updateUserPhone
,
changeNickName
,
AccountInfo
}
from
'@/api'
import
type
{
UserInfo
}
from
'@/types'
import
{
ExchangeParams
,
accountExchange
,
pointToCard
}
from
'@/api/account'
import
{
showModal
,
show
Toast
,
show
Loading
,
hideLoading
}
from
'@tarojs/taro'
import
{
showModal
,
showLoading
,
hideLoading
}
from
'@tarojs/taro'
import
{
getStorage
,
StorageKeys
,
updateStorage
}
from
'@/utils/storage'
import
{
Deferred
}
from
'@/utils/deferred'
import
{
AppStoreModel
}
from
'../store-model'
...
...
@@ -13,6 +13,7 @@ export interface UserModel {
/** 加入部落 */
joinDefered
:
Deferred
|
null
;
userInfo
:
UserInfo
;
pkDetails
:
Omit
<
AccountInfo
,
'accounts'
>
|
null
;
cardNum
:
number
;
point
:
number
;
updating
:
boolean
;
...
...
@@ -33,6 +34,7 @@ export interface UserModel {
const
userModel
:
UserModel
=
{
joinDefered
:
null
,
pkDetails
:
null
,
userInfo
:
getStorage
(
StorageKeys
.
userInfo
)
!
,
isEyeProtectionMode
:
false
,
cardNum
:
0
,
...
...
@@ -162,11 +164,15 @@ const userModel: UserModel = {
fetchAccount
:
thunk
(
async
(
actions
)
=>
{
try
{
const
{
data
:
list
}
=
await
getAccountInfo
()
const
cardNum
=
list
.
find
(
c
=>
c
.
accountType
===
'CARD'
)?.
amount
??
0
const
point
=
list
.
find
(
c
=>
c
.
accountType
===
'POINT'
)?.
amount
??
0
actions
.
updateState
({
cardNum
,
point
})
const
{
data
,
code
}
=
await
fetchAccountInfo
()
if
(
code
===
0
)
{
const
{
accounts
,
...
pkDetails
}
=
data
const
cardNum
=
accounts
.
find
(
c
=>
c
.
accountType
===
'CARD'
)?.
amount
??
0
const
point
=
accounts
.
find
(
c
=>
c
.
accountType
===
'POINT'
)?.
amount
??
0
actions
.
updateState
({
cardNum
,
point
,
pkDetails
})
return
point
}
return
0
}
catch
(
err
)
{
actions
.
updateState
({
cardNum
:
0
,
point
:
0
})
return
0
...
...
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