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
167eadb6
Commit
167eadb6
authored
Apr 20, 2023
by
hewenhao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 添加首页引导
parent
4bed47f5
Hide whitespace changes
Inline
Side-by-side
Showing
30 changed files
with
865 additions
and
50 deletions
+865
-50
app.config.ts.tpl
scripts/app.config.ts.tpl
+1
-0
auth.ts
src/api/auth.ts
+9
-3
index.tsx
src/components/UserGuideView/index.tsx
+11
-9
complete-head.tsx
src/pages/game/complete/components/complete-head.tsx
+10
-2
index.tsx
src/pages/game/play/components/question/index.tsx
+1
-1
index.ts
src/pages/game/play/model/index.ts
+10
-5
utils.ts
src/pages/game/play/model/utils.ts
+6
-1
answer-blank.module.scss
src/pages/game/wrong/components/answer-blank.module.scss
+43
-0
answer-blank.tsx
src/pages/game/wrong/components/answer-blank.tsx
+37
-0
index.tsx
src/pages/game/wrong/components/question/index.tsx
+43
-0
question-blank.module.scss
...game/wrong/components/question/question-blank.module.scss
+26
-0
question-blank.tsx
src/pages/game/wrong/components/question/question-blank.tsx
+33
-0
question-selection.module.scss
.../wrong/components/question/question-selection.module.scss
+100
-0
question-selection.tsx
...ges/game/wrong/components/question/question-selection.tsx
+67
-0
question-vertical-division.module.scss
...omponents/question/question-vertical-division.module.scss
+88
-0
question-vertical-division.tsx
.../wrong/components/question/question-vertical-division.tsx
+50
-0
render-tichtext.tsx
src/pages/game/wrong/components/question/render-tichtext.tsx
+115
-0
rich-text.module.scss
...ages/game/wrong/components/question/rich-text.module.scss
+66
-0
index.config.ts
src/pages/game/wrong/index.config.ts
+5
-0
index.tsx
src/pages/game/wrong/index.tsx
+11
-1
main-component.tsx
src/pages/main/components/main-component.tsx
+1
-2
stage.tsx
src/pages/main/components/scene/stage.tsx
+9
-2
index.tsx
src/pages/main/components/tutorial/index.tsx
+37
-11
modal-area.tsx
src/pages/main/components/tutorial/modal-area.tsx
+10
-3
modal-grade.tsx
src/pages/main/components/tutorial/modal-grade.tsx
+7
-4
shared.module.scss
src/pages/main/components/tutorial/shared.module.scss
+5
-0
model.ts
src/pages/main/model.ts
+26
-1
user.ts
src/store/modules/user.ts
+30
-3
types.ts
src/types.ts
+1
-0
storage.ts
src/utils/storage.ts
+7
-2
No files found.
scripts/app.config.ts.tpl
View file @
167eadb6
...
@@ -11,6 +11,7 @@ export default {
...
@@ -11,6 +11,7 @@ export default {
'pages/group/index',
'pages/group/index',
'pages/market/index',
'pages/market/index',
'pages/game/play/index',
'pages/game/play/index',
'pages/game/wrong/index',
'pages/game/complete/index',
'pages/game/complete/index',
],
],
subPackages: {
{
packages
}
},
subPackages: {
{
packages
}
},
...
...
src/api/auth.ts
View file @
167eadb6
...
@@ -39,12 +39,18 @@ export function getAccountInfo () {
...
@@ -39,12 +39,18 @@ export function getAccountInfo () {
}))
}))
}
}
export
function
updateUserInfo
(
nickName
:
string
)
{
export
type
UpdateUserInfoIn
=
{
return
requestAfterSilentLogin
<
void
,
{
nickName
:
string
;
userId
?:
number
;
}
>
(
userInfo
=>
({
nickName
?:
string
;
city
?:
string
;
grade
?:
string
;
}
export
function
updateUserInfo
(
opts
:
UpdateUserInfoIn
)
{
return
requestAfterSilentLogin
<
void
,
UpdateUserInfoIn
&
{
userId
?:
number
;
}
>
(
userInfo
=>
({
method
:
'POST'
,
method
:
'POST'
,
url
:
'/service-idea/stage/user/updateUserInfo'
,
url
:
'/service-idea/stage/user/updateUserInfo'
,
data
:
{
data
:
{
nickName
,
...
opts
,
userId
:
userInfo
?.
userId
userId
:
userInfo
?.
userId
}
}
}))
}))
...
...
src/components/UserGuideView/index.tsx
View file @
167eadb6
import
{
View
,
RootPortal
}
from
'@tarojs/components'
import
{
View
,
RootPortal
}
from
'@tarojs/components'
import
{
useState
,
useMemo
,
useRef
,
useEffect
,
type
ReactNode
,
type
ComponentType
}
from
'react'
import
{
useState
,
useMemo
,
useRef
,
useEffect
,
type
ReactNode
,
type
ComponentType
}
from
'react'
import
{
createSelectorQuery
,
usePageScroll
}
from
'@tarojs/taro'
import
{
createSelectorQuery
,
usePageScroll
,
nextTick
}
from
'@tarojs/taro'
import
classNames
from
'classnames'
import
classNames
from
'classnames'
import
styles
from
'./index.module.scss'
import
styles
from
'./index.module.scss'
...
@@ -32,14 +32,16 @@ function UserGuideView<T extends ComponentType<any> = typeof View> (props: UserG
...
@@ -32,14 +32,16 @@ function UserGuideView<T extends ComponentType<any> = typeof View> (props: UserG
if
(
isActive
)
{
if
(
isActive
)
{
console
.
log
(
domRef
.
current
)
console
.
log
(
domRef
.
current
)
setTimeout
(()
=>
{
setTimeout
(()
=>
{
createSelectorQuery
()
nextTick
(()
=>
{
.
select
(
`#
${
domRef
.
current
.
uid
}
`
)
createSelectorQuery
()
.
boundingClientRect
().
exec
(([
_rect
])
=>
{
.
select
(
`#
${
domRef
.
current
.
uid
}
`
)
console
.
log
(
_rect
)
.
boundingClientRect
().
exec
(([
_rect
])
=>
{
setRect
({
...
_rect
,
top
:
_rect
.
top
+
scrollRef
.
current
})
console
.
log
(
_rect
)
setIsActive
(
true
)
setRect
({
...
_rect
,
top
:
_rect
.
top
+
scrollRef
.
current
})
})
setIsActive
(
true
)
},
1000
)
})
})
},
0
)
}
else
{
}
else
{
setIsActive
(
false
)
setIsActive
(
false
)
}
}
...
...
src/pages/game/complete/components/complete-head.tsx
View file @
167eadb6
import
{
View
,
Image
}
from
'@tarojs/components'
import
{
View
,
Image
}
from
'@tarojs/components'
import
{
useMemo
,
useEffect
}
from
'react'
import
{
useMemo
,
useEffect
}
from
'react'
import
{
getMenuButtonBoundingClientRect
}
from
'@tarojs/taro'
import
{
getMenuButtonBoundingClientRect
,
navigateTo
}
from
'@tarojs/taro'
import
classNames
from
'classnames'
import
classNames
from
'classnames'
import
assets
from
'@/assets/oss/assets-complete'
import
assets
from
'@/assets/oss/assets-complete'
import
{
useFormatTick
}
from
'@/hooks/use-format-tick'
import
{
useFormatTick
}
from
'@/hooks/use-format-tick'
...
@@ -141,6 +141,14 @@ const GameCompleteHead = () => {
...
@@ -141,6 +141,14 @@ const GameCompleteHead = () => {
}
}
},
[
nav
])
},
[
nav
])
const
goWrong
=
()
=>
{
if
(
gameResult
&&
gameResult
.
errNum
>
0
)
{
navigateTo
({
url
:
'/pages/game/wrong/index'
})
}
}
if
(
!
gameResult
)
{
if
(
!
gameResult
)
{
return
null
return
null
}
}
...
@@ -155,7 +163,7 @@ const GameCompleteHead = () => {
...
@@ -155,7 +163,7 @@ const GameCompleteHead = () => {
<
View
className=
{
styles
.
item_text
}
>
+
{
bonus
}
</
View
>
<
View
className=
{
styles
.
item_text
}
>
+
{
bonus
}
</
View
>
</
View
>
</
View
>
{
!
isOneStop
&&
(
{
!
isOneStop
&&
(
<
View
className=
{
styles
.
item
}
>
<
View
className=
{
styles
.
item
}
onClick=
{
goWrong
}
>
<
Image
src=
{
require
(
'../assets/right-count.png'
)
}
className=
{
styles
.
icon
}
></
Image
>
<
Image
src=
{
require
(
'../assets/right-count.png'
)
}
className=
{
styles
.
icon
}
></
Image
>
<
View
className=
{
classNames
(
styles
.
item_text
,
gameResult
.
errNum
>
0
&&
styles
.
err
)
}
>
{
gameResult
.
errNum
===
0
?
'全对'
:
`错${gameResult.errNum}题`
}
</
View
>
<
View
className=
{
classNames
(
styles
.
item_text
,
gameResult
.
errNum
>
0
&&
styles
.
err
)
}
>
{
gameResult
.
errNum
===
0
?
'全对'
:
`错${gameResult.errNum}题`
}
</
View
>
</
View
>
</
View
>
...
...
src/pages/game/play/components/question/index.tsx
View file @
167eadb6
...
@@ -36,7 +36,7 @@ const Question = (props: QuestionProps) => {
...
@@ -36,7 +36,7 @@ const Question = (props: QuestionProps) => {
}
}
return
(
return
(
<
View
>
234
</
View
>
<
View
>
not supported question type
</
View
>
)
)
}
}
...
...
src/pages/game/play/model/index.ts
View file @
167eadb6
...
@@ -37,6 +37,8 @@ const startCounter = () => getCounter()?.start()
...
@@ -37,6 +37,8 @@ const startCounter = () => getCounter()?.start()
interface
GameModelState
{
interface
GameModelState
{
/** 题目列表 */
/** 题目列表 */
questionList
:
QuestionType
[];
questionList
:
QuestionType
[];
/** 错题列表 */
errList
:
QuestionType
[];
stageDetailPre
:
StageDetail
|
null
;
stageDetailPre
:
StageDetail
|
null
;
stageDetail
:
StageDetail
|
null
;
stageDetail
:
StageDetail
|
null
;
gameResult
:
CompleteStageDetail
|
null
;
gameResult
:
CompleteStageDetail
|
null
;
...
@@ -90,6 +92,7 @@ export interface GameModel extends GameModelState {
...
@@ -90,6 +92,7 @@ export interface GameModel extends GameModelState {
const
gameModel
:
GameModel
=
{
const
gameModel
:
GameModel
=
{
counterId
:
COUNTER_ID
,
counterId
:
COUNTER_ID
,
questionList
:
[],
questionList
:
[],
errList
:
[{
questionType
:
'随机填空'
,
contentText
:
'9<MathSymbol value="*" />2<MathSymbol value="=" /><AnswerBlank index="0" />'
,
simpleType
:
true
,
questionItems
:
[{
contentText
:
'9'
,
sort
:
0
},
{
contentText
:
'2'
,
sort
:
1
},
{
contentText
:
'18'
,
sort
:
2
}],
answers
:
[{
contentText
:
'18'
,
sort
:
0
,
userAnswer
:
'44'
}],
options
:
null
,
userAnswers
:
null
,
sort
:
null
},
{
questionType
:
'随机填空'
,
contentText
:
'7<MathSymbol value="*" />9<MathSymbol value="=" /><AnswerBlank index="0" />'
,
simpleType
:
true
,
questionItems
:
[{
contentText
:
'7'
,
sort
:
0
},
{
contentText
:
'9'
,
sort
:
1
},
{
contentText
:
'63'
,
sort
:
2
}],
answers
:
[{
contentText
:
'63'
,
sort
:
0
,
userAnswer
:
'44'
}],
options
:
null
,
userAnswers
:
null
,
sort
:
null
},
{
questionType
:
'随机填空'
,
contentText
:
'7<MathSymbol value="*" />1<MathSymbol value="=" /><AnswerBlank index="0" />'
,
simpleType
:
true
,
questionItems
:
[{
contentText
:
'7'
,
sort
:
0
},
{
contentText
:
'1'
,
sort
:
1
},
{
contentText
:
'7'
,
sort
:
2
}],
answers
:
[{
contentText
:
'7'
,
sort
:
0
,
userAnswer
:
'44'
}],
options
:
null
,
userAnswers
:
null
,
sort
:
null
},
{
questionType
:
'随机填空'
,
contentText
:
'7<MathSymbol value="*" />6<MathSymbol value="=" /><AnswerBlank index="0" />'
,
simpleType
:
true
,
questionItems
:
[{
contentText
:
'7'
,
sort
:
0
},
{
contentText
:
'6'
,
sort
:
1
},
{
contentText
:
'42'
,
sort
:
2
}],
answers
:
[{
contentText
:
'42'
,
sort
:
0
,
userAnswer
:
'44'
}],
options
:
null
,
userAnswers
:
null
,
sort
:
null
},
{
questionType
:
'随机填空'
,
contentText
:
'7<MathSymbol value="*" />7<MathSymbol value="=" /><AnswerBlank index="0" />'
,
simpleType
:
true
,
questionItems
:
[{
contentText
:
'7'
,
sort
:
0
},
{
contentText
:
'7'
,
sort
:
1
},
{
contentText
:
'49'
,
sort
:
2
}],
answers
:
[{
contentText
:
'49'
,
sort
:
0
,
userAnswer
:
'44'
}],
options
:
null
,
userAnswers
:
null
,
sort
:
null
},
{
questionType
:
'随机填空'
,
contentText
:
'5<MathSymbol value="*" />8<MathSymbol value="=" /><AnswerBlank index="0" />'
,
simpleType
:
true
,
questionItems
:
[{
contentText
:
'5'
,
sort
:
0
},
{
contentText
:
'8'
,
sort
:
1
},
{
contentText
:
'40'
,
sort
:
2
}],
answers
:
[{
contentText
:
'40'
,
sort
:
0
,
userAnswer
:
'44'
}],
options
:
null
,
userAnswers
:
null
,
sort
:
null
},
{
questionType
:
'随机填空'
,
contentText
:
'4<MathSymbol value="*" />4<MathSymbol value="=" /><AnswerBlank index="0" />'
,
simpleType
:
true
,
questionItems
:
[{
contentText
:
'4'
,
sort
:
0
},
{
contentText
:
'4'
,
sort
:
1
},
{
contentText
:
'16'
,
sort
:
2
}],
answers
:
[{
contentText
:
'16'
,
sort
:
0
,
userAnswer
:
'44'
}],
options
:
null
,
userAnswers
:
null
,
sort
:
null
},
{
questionType
:
'随机填空'
,
contentText
:
'8<MathSymbol value="*" />6<MathSymbol value="=" /><AnswerBlank index="0" />'
,
simpleType
:
true
,
questionItems
:
[{
contentText
:
'8'
,
sort
:
0
},
{
contentText
:
'6'
,
sort
:
1
},
{
contentText
:
'48'
,
sort
:
2
}],
answers
:
[{
contentText
:
'48'
,
sort
:
0
,
userAnswer
:
'44'
}],
options
:
null
,
userAnswers
:
null
,
sort
:
null
},
{
questionType
:
'随机填空'
,
contentText
:
'4<MathSymbol value="*" />1<MathSymbol value="=" /><AnswerBlank index="0" />'
,
simpleType
:
true
,
questionItems
:
[{
contentText
:
'4'
,
sort
:
0
},
{
contentText
:
'1'
,
sort
:
1
},
{
contentText
:
'4'
,
sort
:
2
}],
answers
:
[{
contentText
:
'4'
,
sort
:
0
,
userAnswer
:
'44'
}],
options
:
null
,
userAnswers
:
null
,
sort
:
null
},
{
questionType
:
'随机填空'
,
contentText
:
'7<MathSymbol value="*" />4<MathSymbol value="=" /><AnswerBlank index="0" />'
,
simpleType
:
true
,
questionItems
:
[{
contentText
:
'7'
,
sort
:
0
},
{
contentText
:
'4'
,
sort
:
1
},
{
contentText
:
'28'
,
sort
:
2
}],
answers
:
[{
contentText
:
'28'
,
sort
:
0
,
userAnswer
:
'44'
}],
options
:
null
,
userAnswers
:
null
,
sort
:
null
},
{
questionType
:
'随机填空'
,
contentText
:
'9<MathSymbol value="*" />5<MathSymbol value="=" /><AnswerBlank index="0" />'
,
simpleType
:
true
,
questionItems
:
[{
contentText
:
'9'
,
sort
:
0
},
{
contentText
:
'5'
,
sort
:
1
},
{
contentText
:
'45'
,
sort
:
2
}],
answers
:
[{
contentText
:
'45'
,
sort
:
0
,
userAnswer
:
'44'
}],
options
:
null
,
userAnswers
:
null
,
sort
:
null
},
{
questionType
:
'随机填空'
,
contentText
:
'2<MathSymbol value="*" />8<MathSymbol value="=" /><AnswerBlank index="0" />'
,
simpleType
:
true
,
questionItems
:
[{
contentText
:
'2'
,
sort
:
0
},
{
contentText
:
'8'
,
sort
:
1
},
{
contentText
:
'16'
,
sort
:
2
}],
answers
:
[{
contentText
:
'16'
,
sort
:
0
,
userAnswer
:
'44'
}],
options
:
null
,
userAnswers
:
null
,
sort
:
null
},
{
questionType
:
'随机填空'
,
contentText
:
'9<MathSymbol value="*" />3<MathSymbol value="=" /><AnswerBlank index="0" />'
,
simpleType
:
true
,
questionItems
:
[{
contentText
:
'9'
,
sort
:
0
},
{
contentText
:
'3'
,
sort
:
1
},
{
contentText
:
'27'
,
sort
:
2
}],
answers
:
[{
contentText
:
'27'
,
sort
:
0
,
userAnswer
:
'44'
}],
options
:
null
,
userAnswers
:
null
,
sort
:
null
},
{
questionType
:
'随机填空'
,
contentText
:
'7<MathSymbol value="*" />2<MathSymbol value="=" /><AnswerBlank index="0" />'
,
simpleType
:
true
,
questionItems
:
[{
contentText
:
'7'
,
sort
:
0
},
{
contentText
:
'2'
,
sort
:
1
},
{
contentText
:
'14'
,
sort
:
2
}],
answers
:
[{
contentText
:
'14'
,
sort
:
0
,
userAnswer
:
'44'
}],
options
:
null
,
userAnswers
:
null
,
sort
:
null
},
{
questionType
:
'随机填空'
,
contentText
:
'2<MathSymbol value="*" />4<MathSymbol value="=" /><AnswerBlank index="0" />'
,
simpleType
:
true
,
questionItems
:
[{
contentText
:
'2'
,
sort
:
0
},
{
contentText
:
'4'
,
sort
:
1
},
{
contentText
:
'8'
,
sort
:
2
}],
answers
:
[{
contentText
:
'8'
,
sort
:
0
,
userAnswer
:
'44'
}],
options
:
null
,
userAnswers
:
null
,
sort
:
null
}]
as
unknown
as
QuestionType
[],
gameResult
:
null
,
gameResult
:
null
,
bornTimes
:
3
,
bornTimes
:
3
,
modalContinueVisible
:
false
,
modalContinueVisible
:
false
,
...
@@ -270,6 +273,7 @@ const gameModel: GameModel = {
...
@@ -270,6 +273,7 @@ const gameModel: GameModel = {
questionList
:
questionList
.
map
(
convertQuestion
),
questionList
:
questionList
.
map
(
convertQuestion
),
currentInputIndex
:
0
,
currentInputIndex
:
0
,
currentQuestionIndex
:
0
,
currentQuestionIndex
:
0
,
errList
:
[],
modalContinueVisible
:
false
,
modalContinueVisible
:
false
,
bornTimes
:
3
,
bornTimes
:
3
,
gameStartTime
:
Date
.
now
(),
gameStartTime
:
Date
.
now
(),
...
@@ -302,14 +306,15 @@ const gameModel: GameModel = {
...
@@ -302,14 +306,15 @@ const gameModel: GameModel = {
actions
.
updateState
({
isSubmit
:
true
})
actions
.
updateState
({
isSubmit
:
true
})
stopCounter
()
stopCounter
()
const
{
questionList
,
stageDetail
}
=
helpers
.
getState
()
const
{
questionList
,
stageDetail
}
=
helpers
.
getState
()
const
params
=
buildCompleteStageParam
(
questionList
,
stageDetail
!
,
getCounter
()?.
getCount
()
??
0
)
const
{
errList
,
...
rest
}
=
buildCompleteStageParam
(
questionList
,
stageDetail
!
,
getCounter
()?.
getCount
()
??
0
)
const
{
data
:
gameResult
}
=
await
completeStage
(
params
)
const
{
data
:
gameResult
}
=
await
completeStage
(
rest
)
actions
.
updateState
({
actions
.
updateState
({
errList
,
gameResult
:
{
gameResult
:
{
...
gameResult
,
...
gameResult
,
isTimeout
:
params
.
isTimeout
,
isTimeout
:
rest
.
isTimeout
,
errNum
:
params
.
num
-
params
.
correctNum
,
errNum
:
rest
.
num
-
rest
.
correctNum
,
levelTime
:
params
.
levelTime
levelTime
:
rest
.
levelTime
}
}
})
})
hideLoading
()
hideLoading
()
...
...
src/pages/game/play/model/utils.ts
View file @
167eadb6
...
@@ -39,7 +39,11 @@ export function convertQuestion (question: QuestionType): QuestionType {
...
@@ -39,7 +39,11 @@ export function convertQuestion (question: QuestionType): QuestionType {
return
question
return
question
}
}
export
function
buildCompleteStageParam
(
questionList
:
QuestionType
[],
stageDetail
:
StageDetail
,
resultTime
:
number
):
CompleteStageParam
{
type
BuildParamsOut
=
CompleteStageParam
&
{
errList
:
QuestionType
[]
}
export
function
buildCompleteStageParam
(
questionList
:
QuestionType
[],
stageDetail
:
StageDetail
,
resultTime
:
number
):
BuildParamsOut
{
const
wrongList
=
questionList
.
filter
(
c
=>
!
determinQuestion
(
c
))
const
wrongList
=
questionList
.
filter
(
c
=>
!
determinQuestion
(
c
))
const
wrongLength
=
wrongList
.
length
const
wrongLength
=
wrongList
.
length
...
@@ -77,6 +81,7 @@ export function buildCompleteStageParam (questionList: QuestionType[], stageDeta
...
@@ -77,6 +81,7 @@ export function buildCompleteStageParam (questionList: QuestionType[], stageDeta
level
,
level
,
isTimeout
,
isTimeout
,
levelTime
,
levelTime
,
errList
:
wrongList
,
stageId
:
stageDetail
.
id
,
stageId
:
stageDetail
.
id
,
questions
:
questionList
.
map
(
convert
),
questions
:
questionList
.
map
(
convert
),
num
,
num
,
...
...
src/pages/game/wrong/components/answer-blank.module.scss
0 → 100644
View file @
167eadb6
.blank
{
display
:
inline-block
;
margin
:
0
8px
;
vertical-align
:
middle
;
background
:
#F7F7F7
;
border
:
6px
solid
#E5E5E5
;
font-family
:
HelveticaNeue-Medium
,
HelveticaNeue
;
font-weight
:
500
;
color
:
#465164
;
text-align
:
center
;
min-width
:
84px
;
line-height
:
72px
;
height
:
84px
;
font-size
:
50px
;
padding
:
0
8px
;
box-sizing
:
border-box
;
border-radius
:
20px
;
&
.is_simple
{
border-radius
:
32px
;
font-size
:
80px
;
line-height
:
100px
;
min-width
:
112px
;
height
:
112px
;
}
&
.has_answer
{
border-color
:
rgba
(
23
,
134
,
247
,
0
.5
);
background-color
:
#F1F5FF
;
}
&
.is_active
{
border-color
:
#FFC056
;
background-color
:
#FFF5E3
;
}
&
.is_compare
{
border-radius
:
56px
;
border-color
:
rgba
(
23
,
134
,
247
,
0
.5
);
background-color
:
#F1F5FF
;
}
}
src/pages/game/wrong/components/answer-blank.tsx
0 → 100644
View file @
167eadb6
import
{
View
,
CustomWrapper
}
from
'@tarojs/components'
import
{
useMemo
}
from
'react'
import
classNames
from
'classnames'
import
{
useStoreActions
,
useStoreState
}
from
'@/store/hooks'
import
styles
from
'./answer-blank.module.scss'
import
{
isVerticalDivisionQuestion
,
QuestionType
}
from
'../../play/types'
type
AnswerBlankProps
=
{
index
:
number
;
isCompare
?:
boolean
;
question
:
QuestionType
}
const
AnswerBlank
=
(
props
:
AnswerBlankProps
)
=>
{
const
{
index
,
isCompare
,
question
}
=
props
const
currentInput
=
useMemo
(()
=>
{
return
question
.
answers
?.[
index
]?.
userAnswer
??
''
},
[
question
.
answers
,
index
])
const
isSimple
=
useMemo
(()
=>
{
return
question
&&
(
isVerticalDivisionQuestion
(
question
)
||
question
.
simpleType
)
},
[
question
])
return
(
<
CustomWrapper
>
<
View
className=
{
classNames
(
styles
.
blank
,
isSimple
&&
styles
.
is_simple
,
isCompare
&&
styles
.
is_compare
,
currentInput
&&
styles
.
has_answer
)
}
>
{
currentInput
}
</
View
>
</
CustomWrapper
>
)
}
export
default
AnswerBlank
src/pages/game/wrong/components/question/index.tsx
0 → 100644
View file @
167eadb6
import
{
View
}
from
'@tarojs/components'
import
QuestionBlank
from
'./question-blank'
import
QuestionSelection
from
'./question-selection'
import
QuestionVerticalDivision
from
'./question-vertical-division'
import
{
type
QuestionType
,
isBlankQuestion
,
isSelectionQuestion
,
isVerticalDivisionQuestion
}
from
'../../../play/types'
type
QuestionProps
=
{
question
:
QuestionType
}
const
Question
=
(
props
:
QuestionProps
)
=>
{
const
{
question
}
=
props
if
(
isBlankQuestion
(
question
))
{
return
(
<
QuestionBlank
question=
{
question
}
/>
)
}
if
(
isSelectionQuestion
(
question
))
{
return
(
<
QuestionSelection
question=
{
question
}
/>
)
}
if
(
isVerticalDivisionQuestion
(
question
))
{
return
(
<
QuestionVerticalDivision
question=
{
question
}
/>
)
}
return
(
<
View
>
not supported question type
</
View
>
)
}
export
default
Question
src/pages/game/wrong/components/question/question-blank.module.scss
0 → 100644
View file @
167eadb6
.content
{
font-weight
:
500
;
color
:
#465164
;
min-height
:
100%
;
font-size
:
40px
;
font-weight
:
500
;
color
:
#465164
;
line-height
:
60px
;
padding
:
32px
32px
0
32px
;
box-sizing
:
border-box
;
&
.is_sample
{
font-size
:
80px
;
display
:
flex
;
line-height
:
112px
;
align-items
:
center
;
flex-direction
:
column
;
.top
{
flex
:
2
;
}
.bottom
{
flex
:
4
;
}
}
}
src/pages/game/wrong/components/question/question-blank.tsx
0 → 100644
View file @
167eadb6
/** 填空题 */
import
{
View
}
from
'@tarojs/components'
import
{
useMemo
}
from
'react'
import
htmlParser
from
'html-parse-stringify'
import
classNames
from
'classnames'
import
type
{
BlankQuestion
}
from
'../../../play/types'
import
{
renderRichText
}
from
'./render-tichtext'
import
styles
from
'./question-blank.module.scss'
type
QuestionBlankProps
=
{
question
:
BlankQuestion
}
const
QuestionBlank
=
(
props
:
QuestionBlankProps
)
=>
{
const
{
question
}
=
props
const
tree
=
useMemo
(()
=>
{
return
htmlParser
.
parse
(
question
.
contentText
)
},
[
question
.
contentText
])
return
(
<
View
className=
{
classNames
(
styles
.
content
,
question
.
simpleType
&&
styles
.
is_sample
)
}
>
<
View
className=
{
styles
.
top
}
></
View
>
<
View
>
{
tree
.
map
(
item
=>
renderRichText
(
item
,
question
))
}
</
View
>
<
View
className=
{
styles
.
bottom
}
></
View
>
</
View
>
)
}
export
default
QuestionBlank
src/pages/game/wrong/components/question/question-selection.module.scss
0 → 100644
View file @
167eadb6
.content
{
font-size
:
40px
;
font-weight
:
500
;
color
:
#465164
;
line-height
:
60px
;
flex
:
1
;
&
.is_sample
{
font-size
:
80px
;
font-weight
:
500
;
line-height
:
98px
;
display
:
flex
;
align-items
:
center
;
justify-content
:
center
;
}
}
.wrap
{
min-height
:
100%
;
display
:
flex
;
flex-direction
:
column
;
}
.top
{
flex
:
1
;
display
:
flex
;
align-items
:
center
;
padding
:
0
32px
;
}
.option_wrap
{
padding
:
64px
32px
0
32px
;
}
.gap
{
flex
:
5
;
}
.option_item
{
margin-bottom
:
24px
;
background
:
#F0F2F9
;
border-radius
:
24px
;
display
:
flex
;
align-items
:
center
;
border
:
6px
solid
transparent
;
box-sizing
:
border-box
;
&
.is_active
{
background
:
#FFF5E3
;
border-color
:
#FFC056
;
}
&
:last-child
{
margin-bottom
:
0
;
}
}
.is_active
{
.option_index
{
color
:
#FFC056
;
&
:
:
after
{
background
:
#FFC056
;
}
}
.option_content
{
color
:
#FFC056
;
}
}
.option_index
{
font-size
:
40px
;
font-weight
:
500
;
color
:
#465164
;
line-height
:
56px
;
padding
:
10px
12px
10px
28px
;
position
:
relative
;
width
:
64px
;
height
:
64px
;
text-align
:
center
;
&
:
:
after
{
content
:
" "
;
position
:
absolute
;
right
:
0
;
top
:
50%
;
width
:
2px
;
height
:
28px
;
background
:
rgba
(
70
,
81
,
100
,
0
.3
);
border-radius
:
2px
;
margin-top
:
-14px
;
}
}
.option_content
{
padding
:
16px
28px
16px
24px
;
font-size
:
36px
;
font-weight
:
500
;
color
:
#465164
;
line-height
:
50px
;
}
src/pages/game/wrong/components/question/question-selection.tsx
0 → 100644
View file @
167eadb6
/** 选择题 */
import
{
View
}
from
'@tarojs/components'
import
{
useMemo
}
from
'react'
import
htmlParser
from
'html-parse-stringify'
import
classNames
from
'classnames'
import
{
useStoreActions
}
from
'@/store/hooks'
import
{
renderRichText
}
from
'./render-tichtext'
import
type
{
SelectionQuestion
,
QuestionOption
,
QuestionType
}
from
'../../../play/types'
import
styles
from
'./question-selection.module.scss'
type
QuestionSelectionProps
=
{
question
:
SelectionQuestion
}
type
QuestionOptionItemProps
=
{
option
:
QuestionOption
,
index
:
number
;
question
:
SelectionQuestion
;
}
const
QuestionOptionItem
=
(
props
:
QuestionOptionItemProps
)
=>
{
const
{
option
,
index
,
question
}
=
props
const
tree
=
useMemo
(()
=>
{
return
htmlParser
.
parse
(
option
.
contentText
)
},
[
option
.
contentText
])
const
updateSelectionAnswer
=
useStoreActions
(
actions
=>
actions
.
gameModel
.
updateSelectionAnswer
)
return
(
<
View
className=
{
classNames
(
styles
.
option_item
,
option
.
userAnswer
&&
styles
.
is_active
)
}
onClick=
{
()
=>
updateSelectionAnswer
(
index
)
}
>
<
View
className=
{
styles
.
option_index
}
>
{
option
.
index
}
</
View
>
<
View
className=
{
styles
.
option_content
}
>
{
tree
.
map
(
item
=>
renderRichText
(
item
,
question
))
}
</
View
>
</
View
>
)
}
const
QuestionSelection
=
(
props
:
QuestionSelectionProps
)
=>
{
const
{
question
}
=
props
const
tree
=
useMemo
(()
=>
{
return
htmlParser
.
parse
(
question
.
contentText
)
},
[
question
.
contentText
])
return
(
<
View
className=
{
styles
.
wrap
}
>
<
View
className=
{
styles
.
top
}
>
<
View
className=
{
classNames
(
styles
.
content
,
question
.
simpleType
&&
styles
.
is_sample
)
}
>
{
tree
.
map
((
item
)
=>
renderRichText
(
item
,
question
))
}
</
View
>
</
View
>
<
View
className=
{
styles
.
option_wrap
}
>
{
question
.
options
.
map
((
item
,
index
)
=>
{
return
(
<
QuestionOptionItem
option=
{
item
}
key=
{
item
.
index
}
index=
{
index
}
question=
{
question
}
/>
)
})
}
</
View
>
<
View
className=
{
styles
.
gap
}
></
View
>
</
View
>
)
}
export
default
QuestionSelection
src/pages/game/wrong/components/question/question-vertical-division.module.scss
0 → 100644
View file @
167eadb6
.content
{
display
:
flex
;
flex-direction
:
column
;
align-items
:
center
;
padding-right
:
60px
;
min-height
:
100%
;
}
.gap
{
flex
:
2
;
}
.gap_2
{
flex
:
3
;
}
.top
{
display
:
flex
;
justify-content
:
flex-end
;
padding-right
:
30px
;
padding-bottom
:
12px
;
width
:
465px
;
box-sizing
:
border-box
;
}
.center
{
font-size
:
80px
;
font-weight
:
500
;
color
:
#465164
;
line-height
:
98px
;
display
:
flex
;
align-items
:
center
;
}
.divisor
{
width
:
344px
;
height
:
144px
;
background-image
:
url(~@/pages/game/play/assets/vertical-division.png)
;
background-size
:
100%
100%
;
display
:
flex
;
align-items
:
center
;
justify-content
:
space-between
;
padding
:
0
40px
0
60px
;
box-sizing
:
border-box
;
}
.num_item
{
width
:
112px
;
height
:
112px
;
display
:
flex
;
align-items
:
center
;
justify-content
:
center
;
}
.dividor
{
width
:
112px
;
height
:
112px
;
display
:
flex
;
align-items
:
center
;
justify-content
:
center
;
}
.bottom
{
width
:
324px
;
display
:
flex
;
justify-content
:
space-between
;
margin-left
:
132px
;
padding
:
0
30px
24px
30px
;
box-sizing
:
border-box
;
position
:
relative
;
&
:
:
after
{
height
:
8px
;
background
:
rgba
(
23
,
134
,
247
,
0
.9
);
border-radius
:
4px
;
content
:
" "
;
position
:
absolute
;
bottom
:
0
;
left
:
0
;
right
:
0
;
}
}
.footer
{
display
:
flex
;
justify-content
:
flex-end
;
width
:
456px
;
padding-right
:
30px
;
padding-top
:
12px
;
box-sizing
:
border-box
;
}
src/pages/game/wrong/components/question/question-vertical-division.tsx
0 → 100644
View file @
167eadb6
/** 填空题 */
import
{
View
,
Text
}
from
'@tarojs/components'
import
{
useMemo
}
from
'react'
import
classNames
from
'classnames'
import
type
{
VerticalDivisionQuestion
}
from
'../../../play/types'
import
styles
from
'./question-vertical-division.module.scss'
import
AnswerBlank
from
'../answer-blank'
type
QuestionSelectionProps
=
{
question
:
VerticalDivisionQuestion
}
const
QuestionVerticalDivision
=
(
props
:
QuestionSelectionProps
)
=>
{
const
{
question
}
=
props
const
numList
=
useMemo
(()
=>
{
return
question
.
questionItems
.
find
(
c
=>
c
.
sort
===
0
)?.
contentText
.
split
(
''
)
??
[]
},
[
question
.
questionItems
])
const
B
=
useMemo
(()
=>
{
return
question
.
questionItems
.
find
(
c
=>
c
.
sort
===
1
)?.
contentText
},
[
question
.
questionItems
])
return
(
<
View
className=
{
classNames
(
styles
.
content
)
}
>
<
View
className=
{
styles
.
gap
}
></
View
>
<
View
className=
{
styles
.
top
}
>
<
AnswerBlank
index=
{
0
}
question=
{
question
}
></
AnswerBlank
>
</
View
>
<
View
className=
{
styles
.
center
}
>
<
View
className=
{
styles
.
dividor
}
>
{
B
}
</
View
>
<
View
className=
{
styles
.
divisor
}
>
{
numList
.
map
((
item
,
index
)
=>
(
<
Text
className=
{
styles
.
num_item
}
key=
{
index
}
>
{
item
}
</
Text
>
))
}
</
View
>
</
View
>
<
View
className=
{
styles
.
bottom
}
>
<
AnswerBlank
index=
{
1
}
question=
{
question
}
></
AnswerBlank
>
<
AnswerBlank
index=
{
2
}
question=
{
question
}
></
AnswerBlank
>
</
View
>
<
View
className=
{
styles
.
footer
}
>
<
AnswerBlank
index=
{
3
}
question=
{
question
}
></
AnswerBlank
>
</
View
>
<
View
className=
{
styles
.
gap_2
}
></
View
>
</
View
>
)
}
export
default
QuestionVerticalDivision
src/pages/game/wrong/components/question/render-tichtext.tsx
0 → 100644
View file @
167eadb6
import
{
View
,
Text
,
Image
}
from
'@tarojs/components'
import
{
type
Node
}
from
'html-parse-stringify'
import
MathSymbol
from
'@/pages/game/play/components/math-symbol'
import
{
QuestionType
}
from
'@/pages/game/play/types'
import
cs
from
'./rich-text.module.scss'
import
AnswerBlank
from
'../answer-blank'
export
function
renderRichText
(
node
:
Node
,
question
:
QuestionType
)
{
if
(
node
.
type
===
'text'
)
{
return
(
<
Text
decode
className=
{
cs
.
plain
}
>
{
node
.
content
}
</
Text
>
)
}
if
(
node
.
type
===
'tag'
)
{
if
(
node
.
name
===
'img'
)
{
const
{
src
,
style
,
width
,
height
}
=
node
.
attrs
let
_style
=
style
if
(
width
)
{
_style
=
`
${
_style
||
''
}
;width:
${
width
}
px`
}
if
(
height
)
{
_style
=
`
${
_style
||
''
}
;height:
${
height
}
px`
}
if
(
src
)
{
return
(
<
Image
src=
{
src
}
style=
{
_style
}
></
Image
>
)
}
}
const
renderChildren
=
(
filter
?:
string
[])
=>
{
if
(
filter
)
{
return
node
.
children
?.
filter
(
c
=>
c
.
type
===
'tag'
&&
filter
.
includes
(
c
.
name
)).
map
(
n
=>
renderRichText
(
n
,
question
))
}
return
node
.
children
?.
map
((
n
)
=>
renderRichText
(
n
,
question
))
}
if
(
!
node
.
voidElement
)
{
switch
(
node
.
name
)
{
case
'i'
:
{
return
(
<
Text
className=
{
cs
.
italy
}
>
{
renderChildren
()
}
</
Text
>
)
}
case
'b'
:
{
return
(
<
Text
className=
{
cs
.
bold
}
>
{
renderChildren
()
}
</
Text
>
)
}
case
'u'
:
{
return
(
<
Text
className=
{
cs
.
underline
}
>
{
renderChildren
()
}
</
Text
>
)
}
case
'table'
:
{
return
(
<
View
className=
{
cs
.
table
}
>
{
renderChildren
([
'tbody'
,
'thead'
])
}
</
View
>
)
}
case
'thead'
:
{
return
(
<
View
className=
{
cs
.
thead
}
>
{
renderChildren
([
'tr'
])
}
</
View
>
)
}
case
'tr'
:
{
return
(
<
View
className=
{
cs
.
tr
}
>
{
renderChildren
([
'th'
,
'td'
])
}
</
View
>
)
}
case
'th'
:
{
return
(
<
View
className=
{
cs
.
th
}
>
{
renderChildren
()
}
</
View
>
)
}
case
'td'
:
{
return
(
<
View
className=
{
cs
.
td
}
>
{
renderChildren
()
}
</
View
>
)
}
case
'tbody'
:
{
return
(
<
View
className=
{
cs
.
tbody
}
>
{
renderChildren
([
'tr'
])
}
</
View
>
)
}
case
'MathEquation'
:
{
return
(
<
View
className=
{
cs
.
math_equation
}
>
{
renderChildren
()
}
</
View
>
)
}
}
return
(
<
View
>
{
renderChildren
()
}
</
View
>
)
}
if
(
node
.
name
===
'AnswerBlank'
)
{
const
index
=
node
.
attrs
.
index
??
0
const
isCompare
=
node
.
attrs
.
compare
===
'1'
return
(
<
AnswerBlank
index=
{
+
index
}
isCompare=
{
isCompare
}
question=
{
question
}
/>
)
}
if
(
node
.
name
===
'MathSymbol'
)
{
const
index
=
node
.
attrs
.
value
as
any
return
(
<
MathSymbol
value=
{
index
}
/>
)
}
}
}
src/pages/game/wrong/components/question/rich-text.module.scss
0 → 100644
View file @
167eadb6
.italy
{
font-style
:
italic
;
}
.bold
{
font-weight
:
bold
;
}
.underline
{
text-decoration
:
underline
;
}
.plain
{
vertical-align
:
middle
;
}
.table
{
border-collapse
:
collapse
;
border-spacing
:
0
;
display
:
table
;
box-sizing
:
border-box
;
text-indent
:
initial
;
border
:
1px
solid
#000
;
margin
:
0
auto
;
}
.thead
,
.tbody
{
display
:
table-header-group
;
vertical-align
:
middle
;
border-color
:
inherit
;
}
.math_equation
{
display
:
flex
;
align-items
:
center
;
justify-content
:
center
;
font-size
:
80px
;
font-weight
:
500
;
padding
:
20px
0
;
}
.tr
{
display
:
table-row
;
vertical-align
:
inherit
;
border-color
:
inherit
;
}
.th
{
display
:
table-cell
;
vertical-align
:
inherit
;
font-weight
:
bold
;
text-align
:
left
;
border-right
:
1px
solid
#000
;
border-bottom
:
1px
solid
#000
;
padding
:
4px
8px
;
}
.td
{
display
:
table-cell
;
vertical-align
:
inherit
;
text-align
:
left
;
padding
:
4px
8px
;
border-right
:
1px
solid
#000
;
border-bottom
:
1px
solid
#000
;
}
src/pages/game/wrong/index.config.ts
0 → 100644
View file @
167eadb6
export
default
definePageConfig
({
navigationBarBackgroundColor
:
'#ffffff'
,
navigationBarTitleText
:
'本关错题'
,
backgroundColor
:
'#F9F9F9'
})
src/pages/game/wrong/index.tsx
View file @
167eadb6
import
{
View
}
from
'@tarojs/components'
import
{
View
}
from
'@tarojs/components'
import
{
useStoreState
}
from
'@/store/hooks'
import
Question
from
'./components/question'
import
styles
from
'./index.module.scss'
import
styles
from
'./index.module.scss'
const
Wrong
=
()
=>
{
const
Wrong
=
()
=>
{
const
errList
=
useStoreState
(
state
=>
state
.
gameModel
.
errList
)
console
.
log
(
errList
,
111111
)
return
(
return
(
<
View
>
123123
</
View
>
<
View
>
{
errList
.
map
((
c
,
index
)
=>
(
<
View
>
<
Question
question=
{
c
}
key=
{
index
}
/>
</
View
>
))
}
</
View
>
)
)
}
}
...
...
src/pages/main/components/main-component.tsx
View file @
167eadb6
...
@@ -52,8 +52,7 @@ const MainPage = () => {
...
@@ -52,8 +52,7 @@ const MainPage = () => {
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
isFocus
)
{
if
(
isFocus
)
{
player
.
play
()
player
.
play
()
// TODO
tutorialRef
.
current
?.
start
()
// tutorialRef.current?.start()
}
}
},
[
player
,
isFocus
])
},
[
player
,
isFocus
])
...
...
src/pages/main/components/scene/stage.tsx
View file @
167eadb6
...
@@ -106,8 +106,10 @@ const getIconClassNames = (type?: StageType, extra: string[] = []) => {
...
@@ -106,8 +106,10 @@ const getIconClassNames = (type?: StageType, extra: string[] = []) => {
const
StageComp
=
(
props
:
StageProps
)
=>
{
const
StageComp
=
(
props
:
StageProps
)
=>
{
const
{
stage
}
=
props
const
{
stage
}
=
props
const
updateState
=
useStoreActions
(
actions
=>
actions
.
gameModel
.
updateState
)
const
updateState
=
useStoreActions
(
actions
=>
actions
.
gameModel
.
updateState
)
const
completeMainGuide
=
useStoreActions
(
actions
=>
actions
.
mainModel
.
completeMainGuide
)
const
isReady
=
useStoreState
(
state
=>
state
.
mainModel
.
isReady
)
const
isReady
=
useStoreState
(
state
=>
state
.
mainModel
.
isReady
)
const
player
=
useStoreState
(
state
=>
state
.
mainModel
.
player
)
const
player
=
useStoreState
(
state
=>
state
.
mainModel
.
player
)
const
guideActive
=
useStoreState
(
state
=>
state
.
mainModel
.
guideActive
)
const
handleClick
=
()
=>
{
const
handleClick
=
()
=>
{
if
(
stage
.
status
!==
StageStatus
.
DISABLED
)
{
if
(
stage
.
status
!==
StageStatus
.
DISABLED
)
{
...
@@ -118,6 +120,11 @@ const StageComp = (props: StageProps) => {
...
@@ -118,6 +120,11 @@ const StageComp = (props: StageProps) => {
}
}
}
}
const
handleCompleteGuide
=
()
=>
{
handleClick
()
completeMainGuide
()
}
const
renderRound
=
(
ready
:
boolean
)
=>
{
const
renderRound
=
(
ready
:
boolean
)
=>
{
switch
(
stage
.
status
)
{
switch
(
stage
.
status
)
{
case
StageStatus
.
DISABLED
:
{
case
StageStatus
.
DISABLED
:
{
...
@@ -132,11 +139,11 @@ const StageComp = (props: StageProps) => {
...
@@ -132,11 +139,11 @@ const StageComp = (props: StageProps) => {
src=
{
getUnlockedIcon
(
stage
.
type
).
u
}
src=
{
getUnlockedIcon
(
stage
.
type
).
u
}
compnent=
{
Image
}
compnent=
{
Image
}
className=
{
getIconClassNames
(
stage
.
type
)
}
className=
{
getIconClassNames
(
stage
.
type
)
}
isActive=
{
fals
e
}
isActive=
{
guideActiv
e
}
verticalPadding=
{
0
}
verticalPadding=
{
0
}
horizonPadding=
{
0
}
horizonPadding=
{
0
}
wrapClass=
{
styles
.
guide_wrap
}
wrapClass=
{
styles
.
guide_wrap
}
onClickConent=
{
handleC
lick
}
onClickConent=
{
handleC
ompleteGuide
}
guideContent=
{
(
guideContent=
{
(
<
View
className=
{
styles
.
tutorial
}
>
<
View
className=
{
styles
.
tutorial
}
>
<
Image
src=
{
tutorial
[
'arrow.png'
].
u
}
className=
{
styles
.
tutorial_arrow
}
></
Image
>
<
Image
src=
{
tutorial
[
'arrow.png'
].
u
}
className=
{
styles
.
tutorial_arrow
}
></
Image
>
...
...
src/pages/main/components/tutorial/index.tsx
View file @
167eadb6
import
{
useState
,
useImperativeHandle
,
forwardRef
,
useCallback
,
useEffect
,
useRef
}
from
'react'
import
{
useState
,
useImperativeHandle
,
forwardRef
,
useCallback
,
useEffect
,
useRef
}
from
'react'
import
{
showToast
}
from
'@tarojs/taro'
import
{
showToast
}
from
'@tarojs/taro'
import
{
getAreaAndGrades
,
type
AreaAndGrades
}
from
'@/api'
import
{
getAreaAndGrades
,
type
AreaAndGrades
}
from
'@/api'
import
{
useStoreState
}
from
'@/store/hooks'
import
{
useStoreState
,
useStoreActions
}
from
'@/store/hooks'
import
ModalArea
from
'./modal-area'
import
ModalArea
from
'./modal-area'
import
ModalGrade
from
'./modal-grade'
import
ModalGrade
from
'./modal-grade'
import
ModalResult
from
'./modal-result'
import
ModalResult
from
'./modal-result'
...
@@ -12,6 +12,11 @@ export type TutorialRef = {
...
@@ -12,6 +12,11 @@ export type TutorialRef = {
const
Tutorial
=
forwardRef
<
TutorialRef
,
{}
>
((
_
,
ref
)
=>
{
const
Tutorial
=
forwardRef
<
TutorialRef
,
{}
>
((
_
,
ref
)
=>
{
const
joinDefered
=
useStoreState
(
state
=>
state
.
userModel
.
joinDefered
)
const
joinDefered
=
useStoreState
(
state
=>
state
.
userModel
.
joinDefered
)
const
updateUserInfo
=
useStoreActions
(
actions
=>
actions
.
userModel
.
updateUserInfo
)
const
updateGuideActive
=
useStoreActions
(
actions
=>
actions
.
mainModel
.
updateGuideActive
)
const
mainGuideComplete
=
useStoreState
(
state
=>
state
.
mainModel
.
mainGuideComplete
)
const
userInfo
=
useStoreState
(
state
=>
state
.
userModel
.
userInfo
)
const
updating
=
useStoreState
(
state
=>
state
.
userModel
.
updating
)
const
[
step
,
setStep
]
=
useState
(
0
)
const
[
step
,
setStep
]
=
useState
(
0
)
const
[
selected
,
setSelected
]
=
useState
({
area
:
''
,
grade
:
''
})
const
[
selected
,
setSelected
]
=
useState
({
area
:
''
,
grade
:
''
})
...
@@ -35,21 +40,32 @@ const Tutorial = forwardRef<TutorialRef, {}>((_, ref) => {
...
@@ -35,21 +40,32 @@ const Tutorial = forwardRef<TutorialRef, {}>((_, ref) => {
const
handleConfirm
=
useCallback
(()
=>
{
const
handleConfirm
=
useCallback
(()
=>
{
setStep
(
0
)
setStep
(
0
)
},
[])
if
(
!
mainGuideComplete
)
{
updateGuideActive
(
true
)
}
},
[
updateGuideActive
,
mainGuideComplete
])
const
loadData
=
useCallback
(()
=>
{
const
loadData
=
useCallback
(()
=>
{
return
getAreaAndGrades
().
then
(
setData
)
return
getAreaAndGrades
().
then
(
setData
)
},
[])
},
[])
const
handleConfirmArea
=
useCallback
((
val
:
string
)
=>
{
const
handleConfirmArea
=
useCallback
((
val
:
string
)
=>
{
setSelected
(
v
=>
({
...
v
,
area
:
val
}))
updateUserInfo
({
setStep
(
2
)
city
:
val
,
},
[])
}).
then
(()
=>
{
setSelected
(
v
=>
({
...
v
,
area
:
val
}))
setStep
(
2
)
})
},
[
updateUserInfo
])
const
handleConfirmGrade
=
useCallback
((
val
:
string
)
=>
{
const
handleConfirmGrade
=
useCallback
((
val
:
string
)
=>
{
setSelected
(
v
=>
({
...
v
,
grade
:
val
}))
updateUserInfo
({
setStep
(
3
)
grade
:
val
,
},
[])
}).
then
(()
=>
{
setSelected
(
v
=>
({
...
v
,
grade
:
val
}))
setStep
(
3
)
})
},
[
updateUserInfo
])
useEffect
(()
=>
{
useEffect
(()
=>
{
loadData
()
loadData
()
...
@@ -66,7 +82,17 @@ const Tutorial = forwardRef<TutorialRef, {}>((_, ref) => {
...
@@ -66,7 +82,17 @@ const Tutorial = forwardRef<TutorialRef, {}>((_, ref) => {
})
})
})
})
}
}
setStep
(
1
)
// 没选择城市
if
(
!
userInfo
.
city
)
{
setStep
(
1
)
}
else
if
(
!
userInfo
.
grade
)
{
// 没选择年级
setStep
(
2
)
}
else
{
setStep
(
0
)
if
(
!
mainGuideComplete
)
{
updateGuideActive
(
true
)
}
}
}
}
}
}
})
})
...
@@ -77,8 +103,8 @@ const Tutorial = forwardRef<TutorialRef, {}>((_, ref) => {
...
@@ -77,8 +103,8 @@ const Tutorial = forwardRef<TutorialRef, {}>((_, ref) => {
return
(
return
(
<>
<>
{
step
===
1
&&
<
ModalArea
options=
{
data
.
areas
}
onConfirm=
{
handleConfirmArea
}
/>
}
{
step
===
1
&&
<
ModalArea
options=
{
data
.
areas
}
onConfirm=
{
handleConfirmArea
}
loading=
{
updating
}
/>
}
{
step
===
2
&&
<
ModalGrade
options=
{
data
.
grades
}
onConfirm=
{
handleConfirmGrade
}
/>
}
{
step
===
2
&&
!
userInfo
.
grade
&&
<
ModalGrade
options=
{
data
.
grades
}
onConfirm=
{
handleConfirmGrade
}
loading=
{
updating
}
/>
}
{
step
===
3
&&
<
ModalResult
grade=
{
selected
.
grade
}
onConfirm=
{
handleConfirm
}
/>
}
{
step
===
3
&&
<
ModalResult
grade=
{
selected
.
grade
}
onConfirm=
{
handleConfirm
}
/>
}
</>
</>
)
)
...
...
src/pages/main/components/tutorial/modal-area.tsx
View file @
167eadb6
import
{
View
,
RootPortal
,
Image
,
ScrollView
}
from
'@tarojs/components'
import
{
View
,
RootPortal
,
Image
,
ScrollView
,
Button
}
from
'@tarojs/components'
import
tutorialAssets
from
'@/assets/oss/assets-tutorial'
import
tutorialAssets
from
'@/assets/oss/assets-tutorial'
import
{
useState
}
from
'react'
import
{
useState
}
from
'react'
import
classNames
from
'classnames'
import
classNames
from
'classnames'
...
@@ -7,13 +7,15 @@ import styles from './shared.module.scss'
...
@@ -7,13 +7,15 @@ import styles from './shared.module.scss'
type
ModalAreaProps
=
{
type
ModalAreaProps
=
{
options
:
string
[];
options
:
string
[];
onConfirm
:
(
arg
:
string
)
=>
void
;
onConfirm
:
(
arg
:
string
)
=>
void
;
loading
:
boolean
;
}
}
const
ModalArea
=
(
props
:
ModalAreaProps
)
=>
{
const
ModalArea
=
(
props
:
ModalAreaProps
)
=>
{
const
{
options
,
onConfirm
}
=
props
const
{
options
,
onConfirm
,
loading
}
=
props
const
[
current
,
setCurrent
]
=
useState
(
''
)
const
[
current
,
setCurrent
]
=
useState
(
''
)
const
handleConfirm
=
()
=>
{
const
handleConfirm
=
()
=>
{
if
(
loading
)
return
if
(
current
)
{
if
(
current
)
{
onConfirm
(
current
)
onConfirm
(
current
)
}
}
...
@@ -40,7 +42,12 @@ const ModalArea = (props: ModalAreaProps) => {
...
@@ -40,7 +42,12 @@ const ModalArea = (props: ModalAreaProps) => {
</
ScrollView
>
</
ScrollView
>
<
View
className=
{
styles
.
modal_footer
}
>
<
View
className=
{
styles
.
modal_footer
}
>
<
View
className=
{
classNames
(
styles
.
btn
,
!
current
&&
styles
.
disabled
)
}
onClick=
{
handleConfirm
}
hoverClass=
{
styles
.
btn_on
}
>
继续
</
View
>
<
Button
className=
{
classNames
(
styles
.
btn
,
!
current
&&
styles
.
disabled
)
}
onClick=
{
handleConfirm
}
loading=
{
loading
}
hoverClass=
{
styles
.
btn_on
}
>
继续
</
Button
>
</
View
>
</
View
>
</
View
>
</
View
>
</
View
>
</
View
>
...
...
src/pages/main/components/tutorial/modal-grade.tsx
View file @
167eadb6
import
{
View
,
RootPortal
,
Image
,
ScrollView
}
from
'@tarojs/components'
import
{
View
,
RootPortal
,
Image
,
ScrollView
,
Button
}
from
'@tarojs/components'
import
tutorialAssets
from
'@/assets/oss/assets-tutorial'
import
tutorialAssets
from
'@/assets/oss/assets-tutorial'
import
{
useState
}
from
'react'
import
{
useState
}
from
'react'
import
classNames
from
'classnames'
import
classNames
from
'classnames'
...
@@ -7,13 +7,15 @@ import styles from './shared.module.scss'
...
@@ -7,13 +7,15 @@ import styles from './shared.module.scss'
type
ModalGradeProps
=
{
type
ModalGradeProps
=
{
options
:
string
[];
options
:
string
[];
onConfirm
:
(
arg
:
string
)
=>
void
;
onConfirm
:
(
arg
:
string
)
=>
void
;
loading
:
boolean
;
}
}
const
ModalGrade
=
(
props
:
ModalGradeProps
)
=>
{
const
ModalGrade
=
(
props
:
ModalGradeProps
)
=>
{
const
{
options
,
onConfirm
}
=
props
const
{
options
,
onConfirm
,
loading
}
=
props
const
[
current
,
setCurrent
]
=
useState
(
''
)
const
[
current
,
setCurrent
]
=
useState
(
''
)
const
handleConfirm
=
()
=>
{
const
handleConfirm
=
()
=>
{
if
(
loading
)
return
if
(
current
)
{
if
(
current
)
{
onConfirm
(
current
)
onConfirm
(
current
)
}
}
...
@@ -40,11 +42,12 @@ const ModalGrade = (props: ModalGradeProps) => {
...
@@ -40,11 +42,12 @@ const ModalGrade = (props: ModalGradeProps) => {
</
ScrollView
>
</
ScrollView
>
<
View
className=
{
styles
.
modal_footer
}
>
<
View
className=
{
styles
.
modal_footer
}
>
<
View
<
Button
loading=
{
loading
}
className=
{
classNames
(
styles
.
btn
,
!
current
&&
styles
.
disabled
)
}
className=
{
classNames
(
styles
.
btn
,
!
current
&&
styles
.
disabled
)
}
onClick=
{
handleConfirm
}
onClick=
{
handleConfirm
}
hoverClass=
{
styles
.
btn_on
}
hoverClass=
{
styles
.
btn_on
}
>
继续
</
View
>
>
继续
</
Button
>
</
View
>
</
View
>
</
View
>
</
View
>
</
View
>
</
View
>
...
...
src/pages/main/components/tutorial/shared.module.scss
View file @
167eadb6
...
@@ -51,6 +51,11 @@
...
@@ -51,6 +51,11 @@
font-weight
:
500
;
font-weight
:
500
;
color
:
#FFFFFF
;
color
:
#FFFFFF
;
line-height
:
40px
;
line-height
:
40px
;
border
:
none
;
&
:
:
after
{
border
:
none
;
}
&
.btn_on
{
&
.btn_on
{
background-image
:
url(../../../market/assets/btn-on.png)
;
background-image
:
url(../../../market/assets/btn-on.png)
;
...
...
src/pages/main/model.ts
View file @
167eadb6
import
{
import
{
action
,
Action
,
Thunk
,
thunk
action
,
Action
,
State
,
Thunk
,
thunk
}
from
'easy-peasy'
}
from
'easy-peasy'
import
{
createInnerAudioContext
,
type
InnerAudioContext
}
from
'@tarojs/taro'
import
{
createInnerAudioContext
,
type
InnerAudioContext
}
from
'@tarojs/taro'
import
{
AppStoreModel
}
from
'@/store/store-model'
import
{
AppStoreModel
}
from
'@/store/store-model'
import
{
type
Stage
,
getStageList
}
from
'@/api'
import
{
type
Stage
,
getStageList
}
from
'@/api'
import
audio
from
'@/assets/oss/assets-audio'
import
audio
from
'@/assets/oss/assets-audio'
import
{
getStorage
,
StorageKeys
,
updateStorage
}
from
'@/utils/storage'
const
getPlayer
=
()
=>
{
const
getPlayer
=
()
=>
{
const
player
=
createInnerAudioContext
()
const
player
=
createInnerAudioContext
()
...
@@ -17,16 +18,40 @@ const getPlayer = () => {
...
@@ -17,16 +18,40 @@ const getPlayer = () => {
export
interface
MainModel
{
export
interface
MainModel
{
stageList
:
Stage
[];
stageList
:
Stage
[];
isReady
:
boolean
;
isReady
:
boolean
;
guideActive
:
boolean
;
player
:
InnerAudioContext
;
player
:
InnerAudioContext
;
/** 完成首页引导 */
mainGuideComplete
:
boolean
|
null
;
updateState
:
Action
<
MainModel
,
Partial
<
State
<
MainModel
>>>
;
updateReady
:
Action
<
MainModel
,
boolean
>
;
updateReady
:
Action
<
MainModel
,
boolean
>
;
updateGuideActive
:
Action
<
MainModel
,
boolean
>
;
updateStageList
:
Action
<
MainModel
,
Stage
[]
>
;
updateStageList
:
Action
<
MainModel
,
Stage
[]
>
;
completeMainGuide
:
Thunk
<
MainModel
,
void
,
void
,
AppStoreModel
>
;
fetchStage
:
Thunk
<
MainModel
,
void
,
void
,
AppStoreModel
,
Promise
<
[
Stage
[],
Stage
[]]
>>
;
fetchStage
:
Thunk
<
MainModel
,
void
,
void
,
AppStoreModel
,
Promise
<
[
Stage
[],
Stage
[]]
>>
;
}
}
const
mainModel
:
MainModel
=
{
const
mainModel
:
MainModel
=
{
isReady
:
false
,
isReady
:
false
,
guideActive
:
false
,
mainGuideComplete
:
getStorage
(
StorageKeys
.
mainGuideComplete
),
player
:
getPlayer
(),
player
:
getPlayer
(),
stageList
:
[],
stageList
:
[],
updateState
:
action
((
state
,
payload
)
=>
{
for
(
const
k
in
payload
)
{
state
[
k
]
=
payload
[
k
]
}
}),
completeMainGuide
:
thunk
(
async
(
actions
)
=>
{
actions
.
updateState
({
mainGuideComplete
:
true
,
guideActive
:
false
,
})
updateStorage
(
StorageKeys
.
mainGuideComplete
,
true
)
}),
updateGuideActive
:
action
((
state
,
payload
)
=>
{
state
.
guideActive
=
payload
}),
updateReady
:
action
((
state
,
payload
)
=>
{
updateReady
:
action
((
state
,
payload
)
=>
{
state
.
isReady
=
payload
state
.
isReady
=
payload
}),
}),
...
...
src/store/modules/user.ts
View file @
167eadb6
import
{
import
{
action
,
Action
,
Thunk
,
thunk
,
State
action
,
Action
,
Thunk
,
thunk
,
State
}
from
'easy-peasy'
}
from
'easy-peasy'
import
{
getAccountInfo
,
getSetting
,
type
SettintType
,
updateUserInfo
,
updateUserPhone
}
from
'@/api'
import
{
getAccountInfo
,
getSetting
,
type
SettintType
,
updateUserInfo
,
type
UpdateUserInfoIn
,
updateUserPhone
}
from
'@/api'
import
type
{
UserInfo
}
from
'@/types'
import
type
{
UserInfo
}
from
'@/types'
import
{
pointToCard
}
from
'@/api/account'
import
{
pointToCard
}
from
'@/api/account'
import
{
showModal
,
showToast
,
showLoading
,
hideLoading
}
from
'@tarojs/taro'
import
{
showModal
,
showToast
,
showLoading
,
hideLoading
}
from
'@tarojs/taro'
...
@@ -15,12 +15,13 @@ export interface UserModel {
...
@@ -15,12 +15,13 @@ export interface UserModel {
userInfo
:
UserInfo
;
userInfo
:
UserInfo
;
cardNum
:
number
;
cardNum
:
number
;
point
:
number
;
point
:
number
;
updating
:
boolean
;
isEyeProtectionMode
:
boolean
;
isEyeProtectionMode
:
boolean
;
updateState
:
Action
<
UserModel
,
Partial
<
State
<
UserModel
>>>
;
updateState
:
Action
<
UserModel
,
Partial
<
State
<
UserModel
>>>
;
fetchAccount
:
Thunk
<
UserModel
,
void
,
void
,
AppStoreModel
>
;
fetchAccount
:
Thunk
<
UserModel
,
void
,
void
,
AppStoreModel
>
;
setting
:
SettintType
;
setting
:
SettintType
;
getSetting
:
Thunk
<
UserModel
,
void
,
void
,
AppStoreModel
>
;
getSetting
:
Thunk
<
UserModel
,
void
,
void
,
AppStoreModel
>
;
// updateUserInfo: Thunk<UserModel, string
, void, AppStoreModel>;
updateUserInfo
:
Thunk
<
UserModel
,
Partial
<
UpdateUserInfoIn
>
,
void
,
AppStoreModel
>
;
exchangeItem
:
Thunk
<
UserModel
,
{
name
:
string
;
num
:
number
;
},
void
,
AppStoreModel
>
;
exchangeItem
:
Thunk
<
UserModel
,
{
name
:
string
;
num
:
number
;
},
void
,
AppStoreModel
>
;
...
@@ -33,7 +34,33 @@ const userModel: UserModel = {
...
@@ -33,7 +34,33 @@ const userModel: UserModel = {
isEyeProtectionMode
:
false
,
isEyeProtectionMode
:
false
,
cardNum
:
0
,
cardNum
:
0
,
point
:
0
,
point
:
0
,
updating
:
false
,
setting
:
{
pointToCard
:
Infinity
,
aPoint
:
0
,
bPoint
:
0
,
sPoint
:
0
},
setting
:
{
pointToCard
:
Infinity
,
aPoint
:
0
,
bPoint
:
0
,
sPoint
:
0
},
updateUserInfo
:
thunk
(
async
(
actions
,
payload
,
helpers
)
=>
{
try
{
if
(
helpers
.
getState
().
updating
)
return
actions
.
updateState
({
updating
:
true
})
await
updateUserInfo
(
payload
)
const
{
userInfo
}
=
helpers
.
getState
()
const
current
=
{
...
userInfo
,
...
payload
}
updateStorage
(
StorageKeys
.
userInfo
,
current
)
actions
.
updateState
({
userInfo
:
current
,
updating
:
false
,
})
}
catch
(
err
)
{
actions
.
updateState
({
updating
:
false
})
if
(
err
.
message
)
{
showModal
({
title
:
'提示'
,
content
:
err
.
message
,
showCancel
:
false
})
console
.
log
(
err
)
}
throw
err
}
}),
updateNickNameAndPhone
:
thunk
(
async
(
actions
,
payload
,
helpers
)
=>
{
updateNickNameAndPhone
:
thunk
(
async
(
actions
,
payload
,
helpers
)
=>
{
try
{
try
{
...
@@ -42,7 +69,7 @@ const userModel: UserModel = {
...
@@ -42,7 +69,7 @@ const userModel: UserModel = {
}
}
await
Promise
.
all
([
await
Promise
.
all
([
updateUserPhone
(
payload
.
code
),
updateUserPhone
(
payload
.
code
),
updateUserInfo
(
payload
.
name
),
updateUserInfo
(
{
nickName
:
payload
.
name
}
),
])
])
const
{
userInfo
}
=
helpers
.
getState
()
const
{
userInfo
}
=
helpers
.
getState
()
const
current
=
{
...
userInfo
,
nickName
:
payload
.
name
}
const
current
=
{
...
userInfo
,
nickName
:
payload
.
name
}
...
...
src/types.ts
View file @
167eadb6
...
@@ -4,6 +4,7 @@ export type UserInfo = {
...
@@ -4,6 +4,7 @@ export type UserInfo = {
openId
:
string
;
openId
:
string
;
userId
?:
number
;
userId
?:
number
;
city
?:
string
;
city
?:
string
;
grade
?:
string
;
nickName
?:
string
|
null
;
nickName
?:
string
|
null
;
phone
?:
string
|
null
;
phone
?:
string
|
null
;
}
}
...
...
src/utils/storage.ts
View file @
167eadb6
...
@@ -8,11 +8,15 @@ export enum StorageKeys {
...
@@ -8,11 +8,15 @@ export enum StorageKeys {
userInfo
=
1
,
userInfo
=
1
,
/** openid */
/** openid */
openid
,
openid
,
/** 完成首页引导 */
mainGuideComplete
,
}
}
type
Storage
=
{
type
Storage
=
{
[
StorageKeys
.
userInfo
]:
UserInfo
|
null
;
[
StorageKeys
.
userInfo
]:
UserInfo
|
null
;
[
StorageKeys
.
openid
]:
string
|
null
|
undefined
[
StorageKeys
.
openid
]:
string
|
null
|
undefined
;
[
StorageKeys
.
mainGuideComplete
]:
boolean
|
null
;
}
}
const
store
:
Storage
=
{}
as
Storage
const
store
:
Storage
=
{}
as
Storage
...
@@ -26,7 +30,8 @@ export function reloadStore () {
...
@@ -26,7 +30,8 @@ export function reloadStore () {
try
{
try
{
[
[
StorageKeys
.
openid
,
StorageKeys
.
openid
,
StorageKeys
.
userInfo
StorageKeys
.
userInfo
,
StorageKeys
.
mainGuideComplete
,
].
forEach
((
element
)
=>
{
].
forEach
((
element
)
=>
{
updateStorage
(
element
,
Taro
.
getStorageSync
(
`
${
storagePrefix
}${
element
}
`
)
??
null
)
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