Commit 72cd038d authored by m's avatar m
parents 17208565 a90fc4d7
......@@ -45,9 +45,8 @@ const CountUp = (props: CountUpProps) => {
useEffect(() => {
if (isSubmit && countUp.current?.sid) {
console.log(countUp.current)
const comp = getCurrentInstance()?.page?.selectComponent?.(`#${countUp.current?.sid}`) as any
const comp = getCurrentInstance()?.page?.selectComponent?.(`#${countUp.current.sid}`) as any
comp?.stop?.()
console.log(comp, 11)
}
}, [isSubmit])
......
import { action, Action, computed, Computed, State, Thunk, thunk } from 'easy-peasy'
import { action, Action, computed, Computed, Thunk, thunk } from 'easy-peasy'
import { AppStoreModel } from '@/store/store-model'
import { getQuestionList, type StageDetail, getStageDetail, completeStage, StageType, type CompleteStageOut, StageLevel } from '@/api'
import { showLoading, hideLoading, showModal, redirectTo, vibrateShort } from '@tarojs/taro'
......@@ -17,24 +17,29 @@ interface CompleteStageDetail extends CompleteStageOut {
levelTime: number;
}
export interface GameModel {
interface GameModelState {
/** 题目列表 */
questionList: QuestionType[];
stageDetail: StageDetail | null;
gameResult: CompleteStageDetail | null;
gameStartTime: number;
updateState: Action<GameModel, Partial<State<GameModel>>>;
/** 当前题目 */
currentQuestion: Computed<GameModel, QuestionType | undefined>;
/** 当前题目下标 */
currentQuestionIndex: number;
/** 当前输入框下标 */
currentInputIndex: number;
isSubmit: boolean;
modalContinueVisible: boolean;
}
export interface GameModel extends GameModelState {
updateState: Action<GameModel, Partial<GameModelState>>;
/** 当前题目 */
currentQuestion: Computed<GameModel, QuestionType | undefined>;
/** 题目答案和用户答案 */
questionAnswers: Computed<GameModel, QuestionAnswer[] | undefined>;
/** 更新当前题目下标 */
updateCurrentIndex: Action<GameModel, number>;
/** 当前输入框下标 */
currentInputIndex: number;
/** 更新当前输入框下标 */
updateCurrentInputIndex: Action<GameModel, number>;
/** 更新用户输入 */
......@@ -51,9 +56,6 @@ export interface GameModel {
getStageDetail: Thunk<GameModel, number, void, AppStoreModel>;
handleGoNext: Thunk<GameModel, void, void, AppStoreModel>;
isSubmit: boolean;
modalContinueVisible: boolean;
submit: Thunk<GameModel, void, void, AppStoreModel>;
}
......@@ -214,6 +216,10 @@ const gameModel: GameModel = {
const { data: questionList } = await getQuestionList(round)
actions.updateState({
questionList: questionList.map(convertQuestion),
currentInputIndex: 0,
isSubmit: false,
currentQuestionIndex: 0,
modalContinueVisible: false,
gameStartTime: Date.now(),
})
// hideLoading()
......@@ -225,7 +231,9 @@ const gameModel: GameModel = {
showCancel: false,
})
actions.updateState({
stageDetail: null
questionList: [],
currentInputIndex: 0,
currentQuestionIndex: 0,
})
}
}),
......@@ -247,18 +255,17 @@ const gameModel: GameModel = {
levelTime: params.levelTime
}
})
hideLoading()
redirectTo({
url: '/pages/game/complete/index',
})
} catch (err) {
hideLoading()
showModal({
title: '提示',
content: err.message || '出错了',
showCancel: false,
})
console.log(err)
} finally {
hideLoading()
}
}),
}
......
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