Commit 2dfaaf17 authored by hewenhao's avatar hewenhao

feat: 答题

parent e581a256
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
color: #465164; color: #465164;
text-align: center; text-align: center;
min-width: 84px; min-width: 84px;
line-height: 70px; line-height: 72px;
height: 84px; height: 84px;
font-size: 50px; font-size: 50px;
padding: 0 8px; padding: 0 8px;
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
&.is_simple { &.is_simple {
border-radius: 32px; border-radius: 32px;
font-size: 80px; font-size: 80px;
line-height: 112px; line-height: 100px;
min-width: 112px; min-width: 112px;
height: 112px; height: 112px;
} }
......
import { View, Image, CustomWrapper } from '@tarojs/components' import { View, Image, CustomWrapper } from '@tarojs/components'
import { useStoreState, useStoreActions } from '@/store/hooks' import { useStoreState, useStoreActions } from '@/store/hooks'
import { useCallback, useMemo } from 'react' import { useMemo } from 'react'
import classNames from 'classnames' import classNames from 'classnames'
import styles from './page-footer.module.scss' import styles from './page-footer.module.scss'
...@@ -12,13 +12,8 @@ const PageFooter = () => { ...@@ -12,13 +12,8 @@ const PageFooter = () => {
const isLastQuestion = useMemo(() => { const isLastQuestion = useMemo(() => {
return questionList.length === currentQuestionIndex + 1 return questionList.length === currentQuestionIndex + 1
}, [questionList, currentQuestionIndex]) }, [questionList, currentQuestionIndex])
const updateCurrentIndex = useStoreActions(actions => actions.gameModel.updateCurrentIndex)
const clearUserAnswer = useStoreActions(actions => actions.gameModel.clearUserAnswer) const clearUserAnswer = useStoreActions(actions => actions.gameModel.clearUserAnswer)
const handleGoNext = useStoreActions(actions => actions.gameModel.handleGoNext)
const handleGoNext = useCallback(() => {
if (!canGoNext) return
updateCurrentIndex(currentQuestionIndex + 1)
}, [canGoNext, updateCurrentIndex, currentQuestionIndex])
return ( return (
<CustomWrapper> <CustomWrapper>
...@@ -35,7 +30,7 @@ const PageFooter = () => { ...@@ -35,7 +30,7 @@ const PageFooter = () => {
<View <View
className={classNames(styles.btn_right, !canGoNext && styles.disabled)} className={classNames(styles.btn_right, !canGoNext && styles.disabled)}
hoverClass={canGoNext ? styles.is_active : null} hoverClass={canGoNext ? styles.is_active : null}
onClick={handleGoNext} onClick={() => handleGoNext()}
>{isLastQuestion ? '提交' : '下一题'}</View> >{isLastQuestion ? '提交' : '下一题'}</View>
</View> </View>
</View> </View>
......
...@@ -115,8 +115,16 @@ const gameModel: GameModel = { ...@@ -115,8 +115,16 @@ const gameModel: GameModel = {
state.questionList = questionList 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) => { 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