Commit da8c92e0 authored by hewenhao's avatar hewenhao

feat: update

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