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
7bd6a206
Commit
7bd6a206
authored
Apr 03, 2023
by
m
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://118.24.71.244/hewenhao/GeekLearnMathWeapp
parents
b96270ee
e68d6cde
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
212 additions
and
89 deletions
+212
-89
game.ts
src/api/game.ts
+13
-17
complete-achieve.module.scss
...ges/game/complete/components/complete-achieve.module.scss
+23
-0
complete-achieve.tsx
src/pages/game/complete/components/complete-achieve.tsx
+71
-19
complete-head.module.scss
src/pages/game/complete/components/complete-head.module.scss
+5
-0
complete-head.tsx
src/pages/game/complete/components/complete-head.tsx
+16
-6
question-vertical-division.module.scss
...omponents/question/question-vertical-division.module.scss
+2
-2
index.tsx
src/pages/game/play/index.tsx
+6
-11
index.ts
src/pages/game/play/model/index.ts
+49
-28
utils.ts
src/pages/game/play/model/utils.ts
+6
-1
launch-quest.tsx
src/pages/prepare/components/overview/launch-quest.tsx
+18
-2
index.tsx
src/pages/prepare/index.tsx
+3
-3
No files found.
src/api/game.ts
View file @
7bd6a206
...
...
@@ -86,7 +86,8 @@ export interface CompleteQuestion extends QuestionItem {
export
interface
CompleteStageParam
{
correctNum
:
number
;
level
:
StageLevel
;
level
:
StageLevel
|
null
;
levelTime
:
number
;
num
:
number
;
questions
:
CompleteQuestion
[];
resultTime
:
number
;
...
...
@@ -98,30 +99,25 @@ interface CompleteStageParamIn extends CompleteStageParam {
}
export
interface
CompleteStageOut
{
/** 单题耗时 */
averageTime
:
number
;
/** 排名档位 */
gear
:
number
;
/** 排名积分 */
gearReward
:
number
;
/** 成就等级:SAB */
level
:
StageLevel
;
/** 下一档位 */
nextGear
:
number
;
/** 下一档位时间 */
nextGearTime
:
number
;
/** 积分后 */
pointAfter
:
number
;
/** 积分前 */
pointBefore
:
number
;
level
:
StageLevel
|
null
;
/** 之前成就 */
levelBefore
:
StageLevel
|
null
;
/** 成就奖励 */
levelReward
:
number
;
/** 排名 */
ranks
:
StageRank
[];
/** 正确率 */
rate
:
number
;
ranks
:
StageRank
[]
|
null
;
/** 耗时 */
resultTime
:
number
;
/** S时间 */
sLevelTime
:
number
;
/** 是否升档奖励 */
upGear
:
boolean
;
/** 升档奖励 */
upGearReward
:
number
;
}
/** 完成 */
...
...
src/pages/game/complete/components/complete-achieve.module.scss
View file @
7bd6a206
...
...
@@ -24,6 +24,29 @@
font-weight
:
600
;
color
:
#465164
;
line-height
:
44px
;
display
:
flex
;
align-items
:
center
;
}
.first_time
{
height
:
38px
;
background
:
#FDB74B
;
border-radius
:
19px
;
border
:
2px
solid
#FF9E07
;
margin-left
:
16px
;
display
:
flex
;
align-items
:
center
;
justify-content
:
center
;
padding
:
0
12px
;
font-size
:
24px
;
font-weight
:
500
;
color
:
#FFFFFF
;
line-height
:
34px
;
box-sizing
:
border-box
;
&
.is_second
{
background
:
rgba
(
$color
:
#465164
,
$alpha
:
0
.3
);
border-color
:
transparent
;
}
}
.tips_text
{
...
...
src/pages/game/complete/components/complete-achieve.tsx
View file @
7bd6a206
import
{
View
,
Image
}
from
'@tarojs/components'
import
{
View
,
Image
,
Text
}
from
'@tarojs/components'
import
assets
from
'@/assets/oss/assets-complete'
import
{
useMemo
}
from
'react'
import
classNames
from
'classnames'
import
{
useStoreState
}
from
'@/store/hooks'
import
{
StageLevel
}
from
'@/api'
import
{
useFormatTick
}
from
'@/hooks/use-format-tick'
import
{
cs
}
from
'@/styles'
import
styles
from
'./complete-achieve.module.scss'
const
getLevelBg
=
(
s
?:
StageLevel
):
string
=>
{
const
getLevelBg
=
(
s
?:
StageLevel
|
null
):
string
=>
{
switch
(
s
)
{
case
StageLevel
.
S
:
{
return
assets
[
'level-small-s.png'
].
u
...
...
@@ -49,6 +51,47 @@ const GameCompleteAchieve = () => {
return
getTopIcon
(
gameResult
?.
gear
??
0
)
},
[
gameResult
])
const
time
=
useFormatTick
((
gameResult
?.
levelTime
??
0
)
*
1000
)
const
rankNo
=
useMemo
(()
=>
{
return
gameResult
?.
ranks
?.
find
(
c
=>
c
.
me
)?.
no
??
'NaN'
},
[
gameResult
])
const
rankNoS
=
useMemo
(()
=>
{
if
(
rankNo
===
'NaN'
)
return
'NaN'
if
(
rankNo
<=
10
)
{
return
10
}
if
(
rankNo
<=
100
)
{
return
100
}
return
Math
.
ceil
(
rankNo
/
500
)
*
500
},
[
rankNo
])
const
renderBtn
=
()
=>
(
<
View
className=
{
styles
.
footer
}
>
<
View
className=
{
styles
.
btn_continue
}
hoverClass=
{
styles
.
is_active
}
>
继续
</
View
>
</
View
>
)
if
(
!
gameResult
)
{
return
null
}
if
(
gameResult
.
errNum
>
0
)
{
return
(
<>
<
View
>
没关系,差一点就成功了! 加油!加油!
</
View
>
{
renderBtn
()
}
</>
)
}
return
(
<>
<
View
className=
{
styles
.
wrap
}
>
...
...
@@ -56,25 +99,39 @@ const GameCompleteAchieve = () => {
<
View
className=
{
styles
.
achieve_item
}
>
<
Image
src=
{
level
}
className=
{
styles
.
achieve_icon
}
></
Image
>
<
View
className=
{
cs
.
flex__item
}
>
<
View
className=
{
styles
.
main_text
}
>
B等级
</
View
>
<
View
className=
{
styles
.
tips_text
}
>
全对且用时≤1分30秒
</
View
>
<
View
className=
{
styles
.
main_text
}
>
{
gameResult
.
level
}
等级
<
Text
className=
{
classNames
(
styles
.
first_time
,
gameResult
.
levelReward
<=
0
&&
styles
.
is_second
)
}
>
{
gameResult
.
levelReward
>
0
?
'首次达成'
:
'二次达成'
}
</
Text
>
</
View
>
<
View
className=
{
styles
.
tips_text
}
>
全对且用时≤
{
time
.
minutes
}
分
{
time
.
seconds
}
秒
</
View
>
</
View
>
{
gameResult
.
levelReward
>
0
&&
(
<
View
>
<
Image
src=
{
require
(
'../assets/bonus.png'
)
}
className=
{
styles
.
bonus_icon
}
></
Image
>
<
View
className=
{
styles
.
bonus_text
}
>
+30
</
View
>
<
View
className=
{
styles
.
bonus_text
}
>
+
{
gameResult
.
levelReward
}
</
View
>
</
View
>
)
}
</
View
>
{
topIcon
&&
(
<
View
className=
{
styles
.
achieve_item
}
>
<
Image
src=
{
topIcon
}
className=
{
styles
.
achieve_icon
}
></
Image
>
<
View
className=
{
cs
.
flex__item
}
>
<
View
className=
{
styles
.
main_text
}
>
TOP
{
gameResult
?.
gear
??
0
}
%
</
View
>
<
View
className=
{
styles
.
main_text
}
>
TOP
{
gameResult
?.
gear
??
0
}
%
<
Text
className=
{
classNames
(
styles
.
first_time
,
gameResult
.
gearReward
<=
0
&&
styles
.
is_second
)
}
>
{
gameResult
.
gearReward
>
0
?
'首次达成'
:
'二次达成'
}
</
Text
>
</
View
>
<
View
className=
{
styles
.
tips_text
}
>
恭喜你成为了最优秀的
{
gameResult
?.
gear
??
0
}
%
</
View
>
</
View
>
{
gameResult
.
gearReward
>
0
&&
(
<
View
>
<
Image
src=
{
require
(
'../assets/bonus.png'
)
}
className=
{
styles
.
bonus_icon
}
></
Image
>
<
View
className=
{
styles
.
bonus_text
}
>
+20
</
View
>
<
View
className=
{
styles
.
bonus_text
}
>
+
{
gameResult
.
gearReward
}
</
View
>
</
View
>
)
}
</
View
>
)
}
...
...
@@ -82,33 +139,28 @@ const GameCompleteAchieve = () => {
<
Image
src=
{
assets
[
'rank.png'
].
u
}
className=
{
styles
.
achieve_icon
}
></
Image
>
<
View
className=
{
cs
.
flex__item
}
>
<
View
className=
{
styles
.
main_text
}
>
全市排名
</
View
>
<
View
className=
{
styles
.
tips_text
}
>
恭喜你进入了全市前
100
名
</
View
>
<
View
className=
{
styles
.
tips_text
}
>
恭喜你进入了全市前
{
rankNoS
}
名
</
View
>
</
View
>
<
View
className=
{
styles
.
rank_text
}
>
89
名
</
View
>
<
View
className=
{
styles
.
rank_text
}
>
{
rankNo
}
名
</
View
>
</
View
>
{
gameResult
?.
upGear
&&
(
<
View
className=
{
styles
.
achieve_item
}
>
<
Image
src=
{
assets
[
'upgear.png'
].
u
}
className=
{
styles
.
achieve_icon
}
></
Image
>
<
View
className=
{
cs
.
flex__item
}
>
<
View
className=
{
styles
.
main_text
}
>
升档成功
</
View
>
<
View
className=
{
styles
.
tips_text
}
>
提升到
50%-60
%
</
View
>
<
View
className=
{
styles
.
tips_text
}
>
提升到
{
gameResult
.
gear
-
10
}
%-
{
gameResult
.
gear
}
%
</
View
>
</
View
>
{
gameResult
.
upGearReward
>
0
&&
(
<
View
>
<
Image
src=
{
require
(
'../assets/bonus.png'
)
}
className=
{
styles
.
bonus_icon
}
></
Image
>
<
View
className=
{
styles
.
bonus_text
}
>
+10
</
View
>
<
View
className=
{
styles
.
bonus_text
}
>
+
{
gameResult
.
upGearReward
}
</
View
>
</
View
>
)
}
</
View
>
)
}
<
View
className=
{
styles
.
gap
}
></
View
>
</
View
>
<
View
className=
{
styles
.
footer
}
>
<
View
className=
{
styles
.
btn_continue
}
hoverClass=
{
styles
.
is_active
}
>
继续
</
View
>
</
View
>
{
renderBtn
()
}
</>
)
}
...
...
src/pages/game/complete/components/complete-head.module.scss
View file @
7bd6a206
...
...
@@ -40,6 +40,7 @@
width
:
60px
;
height
:
60px
;
margin-right
:
6px
;
display
:
block
;
}
.item_text
{
...
...
@@ -50,3 +51,7 @@
text-align
:
center
;
line-height
:
40px
;
}
.err
{
color
:
#FF7770
;
}
src/pages/game/complete/components/complete-head.tsx
View file @
7bd6a206
import
{
View
,
Image
,
Text
}
from
'@tarojs/components'
import
{
View
,
Image
}
from
'@tarojs/components'
import
{
useMemo
}
from
'react'
import
{
getMenuButtonBoundingClientRect
}
from
'@tarojs/taro'
import
classNames
from
'classnames'
import
assets
from
'@/assets/oss/assets-complete'
import
{
useFormatTick
}
from
'@/hooks/use-format-tick'
import
{
StageLevel
}
from
'@/api'
...
...
@@ -8,7 +9,7 @@ import { useStoreState } from '@/store/hooks'
import
styles
from
'./complete-head.module.scss'
const
getLevelBigBg
=
(
s
?:
StageLevel
):
string
=>
{
const
getLevelBigBg
=
(
s
?:
StageLevel
|
null
):
string
=>
{
switch
(
s
)
{
case
StageLevel
.
S
:
{
return
assets
[
'level-big-s.png'
].
u
...
...
@@ -24,7 +25,7 @@ const getLevelBigBg = (s?: StageLevel): string => {
return
assets
[
'level-big-fail.png'
].
u
}
const
getLevelText
=
(
s
?:
StageLevel
)
=>
{
const
getLevelText
=
(
s
?:
StageLevel
|
null
)
=>
{
switch
(
s
)
{
case
StageLevel
.
S
:
{
return
{
...
...
@@ -62,6 +63,11 @@ const GameCompleteHead = () => {
const
time
=
useFormatTick
((
gameResult
?.
resultTime
??
0
)
*
1000
)
const
bonus
=
useMemo
(()
=>
{
if
(
!
gameResult
)
return
0
return
gameResult
?.
gearReward
+
gameResult
?.
levelReward
+
gameResult
?.
upGearReward
},
[
gameResult
])
const
bg
=
useMemo
(()
=>
{
return
getLevelBigBg
(
gameResult
?.
level
)
},
[
gameResult
])
...
...
@@ -76,6 +82,10 @@ const GameCompleteHead = () => {
}
},
[
nav
])
if
(
!
gameResult
)
{
return
null
}
return
(
<
View
style=
{
style
}
className=
{
styles
.
head
}
>
<
Image
src=
{
bg
}
className=
{
styles
.
bg
}
></
Image
>
...
...
@@ -83,15 +93,15 @@ const GameCompleteHead = () => {
<
View
className=
{
styles
.
item_wrap
}
>
<
View
className=
{
styles
.
item
}
>
<
Image
src=
{
require
(
'../assets/bonus.png'
)
}
className=
{
styles
.
icon
}
></
Image
>
<
View
className=
{
styles
.
item_text
}
>
+
30
</
View
>
<
View
className=
{
styles
.
item_text
}
>
+
{
bonus
}
</
View
>
</
View
>
<
View
className=
{
styles
.
item
}
>
<
Image
src=
{
require
(
'../assets/right-count.png'
)
}
className=
{
styles
.
icon
}
></
Image
>
<
View
className=
{
styles
.
item_text
}
>
全对
</
View
>
<
View
className=
{
classNames
(
styles
.
item_text
,
gameResult
.
errNum
>
0
&&
styles
.
err
)
}
>
{
gameResult
.
errNum
===
0
?
'全对'
:
`错${gameResult.errNum}题`
}
</
View
>
</
View
>
<
View
className=
{
styles
.
item
}
>
<
Image
src=
{
require
(
'../assets/time.png'
)
}
className=
{
styles
.
icon
}
></
Image
>
<
View
className=
{
styles
.
item_text
}
>
{
time
.
minutes
}
:
{
time
.
seconds
}
</
View
>
<
View
className=
{
classNames
(
styles
.
item_text
,
gameResult
.
errNum
<=
0
&&
!
gameResult
.
level
&&
styles
.
err
)
}
>
{
time
.
minutes
}
:
{
time
.
seconds
}
</
View
>
</
View
>
</
View
>
</
View
>
...
...
src/pages/game/play/components/question/question-vertical-division.module.scss
View file @
7bd6a206
...
...
@@ -61,9 +61,9 @@
.bottom
{
width
:
324px
;
display
:
flex
;
justify-content
:
flex-end
;
justify-content
:
space-between
;
margin-left
:
132px
;
padding
:
0
30px
24px
4
0px
;
padding
:
0
30px
24px
3
0px
;
box-sizing
:
border-box
;
position
:
relative
;
&
:
:
after
{
...
...
src/pages/game/play/index.tsx
View file @
7bd6a206
import
{
View
,
ScrollView
}
from
'@tarojs/components'
import
{
useStoreState
,
useStoreActions
}
from
'@/store/hooks'
import
{
useEffect
}
from
'react'
import
{
useRouter
}
from
'@tarojs/taro'
import
{
useStoreState
}
from
'@/store/hooks'
//
import { useEffect } from 'react'
//
import { useRouter } from '@tarojs/taro'
import
{
useBoolean
}
from
'@/hooks/use-boolean'
import
ModalContinue
from
'./components/modal-continue'
...
...
@@ -15,17 +15,11 @@ import styles from './index.module.scss'
const
GamePlay
=
()
=>
{
const
currentQuestion
=
useStoreState
(
states
=>
states
.
gameModel
.
currentQuestion
)
const
getQuestionList
=
useStoreActions
(
actions
=>
actions
.
gameModel
.
getQuestionList
)
const
stageDetail
=
useStoreState
(
state
=>
state
.
gameModel
.
stageDetail
)
const
[
val
,
actions
]
=
useBoolean
(
false
)
const
router
=
useRouter
<
{
id
:
string
}
>
()
useEffect
(()
=>
{
getQuestionList
(
+
router
.
params
.
id
)
},
[
router
,
getQuestionList
])
return
(
<>
<
View
className=
{
styles
.
viewport
}
>
<
PageHead
/>
{
currentQuestion
&&
stageDetail
&&
(
...
...
@@ -46,8 +40,9 @@ const GamePlay = () => {
<
PageFooter
/>
</>
)
}
<
ModalContinue
closeOnClickModal
onClose=
{
actions
.
setFalse
}
/>
</
View
>
<
ModalContinue
closeOnClickModal
onClose=
{
actions
.
setFalse
}
/>
</>
)
}
...
...
src/pages/game/play/model/index.ts
View file @
7bd6a206
...
...
@@ -10,13 +10,18 @@ import {
}
from
'../types'
import
{
buildCompleteStageParam
,
convertQuestion
,
determinQuestion
}
from
'./utils'
// import questionListJson from './test.json'
import
questionListJson
from
'./test.json'
interface
CompleteStageDetail
extends
CompleteStageOut
{
errNum
:
number
;
levelTime
:
number
;
}
export
interface
GameModel
{
/** 题目列表 */
questionList
:
QuestionType
[];
stageDetail
:
StageDetail
|
null
;
gameResult
:
CompleteStage
Out
|
null
;
gameResult
:
CompleteStage
Detail
|
null
;
gameStartTime
:
number
;
updateState
:
Action
<
GameModel
,
Partial
<
State
<
GameModel
>>>
;
/** 当前题目 */
...
...
@@ -43,6 +48,7 @@ export interface GameModel {
updateList
:
Action
<
GameModel
,
QuestionType
[]
>
;
getQuestionList
:
Thunk
<
GameModel
,
number
,
void
,
AppStoreModel
>
;
getStageDetail
:
Thunk
<
GameModel
,
number
,
void
,
AppStoreModel
>
;
handleGoNext
:
Thunk
<
GameModel
,
void
,
void
,
AppStoreModel
>
;
isSubmit
:
boolean
;
...
...
@@ -53,30 +59,22 @@ export interface GameModel {
}
const
gameModel
:
GameModel
=
{
questionList
:
[],
questionList
:
questionListJson
as
QuestionType
[],
gameResult
:
{
/** 单题耗时 */
averageTime
:
4
,
/** 排名档位 */
gear
:
10
,
gearReward
:
10
,
levelBefore
:
StageLevel
.
B
,
levelReward
:
20
,
upGearReward
:
40
,
errNum
:
0
,
/** 成就等级:SAB */
level
:
StageLevel
.
S
,
/** 下一档位 */
nextGear
:
10
,
/** 下一档位时间 */
nextGearTime
:
3
,
/** 积分后 */
pointAfter
:
80
,
/** 积分前 */
pointBefore
:
76
,
levelTime
:
50
,
/** 排名 */
ranks
:
[],
/** 正确率 */
rate
:
80
,
/** 耗时 */
resultTime
:
60
,
/** S时间 */
sLevelTime
:
70
,
/** 是否升档奖励 */
upGear
:
true
},
...
...
@@ -129,7 +127,9 @@ const gameModel: GameModel = {
}),
updateUserAnswer
:
action
((
state
,
char
)
=>
{
if
(
process
.
env
.
NODE_ENV
===
'production'
)
{
vibrateShort
()
}
const
index
=
state
.
currentInputIndex
const
answers
=
state
.
questionList
[
state
.
currentQuestionIndex
]?.
answers
const
val
=
answers
?.[
index
]
...
...
@@ -189,30 +189,44 @@ const gameModel: GameModel = {
actions
.
updateCurrentIndex
(
currentQuestionIndex
+
1
)
}),
get
QuestionList
:
thunk
(
async
(
actions
,
round
)
=>
{
get
StageDetail
:
thunk
(
async
(
actions
,
round
)
=>
{
try
{
showLoading
()
const
[{
data
:
questionList
},
{
data
:
stageDetail
}]
=
await
Promise
.
all
([
getQuestionList
(
round
),
getStageDetail
(
round
)
])
const
{
data
:
stageDetail
}
=
await
getStageDetail
(
round
)
actions
.
updateState
({
stageDetail
})
hideLoading
()
}
catch
(
err
)
{
hideLoading
()
showModal
({
title
:
'提示'
,
content
:
err
.
message
||
'出错了'
,
showCancel
:
false
,
})
actions
.
updateState
({
stageDetail
:
null
})
}
}),
getQuestionList
:
thunk
(
async
(
actions
,
round
)
=>
{
try
{
// showLoading()
const
{
data
:
questionList
}
=
await
getQuestionList
(
round
)
actions
.
updateState
({
questionList
:
questionList
.
map
(
convertQuestion
),
stageDetail
,
gameStartTime
:
Date
.
now
(),
})
// hideLoading()
}
catch
(
err
)
{
// hideLoading()
showModal
({
title
:
'提示'
,
content
:
err
.
message
||
'出错了'
,
showCancel
:
false
,
})
actions
.
updateState
({
questionList
:
[],
stageDetail
:
null
})
}
finally
{
hideLoading
()
}
}),
...
...
@@ -224,8 +238,15 @@ const gameModel: GameModel = {
})
actions
.
updateState
({
isSubmit
:
true
})
const
{
questionList
,
gameStartTime
,
stageDetail
}
=
helpers
.
getState
()
const
{
data
:
gameResult
}
=
await
completeStage
(
buildCompleteStageParam
(
questionList
,
stageDetail
!
,
gameStartTime
))
actions
.
updateState
({
gameResult
})
const
params
=
buildCompleteStageParam
(
questionList
,
stageDetail
!
,
gameStartTime
)
const
{
data
:
gameResult
}
=
await
completeStage
(
params
)
actions
.
updateState
({
gameResult
:
{
...
gameResult
,
errNum
:
params
.
num
-
params
.
correctNum
,
levelTime
:
params
.
levelTime
}
})
redirectTo
({
url
:
'/pages/game/complete/index'
,
})
...
...
src/pages/game/play/model/utils.ts
View file @
7bd6a206
...
...
@@ -42,23 +42,28 @@ export function buildCompleteStageParam (questionList: QuestionType[], stageDeta
const
{
sTime
,
aTime
,
bTime
}
=
stageDetail
let
level
=
StageLevel
.
B
let
level
:
StageLevel
|
null
=
null
const
num
=
questionList
.
length
let
levelTime
:
number
=
0
if
(
correctNum
===
num
)
{
if
(
resultTime
<=
sTime
)
{
level
=
StageLevel
.
S
levelTime
=
sTime
}
else
if
(
resultTime
<=
aTime
)
{
level
=
StageLevel
.
A
levelTime
=
aTime
}
else
if
(
resultTime
<=
bTime
)
{
level
=
StageLevel
.
B
levelTime
=
bTime
}
}
return
{
correctNum
,
level
,
levelTime
,
stageId
:
stageDetail
.
id
,
questions
:
questionList
.
map
(
convert
),
num
,
...
...
src/pages/prepare/components/overview/launch-quest.tsx
View file @
7bd6a206
import
React
from
'react'
import
{
View
,
Text
,
Button
}
from
'@tarojs/components'
import
{
navigateTo
,
useRouter
}
from
'@tarojs/taro'
// import Taro from '@tarojs/taro'
import
Modal
from
'@/components/Modal'
import
{
useBoolean
}
from
'@/hooks'
import
{
useStoreState
,
useStoreActions
}
from
'@/store/hooks'
import
styles
from
'./index.module.scss'
const
LaunchQuest
:
React
.
FC
=
()
=>
{
const
[
isVisible
,
{
setTrue
,
setFalse
}]
=
useBoolean
(
false
)
const
[
loading
,
loadingAction
]
=
useBoolean
(
false
)
const
cardNum
=
useStoreState
(
state
=>
state
.
userModel
.
cardNum
)
const
getQuestionList
=
useStoreActions
(
actions
=>
actions
.
gameModel
.
getQuestionList
)
const
router
=
useRouter
<
{
id
:
string
}
>
()
const
navigateTo
=
()
=>
{
const
_navigateTo
=
()
=>
{
if
(
cardNum
<
1
)
{
setTrue
()
}
else
{
loadingAction
.
setTrue
()
getQuestionList
(
+
router
.
params
.
id
||
-
1
).
then
(()
=>
{
loadingAction
.
setFalse
()
navigateTo
({
url
:
`/pages/game/play/index?id=
${
router
.
params
.
id
}
`
})
})
}
// Taro.navigateTo('/')
}
return
(
<>
<
View
className=
{
styles
.
launchQuest
}
>
<
Button
onClick=
{
navigateTo
}
>
开始闯关
</
Button
>
<
Button
onClick=
{
_navigateTo
}
loading=
{
loading
}
>
开始闯关
</
Button
>
<
Text
className=
{
styles
.
tip
}
>
首次免答题卡
{
/* {hasFreePass ? '首次免答题卡' : '-1答题卡'} */
}
...
...
src/pages/prepare/index.tsx
View file @
7bd6a206
...
...
@@ -12,13 +12,13 @@ import styles from './index.module.scss'
const
Prepare
:
React
.
FC
=
()
=>
{
const
stageDetail
=
useStoreState
(
state
=>
state
.
gameModel
.
stageDetail
)
const
get
QuestionList
=
useStoreActions
(
actions
=>
actions
.
gameModel
.
getQuestionList
)
const
get
StageDetail
=
useStoreActions
(
actions
=>
actions
.
gameModel
.
getStageDetail
)
const
router
=
useRouter
<
{
id
:
string
}
>
()
useEffect
(()
=>
{
get
QuestionList
(
+
router
.
params
.
id
||
1
)
},
[
router
,
get
QuestionList
])
get
StageDetail
(
+
router
.
params
.
id
||
1
)
},
[
router
,
get
StageDetail
])
const
tabs
:
TabItem
[]
=
[
{
label
:
'成都排行榜'
,
children
:
<
ScrollRankList
users=
{
stageDetail
?.
ranks
!
}
/>
},
...
...
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