Commit 2dfaaf17 authored by hewenhao's avatar hewenhao

feat: 答题

parent e581a256
......@@ -10,7 +10,7 @@
color: #465164;
text-align: center;
min-width: 84px;
line-height: 70px;
line-height: 72px;
height: 84px;
font-size: 50px;
padding: 0 8px;
......@@ -20,7 +20,7 @@
&.is_simple {
border-radius: 32px;
font-size: 80px;
line-height: 112px;
line-height: 100px;
min-width: 112px;
height: 112px;
}
......
import { View, Image, CustomWrapper } from '@tarojs/components'
import { useStoreState, useStoreActions } from '@/store/hooks'
import { useCallback, useMemo } from 'react'
import { useMemo } from 'react'
import classNames from 'classnames'
import styles from './page-footer.module.scss'
......@@ -12,13 +12,8 @@ const PageFooter = () => {
const isLastQuestion = useMemo(() => {
return questionList.length === currentQuestionIndex + 1
}, [questionList, currentQuestionIndex])
const updateCurrentIndex = useStoreActions(actions => actions.gameModel.updateCurrentIndex)
const clearUserAnswer = useStoreActions(actions => actions.gameModel.clearUserAnswer)
const handleGoNext = useCallback(() => {
if (!canGoNext) return
updateCurrentIndex(currentQuestionIndex + 1)
}, [canGoNext, updateCurrentIndex, currentQuestionIndex])
const handleGoNext = useStoreActions(actions => actions.gameModel.handleGoNext)
return (
<CustomWrapper>
......@@ -35,7 +30,7 @@ const PageFooter = () => {
<View
className={classNames(styles.btn_right, !canGoNext && styles.disabled)}
hoverClass={canGoNext ? styles.is_active : null}
onClick={handleGoNext}
onClick={() => handleGoNext()}
>{isLastQuestion ? '提交' : '下一题'}</View>
</View>
</View>
......
......@@ -115,8 +115,16 @@ const gameModel: GameModel = {
state.questionList = questionList
}),
handleGoNext: thunk(async () => {
handleGoNext: thunk(async (actions, _, helpers) => {
const { canGoNext, currentQuestionIndex, questionList } = helpers.getState()
if (!canGoNext) return
const len = questionList.length
if (len === currentQuestionIndex + 1) {
console.log('submit')
return
}
actions.updateCurrentIndex(currentQuestionIndex + 1)
}),
getQuestionList: thunk(async (actions, round, helpers) => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment