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
7948aaf1
Commit
7948aaf1
authored
Jun 16, 2023
by
hewenhao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: pk答题
parent
e9438007
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
388 additions
and
90 deletions
+388
-90
.oss
assets/game/.oss
+12
-0
star-off.png
assets/game/star-off.png
+0
-0
star-on.png
assets/game/star-on.png
+0
-0
pk.ts
src/api/pk.ts
+27
-1
assets-game.ts
src/assets/oss/assets-game.ts
+10
-0
index.ts
src/hooks/index.ts
+1
-0
use-fetch.ts
src/hooks/use-fetch.ts
+130
-0
complete-head.module.scss
src/pages/game/complete/components/complete-head.module.scss
+46
-0
complete-head.tsx
src/pages/game/complete/components/complete-head.tsx
+31
-16
count-up.tsx
src/pages/game/play/components/count-up.tsx
+13
-3
index.ts
src/pages/game/play/model/index.ts
+20
-66
types.ts
src/pages/game/play/model/types.ts
+76
-0
chapter.tsx
src/pages/main/main-underground/chapter.tsx
+1
-1
create-pk.tsx
src/pages/main/main-underground/create-pk.tsx
+20
-2
index.tsx
src/pages/prepare/index.tsx
+1
-1
No files found.
assets/game/.oss
View file @
7948aaf1
...
@@ -106,5 +106,17 @@
...
@@ -106,5 +106,17 @@
"w": 48,
"w": 48,
"h": 48,
"h": 48,
"ossName": "/pk-math/4ZHYpvj1KLEypcgoBmhjEsN2bvC4/48x48"
"ossName": "/pk-math/4ZHYpvj1KLEypcgoBmhjEsN2bvC4/48x48"
},
"star-off.png": {
"u": "https://cdn.jkwljy.com/pk-math/4M6xW7oJhoEaafotmy3eY6xzBkw3/84x84",
"w": 84,
"h": 84,
"ossName": "/pk-math/4M6xW7oJhoEaafotmy3eY6xzBkw3/84x84"
},
"star-on.png": {
"u": "https://cdn.jkwljy.com/pk-math/3ETqmvyv7NrmaXkwoLSqPQ35kqUi/84x84",
"w": 84,
"h": 84,
"ossName": "/pk-math/3ETqmvyv7NrmaXkwoLSqPQ35kqUi/84x84"
}
}
}
}
assets/game/star-off.png
0 → 100644
View file @
7948aaf1
3.75 KB
assets/game/star-on.png
0 → 100644
View file @
7948aaf1
3.88 KB
src/api/pk.ts
View file @
7948aaf1
export
const
test
=
1
import
{
requestAfterSilentLogin
}
from
'@/utils/request'
type
GetPkDetailParams
=
{
userId
:
number
,
stageId
:
number
}
export
type
PkDetail
=
{
allPkNum
:
number
;
errNum
:
number
;
nickName
:
string
;
resultTime
:
number
;
stageId
:
number
;
stageName
:
string
;
userId
:
number
;
winPkNum
:
number
;
userRanks
:
{
level
:
string
;
star
:
number
;
}
}
export
const
getPkDetail
=
(
params
:
GetPkDetailParams
)
=>
{
return
requestAfterSilentLogin
<
PkDetail
,
GetPkDetailParams
>
(()
=>
({
url
:
'/service-idea/pk/personal/stage/detail'
,
data
:
params
,
method
:
'GET'
}))
}
src/assets/oss/assets-game.ts
View file @
7948aaf1
...
@@ -90,5 +90,15 @@ export default {
...
@@ -90,5 +90,15 @@ export default {
"u"
:
"https://cdn.jkwljy.com/pk-math/4ZHYpvj1KLEypcgoBmhjEsN2bvC4/48x48"
,
"u"
:
"https://cdn.jkwljy.com/pk-math/4ZHYpvj1KLEypcgoBmhjEsN2bvC4/48x48"
,
"w"
:
48
,
"w"
:
48
,
"h"
:
48
"h"
:
48
},
"star-off.png"
:
{
"u"
:
"https://cdn.jkwljy.com/pk-math/4M6xW7oJhoEaafotmy3eY6xzBkw3/84x84"
,
"w"
:
84
,
"h"
:
84
},
"star-on.png"
:
{
"u"
:
"https://cdn.jkwljy.com/pk-math/3ETqmvyv7NrmaXkwoLSqPQ35kqUi/84x84"
,
"w"
:
84
,
"h"
:
84
}
}
}
as
const
}
as
const
src/hooks/index.ts
View file @
7948aaf1
...
@@ -5,3 +5,4 @@ export * from './use-request'
...
@@ -5,3 +5,4 @@ export * from './use-request'
export
*
from
'./use-toggle'
export
*
from
'./use-toggle'
export
*
from
'./use-focus'
export
*
from
'./use-focus'
export
*
from
'./use-share'
export
*
from
'./use-share'
export
*
from
'./use-fetch'
src/hooks/use-fetch.ts
0 → 100644
View file @
7948aaf1
import
{
useRef
,
useReducer
,
useCallback
,
Reducer
,
}
from
'react'
import
{
BizError
}
from
'@/utils/request'
import
{
RequestResult
}
from
'@/types'
import
Taro
from
'@tarojs/taro'
export
type
RequestFn
<
T
=
unknown
,
P
=
unknown
>
=
(
arg
:
P
,
task
?:
(
arg
:
Taro
.
RequestTask
<
RequestResult
<
T
>>
)
=>
void
)
=>
Promise
<
RequestResult
<
T
>>
;
export
type
RequestParamsFn
<
P
=
unknown
>
=
()
=>
P
;
export
type
FormatFn
<
T
=
unknown
>
=
(
arg
:
T
,
sysTime
:
number
)
=>
T
;
export
type
RequestState
<
T
>
=
{
detail
:
T
|
null
;
isLoading
:
boolean
;
isLoad
:
boolean
;
error
:
string
|
null
;
}
export
type
UseRequestRet
<
T
,
P
>
=
[
RequestState
<
T
>
,
(
arg
?:
(
result
:
T
|
null
,
error
?:
BizError
<
T
>
)
=>
void
)
=>
void
,
(
arg
:
Partial
<
T
>
)
=>
void
]
enum
ActionType
{
Error
=
'1'
,
Load
=
'2'
,
Loading
=
'3'
}
function
getInitState
<
T
>
():
RequestState
<
T
>
{
return
{
detail
:
null
,
error
:
null
,
isLoad
:
false
,
isLoading
:
false
,
}
}
type
Action
<
T
>
=
|
{
type
:
ActionType
.
Error
,
payload
:
RequestState
<
T
>
[
'error'
]
}
|
{
type
:
ActionType
.
Loading
}
|
{
type
:
ActionType
.
Load
,
payload
:
Partial
<
RequestState
<
T
>>
}
function
reducer
<
T
>
(
state
:
RequestState
<
T
>
,
action
:
Action
<
T
>
):
RequestState
<
T
>
{
switch
(
action
.
type
)
{
case
ActionType
.
Loading
:
{
return
{
...
state
,
error
:
null
,
isLoading
:
true
}
}
case
ActionType
.
Error
:
{
return
{
...
state
,
error
:
action
.
payload
,
isLoad
:
true
,
isLoading
:
false
,
}
}
case
ActionType
.
Load
:
{
return
{
...
state
,
...
action
.
payload
,
error
:
null
,
isLoad
:
true
,
isLoading
:
false
,
}
}
}
}
function
defaultFormatFn
<
T
=
unknown
>
(
data
:
T
,
sysTime
:
number
)
{
return
data
}
export
function
useFetch
<
T
=
unknown
,
P
=
unknown
>
(
requestFn
:
RequestFn
<
T
,
P
>
,
paramsFn
?:
()
=>
P
,
formatFn
?:
FormatFn
<
T
>
,
):
UseRequestRet
<
T
,
P
>
{
const
requestTaskRef
=
useRef
<
Taro
.
RequestTask
<
RequestResult
<
T
>>
|
null
>
(
null
)
const
[
dataSource
,
dispatch
]
=
useReducer
<
Reducer
<
RequestState
<
T
>
,
Action
<
T
>>>
(
reducer
,
getInitState
<
T
>
())
const
loadData
=
useCallback
((
callback
:
(
result
:
T
|
null
,
error
?:
BizError
<
T
>
)
=>
void
)
=>
{
if
(
requestTaskRef
.
current
)
{
requestTaskRef
.
current
.
abort
()
requestTaskRef
.
current
=
null
}
dispatch
({
type
:
ActionType
.
Loading
})
let
params
:
P
=
undefined
as
unknown
as
P
if
(
paramsFn
)
{
params
=
paramsFn
()
}
return
requestFn
(
params
,
(
task
)
=>
{
requestTaskRef
.
current
=
task
})
.
then
(({
data
:
detail
,
sysTime
})
=>
{
const
formattedDetail
=
(
formatFn
??
defaultFormatFn
)(
detail
,
sysTime
)
dispatch
({
type
:
ActionType
.
Load
,
payload
:
{
detail
:
formattedDetail
},
})
if
(
typeof
callback
===
'function'
)
{
callback
(
formattedDetail
)
}
})
.
catch
((
error
:
BizError
<
T
>
)
=>
{
dispatch
({
type
:
ActionType
.
Error
,
payload
:
error
.
message
})
if
(
typeof
callback
===
'function'
)
{
callback
(
null
,
error
)
}
})
.
finally
(()
=>
{
requestTaskRef
.
current
=
null
})
},
[
requestFn
,
formatFn
,
paramsFn
])
const
updateData
=
useCallback
((
data
:
T
)
=>
{
dispatch
({
type
:
ActionType
.
Load
,
payload
:
{
detail
:
data
},
})
},
[])
return
[
dataSource
,
loadData
,
updateData
]
}
src/pages/game/complete/components/complete-head.module.scss
View file @
7948aaf1
...
@@ -16,6 +16,52 @@
...
@@ -16,6 +16,52 @@
}
}
}
}
.top_level
{
position
:
relative
;
}
.star_1
{
position
:
absolute
;
left
:
230px
;
top
:
60px
;
z-index
:
30
;
width
:
84px
;
height
:
84px
;
animation
:
zoomIn
.5s
ease-in-out
0s
backwards
;
}
.star_2
{
position
:
absolute
;
left
:
334px
;
top
:
40px
;
z-index
:
30
;
width
:
84px
;
height
:
84px
;
animation
:
zoomIn
.5s
ease-in-out
0
.3s
backwards
;
}
.star_3
{
position
:
absolute
;
right
:
228px
;
top
:
60px
;
z-index
:
30
;
width
:
84px
;
height
:
84px
;
animation
:
zoomIn
.5s
ease-in-out
0
.6s
backwards
;
}
@keyframes
zoomIn
{
0
%
{
transform
:
scale3d
(
2
,
2
,
1
);
opacity
:
0
;
}
100
%
{
transform
:
scale3d
(
1
,
1
,
1
);
opacity
:
1
;
}
}
.bg
{
.bg
{
width
:
600px
;
width
:
600px
;
display
:
block
;
display
:
block
;
...
...
src/pages/game/complete/components/complete-head.tsx
View file @
7948aaf1
...
@@ -8,6 +8,7 @@ import { StageLevel } from '@/api'
...
@@ -8,6 +8,7 @@ import { StageLevel } from '@/api'
import
{
useStoreState
,
useStoreActions
}
from
'@/store/hooks'
import
{
useStoreState
,
useStoreActions
}
from
'@/store/hooks'
import
{
palyAudio
}
from
'@/utils/play-audio'
import
{
palyAudio
}
from
'@/utils/play-audio'
import
audio
from
'@/assets/oss/assets-audio'
import
audio
from
'@/assets/oss/assets-audio'
import
assetsGame
from
'@/assets/oss/assets-game'
import
tutorialAssets
from
'@/assets/oss/assets-tutorial'
import
tutorialAssets
from
'@/assets/oss/assets-tutorial'
import
{
UserGuideView
}
from
'@/components'
import
{
UserGuideView
}
from
'@/components'
...
@@ -29,21 +30,28 @@ const getLevelBigBg = (s?: StageLevel | null): string => {
...
@@ -29,21 +30,28 @@ const getLevelBigBg = (s?: StageLevel | null): string => {
return
assets
[
'level-big-fail.png'
].
u
return
assets
[
'level-big-fail.png'
].
u
}
}
// const getWeight = (s?: StageLevel | null) => {
const
getStarNum
=
(
s
?:
StageLevel
|
null
):
number
=>
{
// switch (s) {
switch
(
s
)
{
// case StageLevel.S: {
case
StageLevel
.
S
:
{
// return 100
return
3
// }
}
// case StageLevel.A: {
case
StageLevel
.
A
:
{
// return 50
return
2
// }
}
// case StageLevel.B: {
case
StageLevel
.
B
:
{
// return 25
return
1
// }
}
// }
}
// return 0
return
0
// }
}
const
getStarImg
=
(
s1
:
number
,
s2
:
number
):
string
=>
{
if
(
s2
>=
s1
)
{
return
assetsGame
[
'star-on.png'
].
u
}
return
assetsGame
[
'star-off.png'
].
u
}
const
getAudioSrc
=
(
s
?:
StageLevel
|
null
)
=>
{
const
getAudioSrc
=
(
s
?:
StageLevel
|
null
)
=>
{
if
(
!
s
)
{
if
(
!
s
)
{
...
@@ -191,13 +199,20 @@ const GameCompleteHead = () => {
...
@@ -191,13 +199,20 @@ const GameCompleteHead = () => {
}
}
},
[
isErrQuestionGuideComplete
,
gameResult
])
},
[
isErrQuestionGuideComplete
,
gameResult
])
const
starNum
=
useMemo
(()
=>
getStarNum
(
gameResult
?.
level
),
[
gameResult
])
if
(
!
gameResult
)
{
if
(
!
gameResult
)
{
return
null
return
null
}
}
return
(
return
(
<
View
style=
{
style
}
className=
{
classNames
(
styles
.
head
,
linearGradient
)
}
>
<
View
style=
{
style
}
className=
{
classNames
(
styles
.
head
,
linearGradient
)
}
>
<
Image
src=
{
bg
}
className=
{
styles
.
bg
}
></
Image
>
<
View
className=
{
styles
.
top_level
}
>
<
Image
src=
{
bg
}
className=
{
styles
.
bg
}
></
Image
>
<
Image
src=
{
getStarImg
(
1
,
starNum
)
}
className=
{
styles
.
star_1
}
></
Image
>
<
Image
src=
{
getStarImg
(
2
,
starNum
)
}
className=
{
styles
.
star_2
}
></
Image
>
<
Image
src=
{
getStarImg
(
3
,
starNum
)
}
className=
{
styles
.
star_3
}
></
Image
>
</
View
>
<
View
style=
{
{
color
:
text
.
color
}
}
className=
{
styles
.
tips
}
>
{
text
.
text
}
</
View
>
<
View
style=
{
{
color
:
text
.
color
}
}
className=
{
styles
.
tips
}
>
{
text
.
text
}
</
View
>
<
View
className=
{
styles
.
item_wrap
}
>
<
View
className=
{
styles
.
item_wrap
}
>
<
View
className=
{
styles
.
item
}
>
<
View
className=
{
styles
.
item
}
>
...
...
src/pages/game/play/components/count-up.tsx
View file @
7948aaf1
...
@@ -23,6 +23,8 @@ const CountUp = (props: CountUpProps) => {
...
@@ -23,6 +23,8 @@ const CountUp = (props: CountUpProps) => {
const
questionList
=
useStoreState
(
state
=>
state
.
gameModel
.
questionList
)
const
questionList
=
useStoreState
(
state
=>
state
.
gameModel
.
questionList
)
const
isSubmit
=
useStoreState
(
state
=>
state
.
gameModel
.
isSubmit
)
const
isSubmit
=
useStoreState
(
state
=>
state
.
gameModel
.
isSubmit
)
const
submit
=
useStoreActions
(
actions
=>
actions
.
gameModel
.
submit
)
const
submit
=
useStoreActions
(
actions
=>
actions
.
gameModel
.
submit
)
const
pkDetail
=
useStoreState
(
state
=>
state
.
gameModel
.
pkDetail
)
const
[
isExceed
,
exceedActions
]
=
useBoolean
(
false
)
const
[
isExceed
,
exceedActions
]
=
useBoolean
(
false
)
const
[
isStarted
,
startActions
]
=
useBoolean
(
false
)
const
[
isStarted
,
startActions
]
=
useBoolean
(
false
)
...
@@ -48,17 +50,25 @@ const CountUp = (props: CountUpProps) => {
...
@@ -48,17 +50,25 @@ const CountUp = (props: CountUpProps) => {
})
})
const
roleStyle
=
useMemo
(()
=>
{
const
roleStyle
=
useMemo
(()
=>
{
const
getTime
=
()
=>
{
if
(
isBattle
)
{
return
pkDetail
?.
resultTime
??
stageDetail
.
bTime
}
return
stageDetail
.
bTime
}
if
(
isStarted
)
{
if
(
isStarted
)
{
return
{
return
{
transform
:
'translateX(100%)'
,
transform
:
'translateX(100%)'
,
transition
:
`transform
${
stageDetail
.
bTime
}
s linear`
,
transition
:
`transform
${
getTime
()
}
s linear`
,
}
}
}
}
return
{
return
{
transform
:
'translateX(0)'
,
transform
:
'translateX(0)'
,
transition
:
`transform
${
stageDetail
.
bTime
}
s linear`
,
transition
:
`transform
${
getTime
()
}
s linear`
,
}
}
},
[
stageDetail
,
isStarted
])
},
[
stageDetail
,
isStarted
,
isBattle
,
pkDetail
])
const
processInnerStyle
=
useMemo
(()
=>
{
const
processInnerStyle
=
useMemo
(()
=>
{
if
(
isSubmit
)
{
if
(
isSubmit
)
{
...
...
src/pages/game/play/model/index.ts
View file @
7948aaf1
import
{
action
,
Action
,
computed
,
Computed
,
Thunk
,
thunk
}
from
'easy-peasy'
import
{
action
,
computed
,
thunk
}
from
'easy-peasy'
import
{
AppStoreModel
}
from
'@/store/store-model'
import
{
import
{
getQuestionList
,
StageLevel
,
type
StageDetail
,
getStageDetail
,
completeStage
,
StageType
,
type
CompleteStageOut
,
resumeGame
}
from
'@/api'
getQuestionList
,
StageLevel
,
import
{
showLoading
,
hideLoading
,
showModal
,
redirectTo
,
vibrateShort
,
getCurrentInstance
,
disableAlertBeforeUnload
}
from
'@tarojs/taro'
getStageDetail
,
completeStage
,
StageType
,
resumeGame
,
getPkDetail
}
from
'@/api'
import
{
showLoading
,
hideLoading
,
showModal
,
redirectTo
,
vibrateShort
,
getCurrentInstance
,
disableAlertBeforeUnload
}
from
'@tarojs/taro'
import
assets
from
'@/assets/oss/assets-complete'
import
assets
from
'@/assets/oss/assets-complete'
import
{
palyAudio
}
from
'@/utils/play-audio'
import
{
palyAudio
}
from
'@/utils/play-audio'
import
audio
from
'@/assets/oss/assets-audio'
import
audio
from
'@/assets/oss/assets-audio'
import
{
import
{
QuestionType
,
QuestionAnswer
,
isSelectionQuestion
,
isSelectionQuestion
,
// QuestionOption,
// QuestionOption,
}
from
'../types'
}
from
'../types'
import
{
buildCompleteStageParam
,
convertQuestion
,
determinQuestion
}
from
'./utils'
import
{
buildCompleteStageParam
,
convertQuestion
,
determinQuestion
}
from
'./utils'
interface
CompleteStageDetail
extends
CompleteStageOut
{
import
{
GameModel
}
from
'./types'
errNum
:
number
;
levelTime
:
number
;
isTimeout
:
boolean
;
}
const
COUNTER_ID
=
'z__countdown__'
const
COUNTER_ID
=
'z__countdown__'
...
@@ -34,62 +34,8 @@ const getCounter = () => {
...
@@ -34,62 +34,8 @@ const getCounter = () => {
const
stopCounter
=
()
=>
getCounter
()?.
stop
()
const
stopCounter
=
()
=>
getCounter
()?.
stop
()
const
startCounter
=
()
=>
getCounter
()?.
start
()
const
startCounter
=
()
=>
getCounter
()?.
start
()
interface
GameModelState
{
/** 题目列表 */
questionList
:
QuestionType
[];
/** 错题列表 */
errList
:
QuestionType
[];
stageDetailPre
:
StageDetail
|
null
;
stageDetail
:
StageDetail
|
null
;
gameResult
:
CompleteStageDetail
|
null
;
gameStartTime
:
number
;
/** 当前题目下标 */
currentQuestionIndex
:
number
;
/** 当前输入框下标 */
currentInputIndex
:
number
;
isSubmit
:
boolean
;
modalContinueVisible
:
boolean
;
/** 是否复活过 */
bornTimes
:
number
;
/** 计时器id */
counterId
:
string
;
rightIcon
:
string
|
null
;
}
export
interface
GameModel
extends
GameModelState
{
updateState
:
Action
<
GameModel
,
Partial
<
GameModelState
>>
;
/** 当前题目 */
currentQuestion
:
Computed
<
GameModel
,
QuestionType
|
undefined
>
;
/** 题目答案和用户答案 */
questionAnswers
:
Computed
<
GameModel
,
QuestionAnswer
[]
|
undefined
>
;
/** 更新当前题目下标 */
updateCurrentIndex
:
Action
<
GameModel
,
number
>
;
/** 更新当前输入框下标 */
updateCurrentInputIndex
:
Action
<
GameModel
,
number
>
;
/** 更新用户输入 */
updateUserAnswer
:
Action
<
GameModel
,
{
detail
:
string
}
>
;
/** 清空所有输入 */
clearUserAnswer
:
Action
<
GameModel
,
void
>
;
updateSelectionAnswer
:
Action
<
GameModel
,
number
>
;
/** 可以跳转下一题 */
canGoNext
:
Computed
<
GameModel
,
boolean
>
;
updateList
:
Action
<
GameModel
,
QuestionType
[]
>
;
getQuestionList
:
Thunk
<
GameModel
,
number
,
void
,
AppStoreModel
>
;
getStageDetail
:
Thunk
<
GameModel
,
number
,
void
,
AppStoreModel
>
;
handleGoNext
:
Thunk
<
GameModel
,
void
,
void
,
AppStoreModel
>
;
submit
:
Thunk
<
GameModel
,
void
,
void
,
AppStoreModel
>
;
reborn
:
Thunk
<
GameModel
,
void
,
void
,
AppStoreModel
>
;
}
const
gameModel
:
GameModel
=
{
const
gameModel
:
GameModel
=
{
pkDetail
:
null
,
counterId
:
COUNTER_ID
,
counterId
:
COUNTER_ID
,
questionList
:
[],
questionList
:
[],
errList
:
[],
errList
:
[],
...
@@ -112,6 +58,14 @@ const gameModel: GameModel = {
...
@@ -112,6 +58,14 @@ const gameModel: GameModel = {
/** 是否升档奖励 */
/** 是否升档奖励 */
upGear
:
true
upGear
:
true
},
},
getPkDetail
:
thunk
(
async
(
actions
,
payload
)
=>
{
try
{
const
{
data
}
=
await
getPkDetail
(
payload
)
actions
.
updateState
({
pkDetail
:
data
})
}
catch
(
err
)
{}
}),
bornTimes
:
3
,
bornTimes
:
3
,
modalContinueVisible
:
false
,
modalContinueVisible
:
false
,
gameStartTime
:
0
,
gameStartTime
:
0
,
...
...
src/pages/game/play/model/types.ts
0 → 100644
View file @
7948aaf1
import
{
Action
,
Computed
,
Thunk
}
from
'easy-peasy'
import
{
AppStoreModel
}
from
'@/store/store-model'
import
{
type
StageDetail
,
type
CompleteStageOut
,
PkDetail
}
from
'@/api'
import
{
QuestionType
,
QuestionAnswer
,
// QuestionOption,
}
from
'../types'
export
interface
CompleteStageDetail
extends
CompleteStageOut
{
errNum
:
number
;
levelTime
:
number
;
isTimeout
:
boolean
;
}
export
interface
GameModelState
{
/** 题目列表 */
questionList
:
QuestionType
[];
/** 错题列表 */
errList
:
QuestionType
[];
stageDetailPre
:
StageDetail
|
null
;
stageDetail
:
StageDetail
|
null
;
gameResult
:
CompleteStageDetail
|
null
;
gameStartTime
:
number
;
/** 当前题目下标 */
currentQuestionIndex
:
number
;
/** 当前输入框下标 */
currentInputIndex
:
number
;
isSubmit
:
boolean
;
modalContinueVisible
:
boolean
;
/** 是否复活过 */
bornTimes
:
number
;
/** 计时器id */
counterId
:
string
;
rightIcon
:
string
|
null
;
pkDetail
:
PkDetail
|
null
;
}
export
interface
GameModel
extends
GameModelState
{
updateState
:
Action
<
GameModel
,
Partial
<
GameModelState
>>
;
/** 当前题目 */
currentQuestion
:
Computed
<
GameModel
,
QuestionType
|
undefined
>
;
/** 题目答案和用户答案 */
questionAnswers
:
Computed
<
GameModel
,
QuestionAnswer
[]
|
undefined
>
;
/** 更新当前题目下标 */
updateCurrentIndex
:
Action
<
GameModel
,
number
>
;
/** 更新当前输入框下标 */
updateCurrentInputIndex
:
Action
<
GameModel
,
number
>
;
/** 更新用户输入 */
updateUserAnswer
:
Action
<
GameModel
,
{
detail
:
string
}
>
;
/** 清空所有输入 */
clearUserAnswer
:
Action
<
GameModel
,
void
>
;
updateSelectionAnswer
:
Action
<
GameModel
,
number
>
;
/** 可以跳转下一题 */
canGoNext
:
Computed
<
GameModel
,
boolean
>
;
updateList
:
Action
<
GameModel
,
QuestionType
[]
>
;
getQuestionList
:
Thunk
<
GameModel
,
number
,
void
,
AppStoreModel
>
;
getStageDetail
:
Thunk
<
GameModel
,
number
,
void
,
AppStoreModel
>
;
handleGoNext
:
Thunk
<
GameModel
,
void
,
void
,
AppStoreModel
>
;
submit
:
Thunk
<
GameModel
,
void
,
void
,
AppStoreModel
>
;
reborn
:
Thunk
<
GameModel
,
void
,
void
,
AppStoreModel
>
;
getPkDetail
:
Thunk
<
GameModel
,
{
userId
:
number
;
stageId
:
number
},
void
,
AppStoreModel
>
;
}
src/pages/main/main-underground/chapter.tsx
View file @
7948aaf1
import
{
View
,
Text
,
Image
}
from
'@tarojs/components'
import
{
View
,
Image
}
from
'@tarojs/components'
import
assetsMainNext
from
'@/assets/oss/assets-main-next'
import
assetsMainNext
from
'@/assets/oss/assets-main-next'
import
{
getMenuButtonBoundingClientRect
,
getSystemInfoSync
}
from
'@tarojs/taro'
import
{
getMenuButtonBoundingClientRect
,
getSystemInfoSync
}
from
'@tarojs/taro'
import
{
useMemo
}
from
'react'
import
{
useMemo
}
from
'react'
...
...
src/pages/main/main-underground/create-pk.tsx
View file @
7948aaf1
import
{
View
,
Image
,
Button
}
from
'@tarojs/components'
import
{
View
,
Image
,
Button
}
from
'@tarojs/components'
import
assetsPk
from
'@/assets/oss/assets-pk'
import
assetsPk
from
'@/assets/oss/assets-pk'
import
{
useMemo
}
from
'react'
import
{
useMemo
,
useCallback
,
useEffect
}
from
'react'
import
{
getMenuButtonBoundingClientRect
}
from
'@tarojs/taro'
import
{
getMenuButtonBoundingClientRect
}
from
'@tarojs/taro'
import
classNames
from
'classnames'
import
classNames
from
'classnames'
import
assetsMainNext
from
'@/assets/oss/assets-main-next'
import
assetsMainNext
from
'@/assets/oss/assets-main-next'
import
{
cs
}
from
'@/styles'
import
{
cs
}
from
'@/styles'
import
{
useStoreActions
,
useStoreState
}
from
'@/store/hooks'
import
{
useStoreActions
,
useStoreState
}
from
'@/store/hooks'
import
{
useFetch
}
from
'@/hooks'
import
{
getPkDetail
}
from
'@/api'
import
styles
from
'./create-pk.module.scss'
import
styles
from
'./create-pk.module.scss'
type
CreatePkProps
=
{
type
CreatePkProps
=
{
...
@@ -23,6 +25,22 @@ const CreatePk = (props: CreatePkProps) => {
...
@@ -23,6 +25,22 @@ const CreatePk = (props: CreatePkProps) => {
updateState
({
isCreatePkShow
:
false
,
currentPkStage
:
null
})
updateState
({
isCreatePkShow
:
false
,
currentPkStage
:
null
})
}
}
const
[
dataSource
,
loadData
]
=
useFetch
(
getPkDetail
,
useCallback
(()
=>
{
if
(
!
currentPkStage
)
return
null
return
{
userId
:
userInfo
.
userId
,
stageId
:
currentPkStage
.
id
}
},
[
currentPkStage
,
userInfo
]))
useEffect
(()
=>
{
if
(
currentPkStage
&&
userInfo
?.
userId
)
{
loadData
()
}
},
[
currentPkStage
,
userInfo
,
loadData
])
const
detail
=
dataSource
.
detail
const
closeStyle
=
useMemo
(()
=>
{
const
closeStyle
=
useMemo
(()
=>
{
return
{
return
{
paddingTop
:
`
${
nav
.
top
+
5
}
px`
paddingTop
:
`
${
nav
.
top
+
5
}
px`
...
@@ -54,7 +72,7 @@ const CreatePk = (props: CreatePkProps) => {
...
@@ -54,7 +72,7 @@ const CreatePk = (props: CreatePkProps) => {
<
View
>
{
userInfo
.
nickName
}
</
View
>
<
View
>
{
userInfo
.
nickName
}
</
View
>
<
View
className=
{
styles
.
info_detail
}
><
Image
src=
{
assetsPk
[
'bronze-small.png'
].
u
}
className=
{
styles
.
pk_level
}
/>
青铜Ⅰ
</
View
>
<
View
className=
{
styles
.
info_detail
}
><
Image
src=
{
assetsPk
[
'bronze-small.png'
].
u
}
className=
{
styles
.
pk_level
}
/>
青铜Ⅰ
</
View
>
<
View
className=
{
styles
.
info_detail
}
>
本关战绩:胜
{
currentPkStage
?.
pkWinNum
??
0
}
负
{
currentPkStage
?.
pkLoseNum
??
0
}
</
View
>
<
View
className=
{
styles
.
info_detail
}
>
本关战绩:胜
{
currentPkStage
?.
pkWinNum
??
0
}
负
{
currentPkStage
?.
pkLoseNum
??
0
}
</
View
>
<
View
className=
{
styles
.
info_detail
}
>
最佳表现:全对丨
29.3
s
</
View
>
<
View
className=
{
styles
.
info_detail
}
>
最佳表现:全对丨
{
detail
?.
resultTime
??
'-'
}
s
</
View
>
</
View
>
</
View
>
</
View
>
</
View
>
</
View
>
</
View
>
...
...
src/pages/prepare/index.tsx
View file @
7948aaf1
...
@@ -131,7 +131,7 @@ const Prepare = () => {
...
@@ -131,7 +131,7 @@ const Prepare = () => {
getQuestionList(+router.params.id || 1).then(() => {
getQuestionList(+router.params.id || 1).then(() => {
isClickRef.current = false
isClickRef.current = false
navigateTo({
navigateTo({
url: `
/
pages
/
game
/
play
/
index
?
id
=
$
{
router
.
params
.
id
}
&
isBattle
=
true
`
url: `
/
pages
/
game
/
play
/
index
?
id
=
$
{
router
.
params
.
id
}
&
isBattle
=
true
&
initiatorTime
=
30
`
})
})
})
})
}
}
...
...
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