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
974597e5
Commit
974597e5
authored
Apr 04, 2023
by
hewenhao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 一战到底
parent
acc860b3
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
65 additions
and
31 deletions
+65
-31
global.d.ts
global.d.ts
+6
-1
game.ts
src/api/game.ts
+1
-1
index.js
src/native-components/count-up/index.js
+19
-6
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
+17
-3
constants.ts
src/pages/main/components/scene/constants.ts
+5
-14
small-part.tsx
src/pages/main/components/scene/small-part.tsx
+1
-1
main.tsx
src/pages/main/main.tsx
+6
-2
model.ts
src/pages/main/model.ts
+6
-3
No files found.
global.d.ts
View file @
974597e5
...
@@ -13,7 +13,12 @@ declare module '*.styl';
...
@@ -13,7 +13,12 @@ declare module '*.styl';
type
CountUptime
=
React
.
FC
<
{
maxNum
}
>
type
CountUptime
=
React
.
FC
<
{
maxNum
}
>
type
CountUpTime
=
React
.
DetailedHTMLProps
<
React
.
HTMLAttributes
<
HTMLElement
>
&
{
'max-value'
?:
number
,
onTimeup
?:
()
=>
void
},
HTMLElement
>
type
CountUpTime
=
React
.
DetailedHTMLProps
<
React
.
HTMLAttributes
<
HTMLElement
>
&
{
'maxValue'
?:
number
;
'isDown'
?:
boolean
;
'startValue'
:
number
;
onTimeup
?:
()
=>
void
;
},
HTMLElement
>
declare
namespace
JSX
{
declare
namespace
JSX
{
interface
IntrinsicElements
{
interface
IntrinsicElements
{
...
...
src/api/game.ts
View file @
974597e5
...
@@ -19,7 +19,7 @@ export const enum StageStatus {
...
@@ -19,7 +19,7 @@ export const enum StageStatus {
export
const
enum
StageType
{
export
const
enum
StageType
{
Strong
=
'强化'
,
Strong
=
'强化'
,
Enhance
=
'应用'
,
Enhance
=
'应用'
,
OneStop
=
'一
站
到底'
,
OneStop
=
'一
战
到底'
,
}
}
export
const
enum
StageLevel
{
export
const
enum
StageLevel
{
...
...
src/native-components/count-up/index.js
View file @
974597e5
...
@@ -27,6 +27,14 @@ Component({
...
@@ -27,6 +27,14 @@ Component({
type
:
Number
,
type
:
Number
,
value
:
100
*
60
*
60
value
:
100
*
60
*
60
},
},
isDown
:
{
type
:
Boolean
,
value
:
false
,
},
startValue
:
{
type
:
Number
,
value
:
0
}
},
},
data
:
{
data
:
{
...
@@ -35,7 +43,6 @@ Component({
...
@@ -35,7 +43,6 @@ Component({
},
},
attached
()
{
attached
()
{
this
.
_tick
=
0
this
.
startCount
()
this
.
startCount
()
console
.
log
(
this
)
console
.
log
(
this
)
},
},
...
@@ -48,12 +55,23 @@ Component({
...
@@ -48,12 +55,23 @@ Component({
},
},
startCount
()
{
startCount
()
{
this
.
stop
()
this
.
stop
()
this
.
_tick
=
this
.
data
.
startValue
this
.
_timer
=
setInterval
(()
=>
{
this
.
_timer
=
setInterval
(()
=>
{
console
.
log
(
this
.
data
)
const
isDown
=
this
.
data
.
isDown
if
(
isDown
)
{
this
.
_tick
-=
1
if
(
this
.
_tick
<=
0
)
{
this
.
stop
()
this
.
triggerEvent
(
'timeup'
)
}
}
else
{
this
.
_tick
+=
1
this
.
_tick
+=
1
if
(
this
.
_tick
>=
this
.
data
.
maxValue
)
{
if
(
this
.
_tick
>=
this
.
data
.
maxValue
)
{
this
.
stop
()
this
.
stop
()
this
.
triggerEvent
(
'timeup'
)
this
.
triggerEvent
(
'timeup'
)
}
}
}
const
{
minutes
,
seconds
}
=
this
.
data
const
{
minutes
,
seconds
}
=
this
.
data
const
val
=
this
.
_tick
*
1000
const
val
=
this
.
_tick
*
1000
...
@@ -70,11 +88,6 @@ Component({
...
@@ -70,11 +88,6 @@ Component({
this
.
setData
(
opts
)
this
.
setData
(
opts
)
},
1000
)
},
1000
)
},
},
onMyButtonTap
:
function
()
{
this
.
setData
({
// 更新属性和数据的方法与更新页面数据的方法类似
})
},
}
}
})
})
src/pages/game/play/components/count-up.module.scss
View file @
974597e5
...
@@ -2,6 +2,10 @@
...
@@ -2,6 +2,10 @@
padding
:
40px
32px
100px
32px
;
padding
:
40px
32px
100px
32px
;
display
:
flex
;
display
:
flex
;
align-items
:
center
;
align-items
:
center
;
&
.is_stop
{
padding-bottom
:
50px
;
}
}
}
.process
{
.process
{
...
...
src/pages/game/play/components/count-up.tsx
View file @
974597e5
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
,
useRef
}
from
'react'
import
{
createSelectorQuery
,
getCurrentInstance
}
from
'@tarojs/taro'
import
{
createSelectorQuery
,
getCurrentInstance
}
from
'@tarojs/taro'
import
classNames
from
'classnames'
import
{
useStoreState
}
from
'@/store/hooks'
import
{
useStoreState
}
from
'@/store/hooks'
import
{
type
StageDetail
}
from
'@/api'
import
{
type
StageDetail
,
StageType
}
from
'@/api'
import
styles
from
'./count-up.module.scss'
import
styles
from
'./count-up.module.scss'
...
@@ -35,6 +36,17 @@ const CountUp = (props: CountUpProps) => {
...
@@ -35,6 +36,17 @@ const CountUp = (props: CountUpProps) => {
})
})
},
[])
},
[])
const
isOneStop
=
useMemo
(()
=>
{
return
stageDetail
.
type
===
StageType
.
OneStop
},
[
stageDetail
])
const
startTick
=
useMemo
(()
=>
{
if
(
stageDetail
.
type
===
StageType
.
OneStop
)
{
return
stageDetail
.
bTime
}
return
0
},
[
stageDetail
])
const
roleStyle
=
useMemo
(()
=>
{
const
roleStyle
=
useMemo
(()
=>
{
return
{
return
{
transform
:
`translateX(
${
width
}
px)`
,
transform
:
`translateX(
${
width
}
px)`
,
...
@@ -66,18 +78,20 @@ const CountUp = (props: CountUpProps) => {
...
@@ -66,18 +78,20 @@ const CountUp = (props: CountUpProps) => {
},
[])
},
[])
return
(
return
(
<
View
className=
{
styles
.
count
}
>
<
View
className=
{
classNames
(
styles
.
count
,
isOneStop
&&
styles
.
is_stop
)
}
>
<
View
className=
{
styles
.
process
}
id=
{
id
}
>
<
View
className=
{
styles
.
process
}
id=
{
id
}
>
<
View
className=
{
styles
.
process_inner
}
style=
{
processInnerStyle
}
></
View
>
<
View
className=
{
styles
.
process_inner
}
style=
{
processInnerStyle
}
></
View
>
{
!
isOneStop
&&
(
<
View
className=
{
styles
.
role
}
style=
{
roleStyle
}
>
<
View
className=
{
styles
.
role
}
style=
{
roleStyle
}
>
<
View
className=
{
styles
.
tick
}
></
View
>
<
View
className=
{
styles
.
tick
}
></
View
>
<
Image
src=
{
require
(
'../assets/count-cat.png'
)
}
className=
{
styles
.
cat
}
></
Image
>
<
Image
src=
{
require
(
'../assets/count-cat.png'
)
}
className=
{
styles
.
cat
}
></
Image
>
<
View
className=
{
styles
.
tips
}
>
通关要求
</
View
>
<
View
className=
{
styles
.
tips
}
>
通关要求
</
View
>
</
View
>
</
View
>
)
}
</
View
>
</
View
>
<
View
className=
{
styles
.
time
}
>
<
View
className=
{
styles
.
time
}
>
<
Image
src=
{
require
(
'../assets/count-time.png'
)
}
className=
{
styles
.
icon
}
></
Image
>
<
Image
src=
{
require
(
'../assets/count-time.png'
)
}
className=
{
styles
.
icon
}
></
Image
>
<
count
-
up
-
time
max
-
value=
{
60
*
60
}
onTimeup=
{
handleTimeUp
}
ref=
{
countUp
}
/>
<
count
-
up
-
time
max
Value=
{
60
*
60
}
startValue=
{
startTick
}
isDown=
{
isOneStop
}
onTimeup=
{
handleTimeUp
}
ref=
{
countUp
}
/>
</
View
>
</
View
>
</
View
>
</
View
>
)
)
...
...
src/pages/main/components/scene/constants.ts
View file @
974597e5
...
@@ -77,10 +77,10 @@ export function groupRoundToSmallPart (list: Stage[]): SmallPart[] {
...
@@ -77,10 +77,10 @@ export function groupRoundToSmallPart (list: Stage[]): SmallPart[] {
while
(
start
<
len
)
{
while
(
start
<
len
)
{
if
(
flag
===
'even'
)
{
if
(
flag
===
'even'
)
{
const
round
s
=
list
.
slice
(
start
,
start
+
2
)
const
stage
s
=
list
.
slice
(
start
,
start
+
2
)
let
partType
:
SmallPart
[
'type'
]
=
'even'
let
partType
:
SmallPart
[
'type'
]
=
'even'
let
bg
:
ImageSource
let
bg
:
ImageSource
if
(
round
s
.
length
<
2
)
{
if
(
stage
s
.
length
<
2
)
{
specialIndex
+=
1
specialIndex
+=
1
partType
=
'special'
partType
=
'special'
bg
=
getSmallPartBg
(
specialIndex
,
partType
)
bg
=
getSmallPartBg
(
specialIndex
,
partType
)
...
@@ -89,7 +89,7 @@ export function groupRoundToSmallPart (list: Stage[]): SmallPart[] {
...
@@ -89,7 +89,7 @@ export function groupRoundToSmallPart (list: Stage[]): SmallPart[] {
bg
=
getSmallPartBg
(
evenIndex
,
partType
)
bg
=
getSmallPartBg
(
evenIndex
,
partType
)
}
}
ret
.
push
({
ret
.
push
({
round
s
,
stage
s
,
bg
,
bg
,
offset
:
start
,
offset
:
start
,
type
:
partType
type
:
partType
...
@@ -99,7 +99,7 @@ export function groupRoundToSmallPart (list: Stage[]): SmallPart[] {
...
@@ -99,7 +99,7 @@ export function groupRoundToSmallPart (list: Stage[]): SmallPart[] {
}
else
if
(
flag
===
'odd'
)
{
}
else
if
(
flag
===
'odd'
)
{
oddIndex
+=
1
oddIndex
+=
1
ret
.
push
({
ret
.
push
({
round
s
:
list
.
slice
(
start
,
start
+
1
),
stage
s
:
list
.
slice
(
start
,
start
+
1
),
bg
:
getSmallPartBg
(
oddIndex
,
'odd'
),
bg
:
getSmallPartBg
(
oddIndex
,
'odd'
),
offset
:
start
,
offset
:
start
,
type
:
'odd'
type
:
'odd'
...
@@ -112,17 +112,8 @@ export function groupRoundToSmallPart (list: Stage[]): SmallPart[] {
...
@@ -112,17 +112,8 @@ export function groupRoundToSmallPart (list: Stage[]): SmallPart[] {
return
ret
return
ret
}
}
export
const
enum
RoundState
{
/** 未解锁 */
Locked
=
1
,
/** 已完成 */
Clear
=
2
,
/** 已解锁 */
UnLocked
=
3
}
export
type
SmallPart
=
{
export
type
SmallPart
=
{
round
s
:
Stage
[];
stage
s
:
Stage
[];
bg
:
ImageSource
;
bg
:
ImageSource
;
offset
:
number
;
offset
:
number
;
type
:
'odd'
|
'even'
|
'special'
;
type
:
'odd'
|
'even'
|
'special'
;
...
...
src/pages/main/components/scene/small-part.tsx
View file @
974597e5
...
@@ -24,7 +24,7 @@ const SceneSmallPart = (props: SceneSmallPartProps) => {
...
@@ -24,7 +24,7 @@ const SceneSmallPart = (props: SceneSmallPartProps) => {
const
{
part
}
=
props
const
{
part
}
=
props
return
(
return
(
<
LazeImage
source=
{
part
.
bg
}
>
<
LazeImage
source=
{
part
.
bg
}
>
{
part
.
round
s
.
map
((
item
,
index
)
=>
{
{
part
.
stage
s
.
map
((
item
,
index
)
=>
{
return
(
return
(
<
RoundComp
stage=
{
item
}
key=
{
item
.
id
}
className=
{
getClassName
(
index
,
part
.
type
)
}
/>
<
RoundComp
stage=
{
item
}
key=
{
item
.
id
}
className=
{
getClassName
(
index
,
part
.
type
)
}
/>
)
)
...
...
src/pages/main/main.tsx
View file @
974597e5
...
@@ -4,7 +4,7 @@ import { useState, useMemo, useEffect, useCallback } from 'react'
...
@@ -4,7 +4,7 @@ import { useState, useMemo, useEffect, useCallback } from 'react'
import
{
useStoreActions
,
useStoreState
}
from
'@/store/hooks'
import
{
useStoreActions
,
useStoreState
}
from
'@/store/hooks'
import
type
{
TabbarRef
}
from
'../../custom-tab-bar/index'
import
type
{
TabbarRef
}
from
'../../custom-tab-bar/index'
import
{
CurrentRoundId
,
SceneContext
}
from
'./components/scene/constants'
import
{
CurrentRoundId
,
SceneContext
,
StageStatus
}
from
'./components/scene/constants'
import
MainHeader
from
'./components/header'
import
MainHeader
from
'./components/header'
import
MainChapter
from
'./components/chapter'
import
MainChapter
from
'./components/chapter'
import
MainScene
from
'./components/scene'
import
MainScene
from
'./components/scene'
...
@@ -33,11 +33,15 @@ const MainPage = () => {
...
@@ -33,11 +33,15 @@ const MainPage = () => {
fetchAccount
()
fetchAccount
()
const
tabbar
=
getTabBar
<
TabbarRef
>
(
page
)
const
tabbar
=
getTabBar
<
TabbarRef
>
(
page
)
tabbar
?.
setSelected
(
0
)
tabbar
?.
setSelected
(
0
)
fetchStage
().
then
(()
=>
{
fetchStage
().
then
((
list
)
=>
{
setTimeout
(()
=>
{
setTimeout
(()
=>
{
if
(
!
list
.
find
(
c
=>
c
.
status
===
StageStatus
.
CURRENT
))
{
setIsReady
(
true
)
}
else
{
scrollToCurrent
(()
=>
{
scrollToCurrent
(()
=>
{
setIsReady
(
true
)
setIsReady
(
true
)
})
})
}
},
1000
)
},
1000
)
})
})
})
})
...
...
src/pages/main/model.ts
View file @
974597e5
...
@@ -7,7 +7,7 @@ import { type Stage, getStageList } from '@/api'
...
@@ -7,7 +7,7 @@ import { type Stage, getStageList } from '@/api'
export
interface
MainModel
{
export
interface
MainModel
{
stageList
:
Stage
[];
stageList
:
Stage
[];
updateStageList
:
Action
<
MainModel
,
Stage
[]
>
;
updateStageList
:
Action
<
MainModel
,
Stage
[]
>
;
fetchStage
:
Thunk
<
MainModel
,
void
,
void
,
AppStoreModel
>
;
fetchStage
:
Thunk
<
MainModel
,
void
,
void
,
AppStoreModel
,
Promise
<
Stage
[]
>
>
;
}
}
const
mainModel
:
MainModel
=
{
const
mainModel
:
MainModel
=
{
...
@@ -16,12 +16,15 @@ const mainModel: MainModel = {
...
@@ -16,12 +16,15 @@ const mainModel: MainModel = {
state
.
stageList
=
stageList
state
.
stageList
=
stageList
}),
}),
fetchStage
:
thunk
(
async
(
actions
,
_
)
=>
{
fetchStage
:
thunk
(
async
(
actions
,
_
)
=>
{
let
ret
:
Stage
[]
=
[]
try
{
try
{
const
{
data
:
stageList
}
=
await
getStageList
()
const
{
data
:
stageList
}
=
await
getStageList
()
actions
.
updateStageList
(
stageList
)
ret
=
stageList
}
catch
(
err
)
{
}
catch
(
err
)
{
actions
.
updateStageList
([])
ret
=
[]
}
}
actions
.
updateStageList
(
ret
)
return
ret
}),
}),
}
}
...
...
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