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
4b4f12e0
Commit
4b4f12e0
authored
Jun 20, 2023
by
hewenhao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 添加pk完成后音乐
parent
86557b8f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
1 deletion
+13
-1
battle-complete.tsx
src/pages/game/play/components/battle-complete.tsx
+13
-1
No files found.
src/pages/game/play/components/battle-complete.tsx
View file @
4b4f12e0
import
{
View
,
Image
,
Button
}
from
'@tarojs/components'
import
{
View
,
Image
,
Button
}
from
'@tarojs/components'
import
assetsGame
from
'@/assets/oss/assets-game'
import
assetsGame
from
'@/assets/oss/assets-game'
import
assetsPrepare
from
'@/assets/oss/assets-prepare'
import
assetsPrepare
from
'@/assets/oss/assets-prepare'
import
assetsAudio
from
'@/assets/oss/assets-audio'
import
classNames
from
'classnames'
import
classNames
from
'classnames'
import
{
useMemo
,
useEffect
}
from
'react'
import
{
useMemo
,
useEffect
}
from
'react'
import
{
reLaunch
}
from
'@tarojs/taro'
import
{
reLaunch
}
from
'@tarojs/taro'
...
@@ -8,6 +9,7 @@ import { useStoreActions, useStoreState } from '@/store/hooks'
...
@@ -8,6 +9,7 @@ import { useStoreActions, useStoreState } from '@/store/hooks'
import
{
getUserRank
}
from
'@/utils'
import
{
getUserRank
}
from
'@/utils'
import
{
getUserLevelIcon
,
getUserLevelName
,
getUserLevelSubName
}
from
'@/constants'
import
{
getUserLevelIcon
,
getUserLevelName
,
getUserLevelSubName
}
from
'@/constants'
import
{
PkResult
}
from
'@/api'
import
{
PkResult
}
from
'@/api'
import
{
palyAudio
}
from
'@/utils/play-audio'
import
styles
from
'./battle-complete.module.scss'
import
styles
from
'./battle-complete.module.scss'
...
@@ -15,6 +17,13 @@ type BattleCompleteProps = {
...
@@ -15,6 +17,13 @@ type BattleCompleteProps = {
pkResult
:
PkResult
|
null
pkResult
:
PkResult
|
null
}
}
const
getAudio
=
(
win
:
boolean
)
=>
{
if
(
win
)
{
return
assetsAudio
[
'S通关.wav'
].
u
}
return
assetsAudio
[
'闯关失败.wav'
].
u
}
const
BattleComplete
=
({
pkResult
}:
BattleCompleteProps
)
=>
{
const
BattleComplete
=
({
pkResult
}:
BattleCompleteProps
)
=>
{
const
updateState
=
useStoreActions
(
actions
=>
actions
.
mainModel
.
updateState
)
const
updateState
=
useStoreActions
(
actions
=>
actions
.
mainModel
.
updateState
)
const
setting
=
useStoreState
(
state
=>
state
.
userModel
.
setting
)
const
setting
=
useStoreState
(
state
=>
state
.
userModel
.
setting
)
...
@@ -53,11 +62,14 @@ const BattleComplete = ({ pkResult }: BattleCompleteProps) => {
...
@@ -53,11 +62,14 @@ const BattleComplete = ({ pkResult }: BattleCompleteProps) => {
return
isInitiatorFail
return
isInitiatorFail
},
[
pkResult
,
isMySelf
,
isInitiatorFail
])
},
[
pkResult
,
isMySelf
,
isInitiatorFail
])
const
audioUrl
=
useMemo
(()
=>
getAudio
(
headerWin
),
[
headerWin
])
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
pkResult
)
{
if
(
pkResult
)
{
getSetting
()
getSetting
()
palyAudio
(
audioUrl
)
}
}
},
[
getSetting
,
pkResult
])
},
[
getSetting
,
pkResult
,
audioUrl
])
const
score
=
useMemo
(()
=>
{
const
score
=
useMemo
(()
=>
{
if
(
headerWin
)
{
if
(
headerWin
)
{
...
...
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