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
2a898e6d
Commit
2a898e6d
authored
Jun 15, 2023
by
hewenhao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: pk 答题
parent
af4c01c4
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
60 additions
and
16 deletions
+60
-16
.oss
assets/game/.oss
+6
-0
battle-icon.png
assets/game/battle-icon.png
+0
-0
assets-game.ts
src/assets/oss/assets-game.ts
+5
-0
count-up.module.scss
src/pages/game/play/components/count-up.module.scss
+10
-0
count-up.tsx
src/pages/game/play/components/count-up.tsx
+13
-6
page-head.tsx
src/pages/game/play/components/page-head.tsx
+9
-2
index.tsx
src/pages/game/play/index.tsx
+9
-3
create-pk.module.scss
src/pages/main/main-underground/create-pk.module.scss
+5
-5
create-pk.tsx
src/pages/main/main-underground/create-pk.tsx
+3
-0
No files found.
assets/game/.oss
View file @
2a898e6d
...
@@ -4,5 +4,11 @@
...
@@ -4,5 +4,11 @@
"w": 344,
"w": 344,
"h": 144,
"h": 144,
"ossName": "/pk-math/3Nps4sxqLzBwdY3oQiN6G1zXEwNy/344x144"
"ossName": "/pk-math/3Nps4sxqLzBwdY3oQiN6G1zXEwNy/344x144"
},
"battle-icon.png": {
"u": "https://cdn.jkwljy.com/pk-math/3rh5MFpZF96fZE91zu7G1dcjdnsX/80x80",
"w": 80,
"h": 80,
"ossName": "/pk-math/3rh5MFpZF96fZE91zu7G1dcjdnsX/80x80"
}
}
}
}
assets/game/battle-icon.png
0 → 100644
View file @
2a898e6d
7.35 KB
src/assets/oss/assets-game.ts
View file @
2a898e6d
...
@@ -5,5 +5,10 @@ export default {
...
@@ -5,5 +5,10 @@ export default {
"u"
:
"https://cdn.jkwljy.com/pk-math/3Nps4sxqLzBwdY3oQiN6G1zXEwNy/344x144"
,
"u"
:
"https://cdn.jkwljy.com/pk-math/3Nps4sxqLzBwdY3oQiN6G1zXEwNy/344x144"
,
"w"
:
344
,
"w"
:
344
,
"h"
:
144
"h"
:
144
},
"battle-icon.png"
:
{
"u"
:
"https://cdn.jkwljy.com/pk-math/3rh5MFpZF96fZE91zu7G1dcjdnsX/80x80"
,
"w"
:
80
,
"h"
:
80
}
}
}
as
const
}
as
const
src/pages/game/play/components/count-up.module.scss
View file @
2a898e6d
...
@@ -58,6 +58,16 @@
...
@@ -58,6 +58,16 @@
top
:
-8px
;
top
:
-8px
;
margin-left
:
-40px
;
margin-left
:
-40px
;
&
.is_battle
{
.tips
{
background-color
:
#FFB400
;
}
.tick
{
background-color
:
#FFB400
;
}
}
.tick
{
.tick
{
width
:
6px
;
width
:
6px
;
border-radius
:
3px
;
border-radius
:
3px
;
...
...
src/pages/game/play/components/count-up.tsx
View file @
2a898e6d
...
@@ -6,16 +6,18 @@ import { useBoolean } from '@/hooks'
...
@@ -6,16 +6,18 @@ import { useBoolean } from '@/hooks'
import
{
useStoreState
,
useStoreActions
}
from
'@/store/hooks'
import
{
useStoreState
,
useStoreActions
}
from
'@/store/hooks'
import
{
type
StageDetail
,
StageType
}
from
'@/api'
import
{
type
StageDetail
,
StageType
}
from
'@/api'
import
audio
from
'@/assets/oss/assets-audio'
import
audio
from
'@/assets/oss/assets-audio'
import
assetsGame
from
'@/assets/oss/assets-game'
import
{
palyAudio
}
from
'@/utils/play-audio'
import
{
palyAudio
}
from
'@/utils/play-audio'
import
styles
from
'./count-up.module.scss'
import
styles
from
'./count-up.module.scss'
type
CountUpProps
=
{
type
CountUpProps
=
{
stageDetail
:
StageDetail
stageDetail
:
StageDetail
;
isBattle
:
boolean
;
}
}
const
CountUp
=
(
props
:
CountUpProps
)
=>
{
const
CountUp
=
(
props
:
CountUpProps
)
=>
{
const
{
stageDetail
}
=
props
const
{
stageDetail
,
isBattle
}
=
props
const
currentQuestionIndex
=
useStoreState
(
states
=>
states
.
gameModel
.
currentQuestionIndex
)
const
currentQuestionIndex
=
useStoreState
(
states
=>
states
.
gameModel
.
currentQuestionIndex
)
const
counterId
=
useStoreState
(
states
=>
states
.
gameModel
.
counterId
)
const
counterId
=
useStoreState
(
states
=>
states
.
gameModel
.
counterId
)
const
questionList
=
useStoreState
(
state
=>
state
.
gameModel
.
questionList
)
const
questionList
=
useStoreState
(
state
=>
state
.
gameModel
.
questionList
)
...
@@ -70,7 +72,6 @@ const CountUp = (props: CountUpProps) => {
...
@@ -70,7 +72,6 @@ const CountUp = (props: CountUpProps) => {
},
[
currentQuestionIndex
,
questionLength
,
isSubmit
])
},
[
currentQuestionIndex
,
questionLength
,
isSubmit
])
const
handleTimeUp
=
useCallback
(()
=>
{
const
handleTimeUp
=
useCallback
(()
=>
{
console
.
log
(
'upd1'
)
if
(
isOneStop
)
{
if
(
isOneStop
)
{
submit
()
submit
()
}
}
...
@@ -87,10 +88,16 @@ const CountUp = (props: CountUpProps) => {
...
@@ -87,10 +88,16 @@ const CountUp = (props: CountUpProps) => {
<
View
className=
{
styles
.
process_inner
}
style=
{
processInnerStyle
}
></
View
>
<
View
className=
{
styles
.
process_inner
}
style=
{
processInnerStyle
}
></
View
>
{
!
isOneStop
&&
(
{
!
isOneStop
&&
(
<
View
className=
{
styles
.
roleWrap
}
style=
{
roleStyle
}
>
<
View
className=
{
styles
.
roleWrap
}
style=
{
roleStyle
}
>
<
View
className=
{
styles
.
role
}
>
<
View
className=
{
classNames
(
styles
.
role
,
isBattle
&&
styles
.
is_battle
)
}
>
<
View
className=
{
styles
.
tick
}
></
View
>
<
View
className=
{
styles
.
tick
}
></
View
>
<
Image
src=
{
require
(
'../assets/count-cat.png'
)
}
className=
{
styles
.
cat
}
></
Image
>
{
isBattle
<
View
className=
{
styles
.
tips
}
>
通关要求
</
View
>
?
(
<
Image
src=
{
assetsGame
[
'battle-icon.png'
].
u
}
className=
{
styles
.
cat
}
></
Image
>
)
:
(
<
Image
src=
{
require
(
'../assets/count-cat.png'
)
}
className=
{
styles
.
cat
}
></
Image
>
)
}
<
View
className=
{
styles
.
tips
}
>
{
isBattle
?
'对手用时'
:
'通关要求'
}
</
View
>
</
View
>
</
View
>
</
View
>
</
View
>
)
}
)
}
...
...
src/pages/game/play/components/page-head.tsx
View file @
2a898e6d
...
@@ -5,7 +5,12 @@ import { useStoreState } from '@/store/hooks'
...
@@ -5,7 +5,12 @@ import { useStoreState } from '@/store/hooks'
import
styles
from
'./page-head.module.scss'
import
styles
from
'./page-head.module.scss'
const
PageHead
=
()
=>
{
type
PageHeadProps
=
{
isBattle
:
boolean
;
}
const
PageHead
=
(
props
:
PageHeadProps
)
=>
{
const
{
isBattle
}
=
props
const
[
nav
]
=
useState
(
getMenuButtonBoundingClientRect
())
const
[
nav
]
=
useState
(
getMenuButtonBoundingClientRect
())
const
questionList
=
useStoreState
(
states
=>
states
.
gameModel
.
questionList
)
const
questionList
=
useStoreState
(
states
=>
states
.
gameModel
.
questionList
)
const
currentQuestionIndex
=
useStoreState
(
states
=>
states
.
gameModel
.
currentQuestionIndex
)
const
currentQuestionIndex
=
useStoreState
(
states
=>
states
.
gameModel
.
currentQuestionIndex
)
...
@@ -19,7 +24,9 @@ const PageHead = () => {
...
@@ -19,7 +24,9 @@ const PageHead = () => {
}
}
}
}
>
>
<
View
className=
{
styles
.
inner
}
style=
{
{
height
:
`${nav.height + 10}px`
}
}
>
<
View
className=
{
styles
.
inner
}
style=
{
{
height
:
`${nav.height + 10}px`
}
}
>
<
Image
src=
{
require
(
'../assets/arrow.png'
)
}
className=
{
styles
.
arrow
}
onClick=
{
()
=>
navigateBack
()
}
></
Image
>
{
!
isBattle
&&
(
<
Image
src=
{
require
(
'../assets/arrow.png'
)
}
className=
{
styles
.
arrow
}
onClick=
{
()
=>
navigateBack
()
}
></
Image
>
)
}
{
questionList
.
length
>
0
{
questionList
.
length
>
0
?
(<
Text
>
{
currentQuestionIndex
+
1
}
/
{
questionList
.
length
}
</
Text
>)
?
(<
Text
>
{
currentQuestionIndex
+
1
}
/
{
questionList
.
length
}
</
Text
>)
:
(<
Text
>
出错了
</
Text
>)
:
(<
Text
>
出错了
</
Text
>)
...
...
src/pages/game/play/index.tsx
View file @
2a898e6d
...
@@ -2,7 +2,7 @@ import { ScrollView, Image } from '@tarojs/components'
...
@@ -2,7 +2,7 @@ import { ScrollView, Image } from '@tarojs/components'
import
{
useStoreState
,
useStoreActions
}
from
'@/store/hooks'
import
{
useStoreState
,
useStoreActions
}
from
'@/store/hooks'
import
{
preloadImage
}
from
'@/utils/preload-image'
import
{
preloadImage
}
from
'@/utils/preload-image'
import
{
useEffect
,
useMemo
}
from
'react'
import
{
useEffect
,
useMemo
}
from
'react'
import
{
useDidShow
,
enableAlertBeforeUnload
,
disableAlertBeforeUnload
}
from
'@tarojs/taro'
import
{
useDidShow
,
enableAlertBeforeUnload
,
disableAlertBeforeUnload
,
useRouter
}
from
'@tarojs/taro'
import
assets
from
'@/assets/oss/assets-complete'
import
assets
from
'@/assets/oss/assets-complete'
import
{
EyeProtectionView
}
from
'@/components'
import
{
EyeProtectionView
}
from
'@/components'
...
@@ -42,6 +42,12 @@ const GamePlay = () => {
...
@@ -42,6 +42,12 @@ const GamePlay = () => {
const
clearUserAnswer
=
useStoreActions
(
actions
=>
actions
.
gameModel
.
clearUserAnswer
)
const
clearUserAnswer
=
useStoreActions
(
actions
=>
actions
.
gameModel
.
clearUserAnswer
)
const
handleGoNext
=
useStoreActions
(
actions
=>
actions
.
gameModel
.
handleGoNext
)
const
handleGoNext
=
useStoreActions
(
actions
=>
actions
.
gameModel
.
handleGoNext
)
const
router
=
useRouter
()
const
isBattle
=
useMemo
(()
=>
{
return
router
.
params
.
isBattle
===
'true'
},
[
router
])
useEffect
(()
=>
{
useEffect
(()
=>
{
enableAlertBeforeUnload
({
enableAlertBeforeUnload
({
message
:
'还没有答完哦,确定要离开吗?'
,
message
:
'还没有答完哦,确定要离开吗?'
,
...
@@ -61,9 +67,9 @@ const GamePlay = () => {
...
@@ -61,9 +67,9 @@ const GamePlay = () => {
return
(
return
(
<>
<>
<
EyeProtectionView
className=
{
styles
.
viewport
}
>
<
EyeProtectionView
className=
{
styles
.
viewport
}
>
<
PageHead
/>
<
PageHead
isBattle=
{
isBattle
}
/>
{
currentQuestion
&&
stageDetail
&&
(
{
currentQuestion
&&
stageDetail
&&
(
<
CountUp
stageDetail=
{
stageDetail
}
/>
<
CountUp
stageDetail=
{
stageDetail
}
isBattle=
{
isBattle
}
/>
)
}
)
}
<
ScrollView
className=
{
styles
.
body
}
scrollY
>
<
ScrollView
className=
{
styles
.
body
}
scrollY
>
{
currentQuestion
&&
(
{
currentQuestion
&&
(
...
...
src/pages/main/main-underground/create-pk.module.scss
View file @
2a898e6d
...
@@ -43,7 +43,7 @@
...
@@ -43,7 +43,7 @@
flex
:
1
;
flex
:
1
;
position
:
relative
;
position
:
relative
;
width
:
100%
;
width
:
100%
;
transition
:
transform
.5s
ease-
out
;
transition
:
transform
.5s
ease-
in
;
}
}
.top
{
.top
{
...
@@ -92,9 +92,9 @@
...
@@ -92,9 +92,9 @@
left
:
50%
;
left
:
50%
;
margin-left
:
-155px
;
margin-left
:
-155px
;
animation-name
:
shake
;
animation-name
:
shake
;
animation-timing-function
:
ease-
out
;
animation-timing-function
:
ease-
in
;
animation-fill-mode
:
backwards
;
animation-fill-mode
:
backwards
;
animation-duration
:
1
s
;
animation-duration
:
0
.8
s
;
animation-delay
:
.5s
;
animation-delay
:
.5s
;
}
}
...
@@ -146,8 +146,8 @@
...
@@ -146,8 +146,8 @@
.pk_flash_left
,
.pk_flash_right
{
.pk_flash_left
,
.pk_flash_right
{
width
:
360px
;
width
:
360px
;
height
:
200px
;
height
:
200px
;
animation-timing-function
:
ease-
out
;
animation-timing-function
:
ease-
in
;
animation-duration
:
1
s
;
animation-duration
:
0
.8
s
;
animation-fill-mode
:
backwards
;
animation-fill-mode
:
backwards
;
animation-delay
:
0
.5s
;
animation-delay
:
0
.5s
;
}
}
...
...
src/pages/main/main-underground/create-pk.tsx
View file @
2a898e6d
...
@@ -41,6 +41,7 @@ const CreatePk = (props: CreatePkProps) => {
...
@@ -41,6 +41,7 @@ const CreatePk = (props: CreatePkProps) => {
<
Image
src=
{
assetsMainNext
[
'pk-close.png'
].
u
}
className=
{
styles
.
close_icon
}
></
Image
>
<
Image
src=
{
assetsMainNext
[
'pk-close.png'
].
u
}
className=
{
styles
.
close_icon
}
></
Image
>
</
View
>
</
View
>
</
View
>
</
View
>
<
View
className=
{
classNames
(
styles
.
top
,
visible
&&
styles
.
is_show
)
}
>
<
View
className=
{
classNames
(
styles
.
top
,
visible
&&
styles
.
is_show
)
}
>
<
Image
src=
{
assetsMainNext
[
'pk-top.png'
].
u
}
className=
{
styles
.
bg_top
}
mode=
"widthFix"
></
Image
>
<
Image
src=
{
assetsMainNext
[
'pk-top.png'
].
u
}
className=
{
styles
.
bg_top
}
mode=
"widthFix"
></
Image
>
<
View
className=
{
styles
.
top_content
}
>
<
View
className=
{
styles
.
top_content
}
>
...
@@ -56,6 +57,7 @@ const CreatePk = (props: CreatePkProps) => {
...
@@ -56,6 +57,7 @@ const CreatePk = (props: CreatePkProps) => {
</
View
>
</
View
>
</
View
>
</
View
>
</
View
>
</
View
>
<
View
className=
{
classNames
(
styles
.
bottom
,
visible
&&
styles
.
is_show
)
}
>
<
View
className=
{
classNames
(
styles
.
bottom
,
visible
&&
styles
.
is_show
)
}
>
<
Image
src=
{
assetsMainNext
[
'pk-slogen.png'
].
u
}
className=
{
styles
.
pk_slogan
}
></
Image
>
<
Image
src=
{
assetsMainNext
[
'pk-slogen.png'
].
u
}
className=
{
styles
.
pk_slogan
}
></
Image
>
<
Image
src=
{
assetsMainNext
[
'pk-bottom.png'
].
u
}
className=
{
styles
.
bg_bottom
}
mode=
"widthFix"
></
Image
>
<
Image
src=
{
assetsMainNext
[
'pk-bottom.png'
].
u
}
className=
{
styles
.
bg_bottom
}
mode=
"widthFix"
></
Image
>
...
@@ -70,6 +72,7 @@ const CreatePk = (props: CreatePkProps) => {
...
@@ -70,6 +72,7 @@ const CreatePk = (props: CreatePkProps) => {
<
View
className=
{
styles
.
tips
}
>
会以你的最佳表现与对方答题数据进行PK
</
View
>
<
View
className=
{
styles
.
tips
}
>
会以你的最佳表现与对方答题数据进行PK
</
View
>
</
View
>
</
View
>
</
View
>
</
View
>
{
visible
&&
(
{
visible
&&
(
<
View
className=
{
styles
.
center
}
>
<
View
className=
{
styles
.
center
}
>
<
View
className=
{
styles
.
pk_flash
}
>
<
View
className=
{
styles
.
pk_flash
}
>
...
...
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