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