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
d5d7ee95
Commit
d5d7ee95
authored
Apr 04, 2023
by
hewenhao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: update
parent
e2ccd7a4
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
33 additions
and
14 deletions
+33
-14
global.d.ts
global.d.ts
+2
-0
index.js
src/native-components/count-up/index.js
+9
-2
time-red.png
src/pages/game/play/assets/time-red.png
+0
-0
count-up.module.scss
src/pages/game/play/components/count-up.module.scss
+4
-0
count-up.tsx
src/pages/game/play/components/count-up.tsx
+18
-12
No files found.
global.d.ts
View file @
d5d7ee95
...
@@ -17,7 +17,9 @@ type CountUpTime = React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement> & {
...
@@ -17,7 +17,9 @@ type CountUpTime = React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement> & {
'maxValue'
?:
number
;
'maxValue'
?:
number
;
'isDown'
?:
boolean
;
'isDown'
?:
boolean
;
'startValue'
:
number
;
'startValue'
:
number
;
exceedTime
:
number
;
onTimeup
?:
()
=>
void
;
onTimeup
?:
()
=>
void
;
onExceed
?:
()
=>
void
;
},
HTMLElement
>
},
HTMLElement
>
declare
namespace
JSX
{
declare
namespace
JSX
{
...
...
src/native-components/count-up/index.js
View file @
d5d7ee95
...
@@ -34,12 +34,16 @@ Component({
...
@@ -34,12 +34,16 @@ Component({
startValue
:
{
startValue
:
{
type
:
Number
,
type
:
Number
,
value
:
0
value
:
0
},
exceedTime
:
{
type
:
Number
,
value
:
20
}
}
},
},
data
:
{
data
:
{
minutes
:
'00'
,
minutes
:
'00'
,
seconds
:
'00'
seconds
:
'00'
,
},
},
attached
()
{
attached
()
{
...
@@ -64,7 +68,6 @@ Component({
...
@@ -64,7 +68,6 @@ Component({
start
()
{
start
()
{
this
.
stop
()
this
.
stop
()
this
.
_timer
=
setInterval
(()
=>
{
this
.
_timer
=
setInterval
(()
=>
{
console
.
log
(
this
.
data
)
const
isDown
=
this
.
data
.
isDown
const
isDown
=
this
.
data
.
isDown
if
(
isDown
)
{
if
(
isDown
)
{
this
.
_tick
-=
1
this
.
_tick
-=
1
...
@@ -72,6 +75,10 @@ Component({
...
@@ -72,6 +75,10 @@ Component({
this
.
stop
()
this
.
stop
()
this
.
triggerEvent
(
'timeup'
)
this
.
triggerEvent
(
'timeup'
)
}
}
if
(
this
.
_tick
===
this
.
data
.
exceedTime
)
{
this
.
triggerEvent
(
'exceed'
)
}
}
else
{
}
else
{
this
.
_tick
+=
1
this
.
_tick
+=
1
if
(
this
.
_tick
>=
this
.
data
.
maxValue
)
{
if
(
this
.
_tick
>=
this
.
data
.
maxValue
)
{
...
...
src/pages/game/play/assets/time-red.png
0 → 100644
View file @
d5d7ee95
406 Bytes
src/pages/game/play/components/count-up.module.scss
View file @
d5d7ee95
...
@@ -31,6 +31,10 @@
...
@@ -31,6 +31,10 @@
color
:
#465164
;
color
:
#465164
;
line-height
:
46px
;
line-height
:
46px
;
&
.red
{
color
:
#FF7770
;
}
.icon
{
.icon
{
width
:
32px
;
width
:
32px
;
height
:
32px
;
height
:
32px
;
...
...
src/pages/game/play/components/count-up.tsx
View file @
d5d7ee95
import
{
View
,
Image
}
from
'@tarojs/components'
import
{
View
,
Image
}
from
'@tarojs/components'
import
{
useState
,
useEffect
,
useCallback
,
useMemo
,
useRef
}
from
'react'
import
{
useState
,
useEffect
,
useCallback
,
useMemo
}
from
'react'
import
{
createSelectorQuery
,
getCurrentInstance
}
from
'@tarojs/taro'
import
{
createSelectorQuery
}
from
'@tarojs/taro'
import
classNames
from
'classnames'
import
classNames
from
'classnames'
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'
...
@@ -21,6 +22,7 @@ const CountUp = (props: CountUpProps) => {
...
@@ -21,6 +22,7 @@ const CountUp = (props: CountUpProps) => {
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
[
width
,
setWidth
]
=
useState
(
0
)
const
[
width
,
setWidth
]
=
useState
(
0
)
const
[
isExceed
,
exceedActions
]
=
useBoolean
(
false
)
const
questionLength
=
useMemo
(()
=>
{
const
questionLength
=
useMemo
(()
=>
{
return
questionList
.
length
return
questionList
.
length
...
@@ -55,13 +57,6 @@ const CountUp = (props: CountUpProps) => {
...
@@ -55,13 +57,6 @@ const CountUp = (props: CountUpProps) => {
}
}
},
[
width
,
stageDetail
.
bTime
])
},
[
width
,
stageDetail
.
bTime
])
// useEffect(() => {
// if (isSubmit) {
// const comp = getCurrentInstance()?.page?.selectComponent?.(`#${counterId}`) as any
// comp?.stop?.()
// }
// }, [isSubmit, counterId])
const
processInnerStyle
=
useMemo
(()
=>
{
const
processInnerStyle
=
useMemo
(()
=>
{
if
(
isSubmit
)
{
if
(
isSubmit
)
{
return
{
return
{
...
@@ -92,9 +87,20 @@ const CountUp = (props: CountUpProps) => {
...
@@ -92,9 +87,20 @@ const CountUp = (props: CountUpProps) => {
</
View
>
</
View
>
)
}
)
}
</
View
>
</
View
>
<
View
className=
{
styles
.
time
}
>
<
View
className=
{
classNames
(
styles
.
time
,
isExceed
&&
styles
.
red
)
}
>
<
Image
src=
{
require
(
'../assets/count-time.png'
)
}
className=
{
styles
.
icon
}
></
Image
>
{
isExceed
<
count
-
up
-
time
maxValue=
{
60
*
60
}
startValue=
{
startTick
}
isDown=
{
isOneStop
}
onTimeup=
{
handleTimeUp
}
id=
{
counterId
}
/>
?
(<
Image
src=
{
require
(
'../assets/time-red.png'
)
}
className=
{
styles
.
icon
}
></
Image
>)
:
(<
Image
src=
{
require
(
'../assets/count-time.png'
)
}
className=
{
styles
.
icon
}
></
Image
>)
}
<
count
-
up
-
time
exceedTime=
{
20
}
onExceed=
{
exceedActions
.
setTrue
}
maxValue=
{
60
*
60
}
startValue=
{
startTick
}
isDown=
{
isOneStop
}
onTimeup=
{
handleTimeUp
}
id=
{
counterId
}
/>
</
View
>
</
View
>
</
View
>
</
View
>
)
)
...
...
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