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
05d10e19
Commit
05d10e19
authored
Jun 20, 2023
by
hewenhao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 分数加减法
parent
f209fe0f
Show whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
497 additions
and
22 deletions
+497
-22
game.ts
src/api/game.ts
+2
-0
index.tsx
src/components/UserGuideView/index.tsx
+11
-4
index.tsx
src/pages/battles/index.tsx
+8
-1
dot.png
src/pages/game/play/assets/math-symbol/dot.png
+0
-0
count-up.tsx
src/pages/game/play/components/count-up.tsx
+7
-7
math-symbol.module.scss
src/pages/game/play/components/math-symbol.module.scss
+5
-0
math-symbol.tsx
src/pages/game/play/components/math-symbol.tsx
+6
-2
index.tsx
src/pages/game/play/components/question/index.tsx
+13
-1
question-fraction-add-minus.module.scss
...mponents/question/question-fraction-add-minus.module.scss
+42
-0
question-fraction-add-minus.tsx
.../play/components/question/question-fraction-add-minus.tsx
+70
-0
question-vertical-add-minus.module.scss
...mponents/question/question-vertical-add-minus.module.scss
+67
-0
question-vertical-add-minus.tsx
.../play/components/question/question-vertical-add-minus.tsx
+156
-0
index.ts
src/pages/game/play/model/index.ts
+1
-0
types.ts
src/pages/game/play/types.ts
+50
-2
chapter.tsx
src/pages/main/main-underground/chapter.tsx
+8
-1
create-pk.tsx
src/pages/main/main-underground/create-pk.tsx
+1
-1
main-component.tsx
src/pages/main/main-underground/main-component.tsx
+7
-0
constants.ts
src/pages/main/main-underground/scene/constants.ts
+6
-2
stage.tsx
src/pages/main/main-underground/scene/stage.tsx
+11
-1
guide.ts
src/store/modules/guide.ts
+21
-0
storage.ts
src/utils/storage.ts
+5
-0
No files found.
src/api/game.ts
View file @
05d10e19
...
...
@@ -56,6 +56,8 @@ export interface Stage {
index
:
number
;
/** 首页用 */
$stageIndex
:
number
;
/** pk历史返回引导用 */
$lastPassedStage
:
boolean
;
content
:
string
;
gear
:
number
;
id
:
number
;
...
...
src/components/UserGuideView/index.tsx
View file @
05d10e19
...
...
@@ -17,6 +17,7 @@ type UserGuideProps<T extends ComponentType<any>> = {
verticalPadding
?:
number
;
horizonPadding
?:
number
;
guideContent
?:
ReactNode
;
delay
?:
number
;
wrapClass
?:
string
;
placeholderContent
?:
ReactNode
;
}
&
GetProps
<
T
>
...
...
@@ -26,6 +27,7 @@ function UserGuideView<T extends ComponentType<any> = typeof View> (props: UserG
isActive
,
wrapClass
,
guideViewId
,
guideContent
,
verticalPadding
=
0
,
horizonPadding
=
0
,
onFinish
,
onContentLongPress
,
placeholderContent
,
delay
=
0
,
onClickConent
,
component
:
Comp
=
View
,
...
rest
}
=
props
const
[
rect
,
setRect
]
=
useState
({
width
:
80
,
height
:
80
,
top
:
0
,
left
:
0
})
...
...
@@ -37,9 +39,9 @@ function UserGuideView<T extends ComponentType<any> = typeof View> (props: UserG
})
useEffect
(()
=>
{
let
timer
if
(
isActive
)
{
console
.
log
(
domRef
.
current
)
setTimeout
(()
=>
{
timer
=
setTimeout
(()
=>
{
nextTick
(()
=>
{
createSelectorQuery
()
.
select
(
`#
${
domRef
.
current
.
uid
}
`
)
...
...
@@ -48,11 +50,16 @@ function UserGuideView<T extends ComponentType<any> = typeof View> (props: UserG
setIsActive
(
true
)
})
})
},
0
)
},
delay
)
}
else
{
setIsActive
(
false
)
}
},
[
isActive
])
return
()
=>
{
if
(
timer
)
{
clearTimeout
(
timer
)
}
}
},
[
isActive
,
delay
])
const
domRef
=
useRef
<
any
>
()
...
...
src/pages/battles/index.tsx
View file @
05d10e19
import
{
useMemo
}
from
'react'
import
{
getMenuButtonBoundingClientRect
,
useDidShow
}
from
'@tarojs/taro'
import
{
getMenuButtonBoundingClientRect
,
useDidShow
,
navigateBack
}
from
'@tarojs/taro'
import
{
View
,
Text
,
Image
}
from
'@tarojs/components'
import
Button
from
'@/components/Button'
import
{
useStoreState
,
useStoreActions
}
from
'@/store/hooks'
...
...
@@ -13,11 +13,17 @@ import styles from './index.module.scss'
const
Battles
=
()
=>
{
const
nav
=
useMemo
(
getMenuButtonBoundingClientRect
,
[])
const
summary
=
useStoreState
((
state
)
=>
state
.
battlesModel
.
summary
)
const
addPkGuideTimes
=
useStoreActions
((
state
)
=>
state
.
guideModel
.
addPkGuideTimes
)
const
fetchUserSummary
=
useStoreActions
(
(
actions
)
=>
actions
.
battlesModel
.
fetchUserSummary
)
const
handleClick
=
()
=>
{
addPkGuideTimes
()
navigateBack
()
}
useDidShow
(()
=>
{
fetchUserSummary
({})
})
...
...
@@ -56,6 +62,7 @@ const Battles = () => {
<
Button
size=
"large"
image=
{
styles
.
bottomButton
}
onClick=
{
handleClick
}
hoverImage=
{
styles
.
bottomHoverButton
}
>
<
Image
src=
{
assets
[
'pk.png'
].
u
}
className=
{
styles
.
bottomText
}
/>
...
...
src/pages/game/play/assets/math-symbol/dot.png
0 → 100644
View file @
05d10e19
519 Bytes
src/pages/game/play/components/count-up.tsx
View file @
05d10e19
...
...
@@ -49,26 +49,26 @@ const CountUp = (props: CountUpProps) => {
})
})
const
roleStyle
=
useMemo
(()
=>
{
const
getTime
=
()
=>
{
const
timeRest
=
useMemo
(()
=>
{
if
(
isBattle
)
{
return
pkDetail
?.
resultTime
??
stageDetail
.
bTime
}
return
stageDetail
.
bTime
}
},
[
stageDetail
,
isBattle
,
pkDetail
])
const
roleStyle
=
useMemo
(()
=>
{
if
(
isStarted
)
{
return
{
transform
:
'translateX(100%)'
,
transition
:
`transform
${
getTime
()
}
s linear`
,
transition
:
`transform
${
timeRest
}
s linear`
,
}
}
return
{
transform
:
'translateX(0)'
,
transition
:
`transform
${
getTime
()
}
s linear`
,
transition
:
`transform
${
timeRest
}
s linear`
,
}
},
[
stageDetail
,
isStarted
,
isBattle
,
pkDetail
])
},
[
isStarted
,
timeRest
])
const
processInnerStyle
=
useMemo
(()
=>
{
if
(
isSubmit
)
{
...
...
@@ -120,7 +120,7 @@ const CountUp = (props: CountUpProps) => {
<
count
-
up
-
time
exceedTime=
{
10
}
onExceed=
{
handleExceed
}
maxValue=
{
stageDetail
.
bTime
}
maxValue=
{
timeRest
}
startValue=
{
startTick
}
isDown=
{
isOneStop
}
onTimeup=
{
handleTimeUp
}
...
...
src/pages/game/play/components/math-symbol.module.scss
View file @
05d10e19
...
...
@@ -17,4 +17,9 @@
width
:
30px
;
height
:
30px
;
}
&
.is_dot
{
width
:
24px
;
height
:
112px
;
}
}
src/pages/game/play/components/math-symbol.tsx
View file @
05d10e19
...
...
@@ -15,10 +15,13 @@ const SymbolMap = {
'<'
:
require
(
'../assets/math-symbol/less.png'
),
'='
:
require
(
'../assets/math-symbol/equal.png'
),
'=2'
:
require
(
'../assets/math-symbol/equal-2.png'
),
'.'
:
require
(
'../assets/math-symbol/dot.png'
),
ADD
:
require
(
'../assets/math-symbol/add.png'
),
SUB
:
require
(
'../assets/math-symbol/minus.png'
),
}
as
const
type
MathSymbolProps
=
{
value
:
'*'
|
'+'
|
'-'
|
'/'
|
'%'
|
'>'
|
'<'
|
'='
|
'=2'
;
value
:
'*'
|
'+'
|
'-'
|
'/'
|
'%'
|
'>'
|
'<'
|
'='
|
'=2'
|
'.'
|
'ADD'
|
'SUB'
;
size
?:
'small'
|
'big'
;
}
...
...
@@ -37,7 +40,8 @@ const MathSymbol = ({ value, size = 'big' }: MathSymbolProps) => {
className=
{
classNames
(
styles
.
symbol
,
{
[
styles
.
is_remaind
]:
value
===
'%'
,
[
styles
.
is_pair
]:
isPair
,
[
styles
.
is_small
]:
size
===
'small'
[
styles
.
is_small
]:
size
===
'small'
,
[
styles
.
is_dot
]:
value
===
'.'
})
}
/>
)
...
...
src/pages/game/play/components/question/index.tsx
View file @
05d10e19
...
...
@@ -2,13 +2,17 @@ import { View } from '@tarojs/components'
import
QuestionBlank
from
'./question-blank'
import
QuestionSelection
from
'./question-selection'
import
QuestionVerticalDivision
from
'./question-vertical-division'
import
QuestionVerticalAddMinus
from
'./question-vertical-add-minus'
import
{
type
QuestionType
,
isBlankQuestion
,
isSelectionQuestion
,
isVerticalDivisionQuestion
isVerticalDivisionQuestion
,
isVerticalAddMinusQuestion
,
isFractionAddMinusQuestion
}
from
'../../types'
import
QuestionFractionAddMinus
from
'./question-fraction-add-minus'
type
QuestionProps
=
{
question
:
QuestionType
...
...
@@ -35,6 +39,14 @@ const Question = (props: QuestionProps) => {
)
}
if
(
isVerticalAddMinusQuestion
(
question
))
{
return
<
QuestionVerticalAddMinus
question=
{
question
}
/>
}
if
(
isFractionAddMinusQuestion
(
question
))
{
return
<
QuestionFractionAddMinus
question=
{
question
}
/>
}
return
(
<
View
>
not supported question type
</
View
>
)
...
...
src/pages/game/play/components/question/question-fraction-add-minus.module.scss
0 → 100644
View file @
05d10e19
.content
{
display
:
flex
;
flex-direction
:
column
;
align-items
:
center
;
min-height
:
100%
;
}
.center
{
display
:
flex
;
align-items
:
center
;
justify-content
:
center
;
gap
:
16px
;
}
.item_val
{
min-width
:
112px
;
height
:
112px
;
display
:
flex
;
align-items
:
center
;
justify-content
:
center
;
font-size
:
80px
;
font-family
:
HelveticaNeue-Medium
,
HelveticaNeue
;
font-weight
:
500
;
color
:
#465164
;
line-height
:
98px
;
}
.item_center
{
height
:
8px
;
background
:
rgba
(
23
,
134
,
247
,
0
.9
);
background-color
:
rgba
(
23
,
134
,
247
,
0
.9
);
border-radius
:
4px
;
margin
:
16px
10px
;
}
.gap
{
flex
:
2
;
}
.gap_2
{
flex
:
3
;
}
src/pages/game/play/components/question/question-fraction-add-minus.tsx
0 → 100644
View file @
05d10e19
/** 填空题 */
import
{
View
}
from
'@tarojs/components'
import
{
useMemo
}
from
'react'
import
classNames
from
'classnames'
import
htmlParser
from
'html-parse-stringify'
import
{
renderRichText
}
from
'./render-tichtext'
import
type
{
FractionAddMinusQuestion
}
from
'../../types'
import
styles
from
'./question-fraction-add-minus.module.scss'
import
MathSymbol
from
'../math-symbol'
type
QuestionFractionAddMinusProps
=
{
question
:
FractionAddMinusQuestion
}
type
FractionItemProps
=
{
top
:
string
;
bottom
:
string
;
}
const
FractionItem
=
({
top
,
bottom
}:
FractionItemProps
)
=>
{
const
topTree
=
useMemo
(()
=>
{
return
htmlParser
.
parse
(
top
)
},
[
top
])
const
bottomTree
=
useMemo
(()
=>
htmlParser
.
parse
(
bottom
),
[
bottom
])
return
(
<
View
className=
{
styles
.
item_wrap
}
>
<
View
className=
{
styles
.
item_val
}
>
{
topTree
.
map
(
renderRichText
)
}
</
View
>
<
View
className=
{
styles
.
item_center
}
></
View
>
<
View
className=
{
styles
.
item_val
}
>
{
bottomTree
.
map
(
renderRichText
)
}
</
View
>
</
View
>
)
}
const
QuestionFractionAddMinus
=
(
props
:
QuestionFractionAddMinusProps
)
=>
{
const
{
question
}
=
props
const
sign
=
question
.
questionItems
[
6
].
contentText
return
(
<
View
className=
{
classNames
(
styles
.
content
)
}
>
<
View
className=
{
styles
.
gap
}
></
View
>
<
View
className=
{
styles
.
center
}
>
<
FractionItem
top=
{
question
.
questionItems
[
1
].
contentText
}
bottom=
{
question
.
questionItems
[
0
].
contentText
}
/>
<
MathSymbol
value=
{
sign
}
></
MathSymbol
>
<
FractionItem
top=
{
question
.
questionItems
[
3
].
contentText
}
bottom=
{
question
.
questionItems
[
2
].
contentText
}
/>
<
MathSymbol
value=
"="
></
MathSymbol
>
<
FractionItem
top=
{
question
.
questionItems
[
5
].
contentText
}
bottom=
{
question
.
questionItems
[
4
].
contentText
}
/>
</
View
>
<
View
className=
{
styles
.
gap_2
}
></
View
>
</
View
>
)
}
export
default
QuestionFractionAddMinus
src/pages/game/play/components/question/question-vertical-add-minus.module.scss
0 → 100644
View file @
05d10e19
.content
{
display
:
flex
;
flex-direction
:
column
;
align-items
:
center
;
padding-right
:
60px
;
min-height
:
100%
;
}
.gap
{
flex
:
2
;
}
.gap_2
{
flex
:
3
;
}
.question_content
{
display
:
flex
;
align-items
:
center
;
justify-content
:
center
;
}
.item_cell
{
min-width
:
112px
;
height
:
112px
;
display
:
flex
;
align-items
:
center
;
justify-content
:
center
;
font-size
:
80px
;
font-weight
:
500
;
color
:
#465164
;
line-height
:
98px
;
}
.sign_cell
{
display
:
flex
;
align-items
:
center
;
justify-content
:
center
;
height
:
112px
;
}
.left
{
display
:
flex
;
justify-content
:
flex-end
;
gap
:
10px
;
}
.right
{
display
:
flex
;
justify-content
:
flex-start
;
gap
:
10px
;
}
.split
{
height
:
8px
;
background
:
rgba
(
23
,
134
,
247
,
0
.9
);
margin
:
16px
0
;
}
.center
{
display
:
flex
;
flex-direction
:
column
;
}
.place_holder
{
width
:
24px
;
height
:
112px
;
}
src/pages/game/play/components/question/question-vertical-add-minus.tsx
0 → 100644
View file @
05d10e19
/** 填空题 */
import
{
View
,
Text
}
from
'@tarojs/components'
import
{
Fragment
,
useMemo
}
from
'react'
import
classNames
from
'classnames'
import
htmlParser
,
{
Node
}
from
'html-parse-stringify'
import
type
{
VerticalAddMinusQuestion
}
from
'../../types'
import
styles
from
'./question-vertical-add-minus.module.scss'
import
AnswerBlank
from
'../answer-blank'
import
{
renderRichText
}
from
'./render-tichtext'
import
MathSymbol
from
'../math-symbol'
type
QuestionVerticalAddMinusProps
=
{
question
:
VerticalAddMinusQuestion
}
type
NumberLineProps
=
{
left
:
string
;
}
const
NumberLine
=
(
props
:
NumberLineProps
)
=>
{
return
(
<
View
>
<
View
></
View
>
<
View
></
View
>
</
View
>
)
}
const
genNewNode
=
(
src
:
string
):
Node
[]
=>
{
const
tree
=
htmlParser
.
parse
(
src
)
return
tree
.
reduce
<
Node
[]
>
((
ret
,
item
)
=>
{
if
(
item
.
type
===
'text'
)
{
const
sub
:
Node
[]
=
item
.
content
.
split
(
''
).
filter
(
Boolean
).
map
(
text
=>
({
content
:
text
,
type
:
'text'
}))
ret
=
[...
ret
,
...
sub
]
}
else
{
ret
.
push
(
item
)
}
return
ret
},
[])
}
const
isDotTextNode
=
(
node
:
Node
)
=>
node
.
type
===
'text'
&&
node
.
content
===
'.'
function
computeFinalData
(
top
:
Node
[],
center
:
Node
[],
bottom
:
Node
[])
{
const
topDotIndex
=
top
.
findIndex
(
isDotTextNode
)
const
centerDotIndex
=
center
.
findIndex
(
isDotTextNode
)
const
bottomDotIndex
=
bottom
.
findIndex
(
isDotTextNode
)
const
hasTopDot
=
topDotIndex
!==
-
1
const
hasCenterDot
=
centerDotIndex
!==
-
1
const
hasBottomDot
=
bottomDotIndex
!==
-
1
return
{
left
:
[
{
key
:
1
,
nodes
:
hasTopDot
?
top
.
slice
(
0
,
topDotIndex
)
:
top
},
{
key
:
2
,
nodes
:
hasCenterDot
?
center
.
slice
(
0
,
centerDotIndex
)
:
center
,
hasSign
:
true
},
{
key
:
3
,
nodes
:
[],
isSplit
:
true
},
{
key
:
4
,
nodes
:
hasBottomDot
?
bottom
.
slice
(
0
,
bottomDotIndex
)
:
bottom
},
],
center
:
[
{
key
:
1
,
hasDot
:
hasTopDot
},
{
key
:
2
,
hasDot
:
hasCenterDot
},
{
key
:
3
,
hasDot
:
false
,
isSplit
:
true
},
{
key
:
4
,
hasDot
:
hasBottomDot
},
],
right
:
[
{
key
:
1
,
nodes
:
hasTopDot
?
top
.
slice
(
topDotIndex
+
1
,
top
.
length
)
:
[]
},
{
key
:
2
,
nodes
:
hasCenterDot
?
center
.
slice
(
topDotIndex
+
1
,
center
.
length
)
:
[]
},
{
key
:
3
,
nodes
:
[],
isSplit
:
true
},
{
key
:
4
,
nodes
:
hasBottomDot
?
bottom
.
slice
(
topDotIndex
+
1
,
bottom
.
length
)
:
[]
},
]
}
}
const
QuestionVerticalAddMinus
=
(
props
:
QuestionVerticalAddMinusProps
)
=>
{
const
{
question
}
=
props
const
sign
=
question
.
questionItems
[
3
].
contentText
const
contentTreeInfo
=
useMemo
(()
=>
{
const
top
=
genNewNode
(
question
.
questionItems
[
0
].
contentText
)
const
center
=
genNewNode
(
question
.
questionItems
[
1
].
contentText
)
const
bottom
=
genNewNode
(
question
.
questionItems
[
2
].
contentText
)
return
computeFinalData
(
top
,
center
,
bottom
)
},
[
question
.
questionItems
])
return
(
<
View
className=
{
classNames
(
styles
.
content
)
}
>
<
View
className=
{
styles
.
gap
}
></
View
>
<
View
className=
{
styles
.
question_content
}
>
<
View
>
{
contentTreeInfo
.
left
.
map
(
item
=>
{
if
(
item
.
isSplit
)
{
return
(
<
View
key=
{
item
.
key
}
className=
{
styles
.
split
}
></
View
>
)
}
return
(
<
View
key=
{
item
.
key
}
className=
{
styles
.
left
}
>
{
item
.
hasSign
&&
(
<
View
className=
{
styles
.
sign_cell
}
>
<
MathSymbol
value=
{
sign
}
></
MathSymbol
>
</
View
>
)
}
{
item
.
nodes
.
map
((
node
,
index
)
=>
(
<
View
key=
{
index
}
className=
{
styles
.
item_cell
}
>
{
renderRichText
(
node
)
}
</
View
>
))
}
</
View
>
)
})
}
</
View
>
<
View
className=
{
styles
.
center
}
>
{
contentTreeInfo
.
center
.
map
(
item
=>
{
if
(
item
.
isSplit
)
{
return
(
<
View
key=
{
item
.
key
}
className=
{
styles
.
split
}
></
View
>
)
}
if
(
item
.
hasDot
)
{
return
(
<
MathSymbol
value=
"."
key=
{
item
.
key
}
></
MathSymbol
>
)
}
return
(
<
View
className=
{
styles
.
place_holder
}
key=
{
item
.
key
}
></
View
>
)
})
}
</
View
>
<
View
>
{
contentTreeInfo
.
right
.
map
(
item
=>
{
if
(
item
.
isSplit
)
{
return
(
<
View
key=
{
item
.
key
}
className=
{
styles
.
split
}
></
View
>
)
}
return
(
<
View
key=
{
item
.
key
}
className=
{
styles
.
right
}
>
{
item
.
nodes
.
map
((
node
,
index
)
=>
(
<
View
key=
{
index
}
className=
{
styles
.
item_cell
}
>
{
renderRichText
(
node
)
}
</
View
>
))
}
</
View
>
)
})
}
</
View
>
</
View
>
<
View
className=
{
styles
.
gap_2
}
></
View
>
</
View
>
)
}
export
default
QuestionVerticalAddMinus
src/pages/game/play/model/index.ts
View file @
05d10e19
...
...
@@ -13,6 +13,7 @@ import { palyAudio } from '@/utils/play-audio'
import
audio
from
'@/assets/oss/assets-audio'
import
{
isSelectionQuestion
,
QuestionType
,
// QuestionOption,
}
from
'../types'
import
{
buildCompleteStageParam
,
convertQuestion
,
determinQuestion
,
buildSubmitPkParams
}
from
'./utils'
...
...
src/pages/game/play/types.ts
View file @
05d10e19
...
...
@@ -41,13 +41,41 @@ export interface VerticalDivisionQuestion extends QuestionItem {
questionItems
:
[
RandomQuestionItem
,
RandomQuestionItem
];
}
export
interface
VerticalAddMinusQuestion
extends
QuestionItem
{
questionType
:
'竖式加减法'
;
questionItems
:
[
RandomQuestionItem
,
RandomQuestionItem
,
RandomQuestionItem
,
RandomQuestionSign
];
}
export
interface
FractionAddMinusQuestion
extends
QuestionItem
{
questionType
:
'分数计算'
;
questionItems
:
[
RandomQuestionItem
,
RandomQuestionItem
,
RandomQuestionItem
,
RandomQuestionItem
,
RandomQuestionItem
,
RandomQuestionItem
,
RandomQuestionSign
];
}
/** 乘法 */
export
interface
MultiplicationQuestion
extends
QuestionItem
{
questionType
:
'乘法'
;
questionItems
:
[];
}
export
type
QuestionType
=
BlankQuestion
|
SelectionQuestion
|
VerticalDivisionQuestion
export
type
QuestionType
=
|
BlankQuestion
|
SelectionQuestion
|
VerticalDivisionQuestion
|
VerticalAddMinusQuestion
|
FractionAddMinusQuestion
export
function
isBlankQuestion
(
q
:
QuestionType
):
q
is
BlankQuestion
{
return
q
?.
questionType
===
'填空题'
||
q
?.
questionType
===
'随机填空'
...
...
@@ -61,6 +89,14 @@ export function isVerticalDivisionQuestion (q: QuestionType): q is VerticalDivis
return
q
?.
questionType
===
'竖式除法'
}
export
function
isVerticalAddMinusQuestion
(
q
:
QuestionType
):
q
is
VerticalAddMinusQuestion
{
return
q
?.
questionType
===
'竖式加减法'
}
export
function
isFractionAddMinusQuestion
(
q
:
QuestionType
):
q
is
FractionAddMinusQuestion
{
return
q
?.
questionType
===
'分数计算'
}
export
type
QuestionOption
=
{
index
:
string
;
contentText
:
string
;
...
...
@@ -68,8 +104,13 @@ export type QuestionOption = {
userAnswer
?:
boolean
;
}
export
type
RandomQuestionSign
=
{
contentText
:
'ADD'
|
'SUB'
;
sort
:
number
;
}
export
type
RandomQuestionItem
=
{
contentText
:
'$input'
|
`
${
number
}
`
;
contentText
:
'$input'
|
`
${
number
}
`
|
'ADD'
|
'SUB'
;
sort
:
number
;
}
...
...
@@ -89,3 +130,10 @@ export type RandomQuestionItem = {
<: <MathSymbol value="<" />
比较里面的=: <MathSymbol value="=2" />
*/
/**
* 12.14
* + / -
* 33.23
* 45.37
*/
src/pages/main/main-underground/chapter.tsx
View file @
05d10e19
...
...
@@ -5,12 +5,18 @@ import { useStoreActions, useStoreState } from '@/store/hooks'
import
{
useMemo
}
from
'react'
import
styles
from
'./chapter.module.scss'
import
{
StageStatus
}
from
'./scene/constants'
const
MainHeader
=
()
=>
{
const
nav
=
useMemo
(
getMenuButtonBoundingClientRect
,
[])
const
sys
=
useMemo
(
getSystemInfoSync
,
[])
const
completeAddDeskGuide
=
useStoreActions
(
actions
=>
actions
.
guideModel
.
completeAddDeskGuide
)
const
isAddDeskTopGuideComplete
=
useStoreState
(
state
=>
state
.
guideModel
.
isAddDeskTopGuideComplete
)
const
stageList
=
useStoreState
(
state
=>
state
.
mainModel
.
stageList
)
const
hasPassed
=
useMemo
(()
=>
{
return
stageList
.
findIndex
(
c
=>
c
.
status
===
StageStatus
.
CURRENT
)
>
0
},
[
stageList
])
const
guideStyle
=
useMemo
(()
=>
{
return
{
...
...
@@ -46,11 +52,12 @@ const MainHeader = () => {
</
View
>
</
View
>
)
}
{
hasPassed
&&
(
<
View
className=
{
styles
.
pk
}
onClick=
{
()
=>
navigateTo
({
url
:
'/pages/battles/index'
})
}
>
<
View
className=
{
styles
.
dot
}
></
View
>
<
Image
src=
{
assetsMainNext
[
'pk-btn.png'
].
u
}
className=
{
styles
.
pkIcon
}
></
Image
>
</
View
>
)
}
</
View
>
</>
)
...
...
src/pages/main/main-underground/create-pk.tsx
View file @
05d10e19
...
...
@@ -92,7 +92,7 @@ const CreatePk = (props: CreatePkProps) => {
<>
{
visible
&&
(<
PkGuide
/>)
}
<
View
className=
{
classNames
(
styles
.
close_wrap
,
visible
&&
styles
.
is_show
)
}
style=
{
closeStyle
}
>
<
View
className=
{
styles
.
close
}
on
Click
=
{
closeModal
}
data
-
name=
"关闭发起PK"
>
<
View
className=
{
styles
.
close
}
on
TouchStart
=
{
closeModal
}
data
-
name=
"关闭发起PK"
>
<
Image
src=
{
assetsMainNext
[
'pk-close.png'
].
u
}
className=
{
styles
.
close_icon
}
></
Image
>
</
View
>
</
View
>
...
...
src/pages/main/main-underground/main-component.tsx
View file @
05d10e19
...
...
@@ -38,6 +38,7 @@ const MainPage = () => {
const
updateGroupGuideActive
=
useStoreActions
(
actions
=>
actions
.
guideModel
.
updateGroupGuideActive
)
const
fetchTribeInfo
=
useStoreActions
(
actions
=>
actions
.
groupModel
.
fetchTribeInfo
)
const
userInfo
=
useStoreState
(
state
=>
state
.
userModel
.
userInfo
)
const
showPkGuideFromHis
=
useStoreState
(
state
=>
state
.
guideModel
.
showPkGuideFromHis
)
const
nav
=
useMemo
(
getMenuButtonBoundingClientRect
,
[])
...
...
@@ -93,6 +94,12 @@ const MainPage = () => {
}
},
[
player
,
isFocus
])
useEffect
(()
=>
{
if
(
showPkGuideFromHis
)
{
scrollToCurrent
()
}
},
[
showPkGuideFromHis
,
scrollToCurrent
])
useEffect
(()
=>
{
if
(
isFocus
&&
userInfo
.
city
&&
userInfo
.
grade
)
{
fetchAccount
()
...
...
src/pages/main/main-underground/scene/constants.ts
View file @
05d10e19
...
...
@@ -44,7 +44,7 @@ function stageToStageNext (stageList: Stage[]): {nextList: StageNext[]; showList
const
newList
=
stageList
.
slice
()
.
sort
((
a
,
b
)
=>
(
a
.
part
??
0
)
-
(
b
.
part
??
0
))
.
map
((
c
,
index
)
=>
({
...
c
,
$stageIndex
:
index
}))
.
map
((
c
,
index
)
=>
({
...
c
,
$stageIndex
:
index
,
$lastPassedStage
:
false
}))
const
ret
:
StageNext
[]
=
[]
...
...
@@ -54,7 +54,11 @@ function stageToStageNext (stageList: Stage[]): {nextList: StageNext[]; showList
if
(
currentIndex
===
-
1
)
{
showList
=
newList
}
else
{
showList
=
newList
.
slice
(
0
,
Math
.
max
(
currentIndex
+
3
,
5
))
showList
=
newList
.
slice
(
0
,
Math
.
max
(
currentIndex
+
30
,
5
))
}
/** 设置pk历史页面返回后引导 */
if
(
showList
[
currentIndex
-
1
])
{
showList
[
currentIndex
-
1
].
$lastPassedStage
=
true
}
let
currentPart
...
...
src/pages/main/main-underground/scene/stage.tsx
View file @
05d10e19
...
...
@@ -150,10 +150,15 @@ const StageComp = (props: StageProps) => {
const
pkGuideActive
=
useStoreState
(
state
=>
state
.
guideModel
.
pkGuideActive
)
const
pkGuideStep
=
useStoreState
(
state
=>
state
.
guideModel
.
pkGuideStep
)
const
nextPkGuide
=
useStoreActions
(
state
=>
state
.
guideModel
.
nextPkGuide
)
const
showPkGuideFromHis
=
useStoreState
(
state
=>
state
.
guideModel
.
showPkGuideFromHis
)
const
updateGuideState
=
useStoreActions
(
state
=>
state
.
guideModel
.
updateState
)
const
isPkGuideShow
=
useMemo
(()
=>
{
if
(
stage
.
$lastPassedStage
)
{
return
showPkGuideFromHis
}
return
pkGuideStep
===
2
&&
pkGuideActive
&&
stage
.
$stageIndex
===
1
},
[
pkGuideActive
,
pkGuideStep
,
stage
])
},
[
pkGuideActive
,
pkGuideStep
,
stage
,
showPkGuideFromHis
])
const
handleClick
=
()
=>
{
if
(
stage
.
status
!==
StageStatus
.
DISABLED
||
!
isProduction
)
{
...
...
@@ -171,7 +176,11 @@ const StageComp = (props: StageProps) => {
}
const
handlePk
=
()
=>
{
if
(
showPkGuideFromHis
)
{
updateGuideState
({
showPkGuideFromHis
:
false
})
}
else
{
nextPkGuide
()
}
handleLongPress
()
}
...
...
@@ -220,6 +229,7 @@ const StageComp = (props: StageProps) => {
isActive=
{
isPkGuideShow
}
wrapClass=
{
styles
.
pk_guide_wrap
}
verticalPadding=
{
0
}
delay=
{
showPkGuideFromHis
?
300
:
0
}
horizonPadding=
{
0
}
guideViewId=
"first_pk_guide"
guideContent=
{
(
...
...
src/store/modules/guide.ts
View file @
05d10e19
...
...
@@ -36,6 +36,8 @@ export interface GuideModel {
/** 完成pk引导 */
isPkGuideComplete
:
boolean
|
null
;
pkGuideTimes
:
number
|
null
;
pkGuideStep
:
number
;
storeGuideStep
:
number
;
groupGuideStep
:
number
;
...
...
@@ -43,6 +45,8 @@ export interface GuideModel {
revceiPoint
:
Thunk
<
GuideModel
,
void
,
void
,
AppStoreModel
>
;
nextGroupGuide
:
Action
<
GuideModel
>
;
nextPkGuide
:
Action
<
GuideModel
>
;
addPkGuideTimes
:
Action
<
GuideModel
,
void
>
;
showPkGuideFromHis
:
boolean
;
pointToCardNum
:
number
;
completeAddDeskGuide
:
Thunk
<
GuideModel
,
void
,
void
,
AppStoreModel
>
;
...
...
@@ -63,6 +67,8 @@ const guideModel: GuideModel = {
storeGuideStep
:
0
,
pointToCardNum
:
0
,
pkGuideStep
:
0
,
showPkGuideFromHis
:
false
,
pkGuideTimes
:
getStorage
(
StorageKeys
.
pkGuideTimes
),
isAddDeskTopGuideComplete
:
getStorage
(
StorageKeys
.
isAddDeskTopGuideComplete
),
isStoreGuideComplete
:
getStorage
(
StorageKeys
.
isStoreGuideComplete
),
...
...
@@ -75,6 +81,21 @@ const guideModel: GuideModel = {
state
.
pkGuideStep
+=
1
}),
addPkGuideTimes
:
action
((
state
)
=>
{
let
next
if
(
state
.
pkGuideTimes
!==
null
)
{
if
(
state
.
pkGuideTimes
>=
3
)
{
return
}
next
=
state
.
pkGuideTimes
+
1
}
else
{
next
=
1
}
state
.
pkGuideTimes
=
next
state
.
showPkGuideFromHis
=
true
updateStorage
(
StorageKeys
.
pkGuideTimes
,
next
)
}),
updatePkGuideActive
:
action
((
state
,
payload
)
=>
{
state
.
pkGuideActive
=
payload
}),
...
...
src/utils/storage.ts
View file @
05d10e19
...
...
@@ -34,6 +34,9 @@ export enum StorageKeys {
/** pk引导 */
isPkGuideComplete
,
/** pk历史点击发起pk后引导次数 */
pkGuideTimes
,
/** 用于强制用户走静默登录接口 */
refreshToken
=
100
,
}
...
...
@@ -51,6 +54,7 @@ type Storage = {
[
StorageKeys
.
isStoreGuideComplete
]:
boolean
|
null
;
[
StorageKeys
.
isAddDeskTopGuideComplete
]:
boolean
|
null
;
[
StorageKeys
.
isPkGuideComplete
]:
boolean
|
null
;
[
StorageKeys
.
pkGuideTimes
]:
number
|
null
;
[
StorageKeys
.
refreshToken
]:
string
|
undefined
;
}
...
...
@@ -76,6 +80,7 @@ export function reloadStore () {
StorageKeys
.
isStoreGuideComplete
,
StorageKeys
.
isAddDeskTopGuideComplete
,
StorageKeys
.
isPkGuideComplete
,
StorageKeys
.
pkGuideTimes
,
StorageKeys
.
refreshToken
,
].
forEach
((
element
)
=>
{
updateStorage
(
element
,
Taro
.
getStorageSync
(
`
${
storagePrefix
}${
element
}
`
)
??
null
)
...
...
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