Commit f1c49d87 authored by m's avatar m

feat: update

parents 051dd08d adedecb8
......@@ -13,7 +13,14 @@ declare module '*.styl';
type CountUptime = React.FC<{ maxNum }>
type CountUpTime = React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement> & { 'max-value'?: number, onTimeup?: () => void }, HTMLElement>
type CountUpTime = React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement> & {
'maxValue'?: number;
'isDown'?: boolean;
'startValue': number;
exceedTime: number;
onTimeup?: () => void;
onExceed?: () => void;
}, HTMLElement>
declare namespace JSX{
interface IntrinsicElements {
......
import { request, requestAfterSilentLogin } from '@/utils/request'
import type { UserInfo } from '@/types'
type LoginResult = {
phone?: string | null;
/** 用户openId */
openId: string;
/** 用户昵称 */
nickname?: string | null;
/** 用户头像 */
avatarUrl?: string | null;
/** 登录token */
token: string;
/** 用户ID */
userId: number;
/** */
unionId: string;
}
type LoginResult = UserInfo
/** 静默登录 */
export function silentLoginApi (code: string) {
......
......@@ -10,6 +10,14 @@ export const getQuestionList = (stageId: number) => {
}))
}
export const resumeGame = (stageId: number) => {
return requestAfterSilentLogin<null, { stageId: number, userId?: number }>(userInfo => ({
method: 'GET',
url: '/service-idea/stage/resumeStage',
data: { stageId, userId: userInfo?.userId }
}))
}
export const enum StageStatus {
CURRENT = 'CURRENT',
DISABLED = 'DISABLED',
......@@ -19,7 +27,7 @@ export const enum StageStatus {
export const enum StageType {
Strong = '强化',
Enhance = '应用',
OneStop = '一站到底',
OneStop = '一战到底',
}
export const enum StageLevel {
......@@ -46,7 +54,7 @@ export type StageRank = {
bestResultTime: number;
firstResultTime: number;
me: boolean;
nickName: string;
nickName: string | null;
no: number;
secondName: string;
userId: number;
......
......@@ -30,14 +30,22 @@
}
.bg {
width: 100%;
height: 100%;
width: calc(100% + 48px);
position: absolute;
left: 0;
top: 0;
bottom: 0;
right: 0;
z-index: 1;
&.left {
right: -48px;
}
&.right {
left: -48px;
}
}
.icon {
......
import { useState, useImperativeHandle, forwardRef, useCallback, type ForwardRefRenderFunction } from 'react'
import { View, Image } from '@tarojs/components'
import { switchTab } from '@tarojs/taro'
import classNames from 'classnames'
import styles from './index.module.scss'
type TabbarRef = {
......@@ -28,13 +29,13 @@ const Tabbar: ForwardRefRenderFunction<TabbarRef, {}> = (_, ref) => {
<View className={styles.inner}>
<View className={styles.left} onClick={() => _switchTab(0, '/pages/main/main')}>
{selected === 0 && (
<Image src="/assets/tabbar/personal-bg.png" className={styles.bg}></Image>
<Image src="/assets/tabbar/personal-bg.png" className={classNames(styles.bg, styles.left)}></Image>
)}
<Image src="/assets/tabbar/personal-on.png" className={styles.icon} />
</View>
<View className={styles.right} onClick={() => _switchTab(1, '/pages/group/index')}>
{selected === 1 && (
<Image src="/assets/tabbar/group-bg.png" className={styles.bg}></Image>
<Image src="/assets/tabbar/group-bg.png" className={classNames(styles.bg, styles.right)}></Image>
)}
<Image src="/assets/tabbar/group-on.png" className={styles.icon} />
</View>
......
......@@ -27,16 +27,28 @@ Component({
type: Number,
value: 100 * 60 * 60
},
isDown: {
type: Boolean,
value: false,
},
startValue: {
type: Number,
value: 0
},
exceedTime: {
type: Number,
value: 20
}
},
data: {
minutes: '00',
seconds: '00'
seconds: '00',
},
attached () {
this._tick = 0
this.startCount()
this._tick = this.data.startValue
this.start()
console.log(this)
},
......@@ -46,13 +58,33 @@ Component({
clearInterval(this._timer)
}
},
startCount () {
getCount () {
if (this.data.isDown) {
return this.data.startValue - this._tick
}
return this._tick
},
start () {
this.stop()
this._timer = setInterval(() => {
this._tick += 1
if (this._tick >= this.data.maxValue) {
this.stop()
this.triggerEvent('timeup')
const isDown = this.data.isDown
if (isDown) {
this._tick -= 1
if (this._tick <= 0) {
this.stop()
this.triggerEvent('timeup')
}
if (this._tick === this.data.exceedTime) {
this.triggerEvent('exceed')
}
} else {
this._tick += 1
if (this._tick >= this.data.maxValue) {
this.stop()
this.triggerEvent('timeup')
}
}
const { minutes, seconds } = this.data
const val = this._tick * 1000
......@@ -70,11 +102,6 @@ Component({
this.setData(opts)
}, 1000)
},
onMyButtonTap: function () {
this.setData({
// 更新属性和数据的方法与更新页面数据的方法类似
})
},
}
})
......@@ -13,6 +13,67 @@
align-items: center;
background: #F7F7F7;
border-radius: 32px;
animation-name: fadeIn;
animation-duration: .5s;
animation-timing-function: ease-out;
animation-iteration-count: 1;
animation-fill-mode: backwards;
&:nth-child(1) {
animation-delay: 0.5s;
}
&:nth-child(2) {
animation-delay: 1s;
}
&:nth-child(3) {
animation-delay: 1.5s;
}
&:nth-child(4) {
animation-delay: 2s;
}
}
@keyframes fadeIn {
0% {
opacity: 0;
transform: scale3d(1.5, 1.5, 1) translateY(100px);
}
100% {
opacity: 1;
transform: scale3d(1, 1, 1) translateY(0px);
}
}
.icon_wrap {
position: relative;
margin-right: 24px;
}
.rocket {
position: absolute;
width: 34px;
height: 32px;
bottom: 0;
right: -10px;
animation-name: updown;
animation-timing-function: ease-in-out;
animation-duration: 1.3s;
animation-iteration-count: infinite;
animation-delay: 0s;
}
@keyframes updown {
0% {
transform: translateY(-10px);
}
50% {
transform: translateY(0px);
}
100% {
transform: translateY(-10px);
}
}
.achieve_item_main {
......@@ -67,7 +128,6 @@
.achieve_icon {
width: 96px;
height: 96px;
margin-right: 24px;
}
.bonus_icon {
......@@ -103,6 +163,18 @@
}
}
.fail {
display: flex;
align-items: center;
justify-content: center;
padding-top: 10vh;
}
.fail_icon {
width: 498px;
height: 96px;
}
.gap {
height: 160px;
}
......
import { View, Image, Text } from '@tarojs/components'
import assets from '@/assets/oss/assets-complete'
import { useMemo } from 'react'
import { useMemo, useCallback } from 'react'
import { navigateBack } from '@tarojs/taro'
import classNames from 'classnames'
import { useStoreState } from '@/store/hooks'
import { StageLevel } from '@/api'
......@@ -68,11 +69,16 @@ const GameCompleteAchieve = () => {
return Math.ceil(rankNo / 500) * 500
}, [rankNo])
const handleContinue = useCallback(() => {
navigateBack()
}, [])
const renderBtn = () => (
<View className={styles.footer}>
<View
className={styles.btn_continue}
hoverClass={styles.is_active}
onClick={handleContinue}
>
继续
</View>
......@@ -83,10 +89,12 @@ const GameCompleteAchieve = () => {
return null
}
if (gameResult.errNum > 0) {
if (gameResult.errNum > 0 || !gameResult.level) {
return (
<>
<View>没关系,差一点就成功了! 加油!加油!</View>
<View className={classNames(styles.wrap, styles.fail)}>
<Image src={require('../assets/fail.png')} className={styles.fail_icon}></Image>
</View>
{renderBtn()}
</>
)
......@@ -96,68 +104,75 @@ const GameCompleteAchieve = () => {
<>
<View className={styles.wrap}>
<View className={styles.title}>本关成就获得</View>
<View className={styles.achieve_item}>
<Image src={level} className={styles.achieve_icon}></Image>
<View className={cs.flex__item}>
<View className={styles.main_text}>
{gameResult.level}等级
<Text className={classNames(styles.first_time, gameResult.levelReward <= 0 && styles.is_second)}>
{gameResult.levelReward > 0 ? '首次达成' : '二次达成'}
</Text>
</View>
<View className={styles.tips_text}>全对且用时≤{time.minutes}分{time.seconds}秒</View>
</View>
{gameResult.levelReward > 0 && (
<View>
<Image src={require('../assets/bonus.png')} className={styles.bonus_icon}></Image>
<View className={styles.bonus_text}>+{gameResult.levelReward}</View>
</View>
)}
</View>
{topIcon && (
<View>
<View className={styles.achieve_item}>
<Image src={topIcon} className={styles.achieve_icon}></Image>
<View className={styles.icon_wrap}>
<Image src={level} className={styles.achieve_icon} />
{gameResult.levelReward > 0 && (
<Image src={require('../assets/rocket.png')} className={styles.rocket} />
)}
</View>
<View className={cs.flex__item}>
<View className={styles.main_text}>
TOP {gameResult?.gear ?? 0}%
<Text className={classNames(styles.first_time, gameResult.gearReward <= 0 && styles.is_second)}>
{gameResult.gearReward > 0 ? '首次达成' : '二次达成'}
{gameResult.level}等级
<Text className={classNames(styles.first_time, gameResult.levelReward <= 0 && styles.is_second)}>
{gameResult.levelReward > 0 ? '首次达成' : '二次达成'}
</Text>
</View>
<View className={styles.tips_text}>恭喜你成为了最优秀的{gameResult?.gear ?? 0}%</View>
<View className={styles.tips_text}>全对且用时≤{time.minutes}分{time.seconds}秒</View>
</View>
{gameResult.gearReward > 0 && (
{gameResult.levelReward > 0 && (
<View>
<Image src={require('../assets/bonus.png')} className={styles.bonus_icon}></Image>
<View className={styles.bonus_text}>+{gameResult.gearReward}</View>
<View className={styles.bonus_text}>+{gameResult.levelReward}</View>
</View>
)}
</View>
)}
{topIcon && (
<View className={styles.achieve_item}>
<Image src={topIcon} className={styles.achieve_icon}></Image>
<View className={cs.flex__item}>
<View className={styles.main_text}>
TOP {gameResult?.gear ?? 0}%
<Text className={classNames(styles.first_time, gameResult.gearReward <= 0 && styles.is_second)}>
{gameResult.gearReward > 0 ? '首次达成' : '二次达成'}
</Text>
</View>
<View className={styles.tips_text}>恭喜你成为了最优秀的{gameResult?.gear ?? 0}%</View>
</View>
{gameResult.gearReward > 0 && (
<View>
<Image src={require('../assets/bonus.png')} className={styles.bonus_icon}></Image>
<View className={styles.bonus_text}>+{gameResult.gearReward}</View>
</View>
)}
</View>
)}
<View className={styles.achieve_item}>
<Image src={assets['rank.png'].u} className={styles.achieve_icon}></Image>
<View className={cs.flex__item}>
<View className={styles.main_text}>全市排名</View>
<View className={styles.tips_text}>恭喜你进入了全市前{rankNoS}名</View>
</View>
<View className={styles.rank_text}>{rankNo}名</View>
</View>
{gameResult?.upGear && (
<View className={styles.achieve_item}>
<Image src={assets['upgear.png'].u} className={styles.achieve_icon}></Image>
<Image src={assets['rank.png'].u} className={styles.achieve_icon}></Image>
<View className={cs.flex__item}>
<View className={styles.main_text}>升档成功</View>
<View className={styles.tips_text}>提升到{gameResult.gear - 10}%-{gameResult.gear}%</View>
<View className={styles.main_text}>全市排名</View>
<View className={styles.tips_text}>恭喜你进入了全市前{rankNoS}名</View>
</View>
{gameResult.upGearReward > 0 && (
<View>
<Image src={require('../assets/bonus.png')} className={styles.bonus_icon}></Image>
<View className={styles.bonus_text}>+{gameResult.upGearReward}</View>
</View>
)}
<View className={styles.rank_text}>{rankNo}名</View>
</View>
)}
{gameResult?.upGear && (
<View className={styles.achieve_item}>
<Image src={assets['upgear.png'].u} className={styles.achieve_icon}></Image>
<View className={cs.flex__item}>
<View className={styles.main_text}>升档成功</View>
<View className={styles.tips_text}>提升到{gameResult.gear - 10}%-{gameResult.gear}%</View>
</View>
{gameResult.upGearReward > 0 && (
<View>
<Image src={require('../assets/bonus.png')} className={styles.bonus_icon}></Image>
<View className={styles.bonus_text}>+{gameResult.upGearReward}</View>
</View>
)}
</View>
)}
</View>
<View className={styles.gap}></View>
</View>
{renderBtn()}
......
......@@ -20,6 +20,23 @@
display: block;
margin: 0 auto;
height: 536px;
animation-name: fadeIn;
animation-duration: .5s;
animation-timing-function: ease-out;
animation-iteration-count: 1;
animation-fill-mode: backwards;
animation-delay: 0s;
}
@keyframes fadeIn {
0% {
opacity: 0;
transform: scale3d(1.5, 1.5, 1) translateY(100px);
}
100% {
opacity: 1;
transform: scale3d(1, 1, 1) translateY(0px);
}
}
.tips {
......
......@@ -2,6 +2,10 @@
padding: 40px 32px 100px 32px;
display: flex;
align-items: center;
&.is_stop {
padding-bottom: 50px;
}
}
.process {
......@@ -27,6 +31,10 @@
color: #465164;
line-height: 46px;
&.red {
color: #FF7770;
}
.icon {
width: 32px;
height: 32px;
......
import { View, Image } from '@tarojs/components'
import { useState, useEffect, useCallback, useMemo, useRef } from 'react'
import { createSelectorQuery, getCurrentInstance } from '@tarojs/taro'
import { useStoreState } from '@/store/hooks'
import { type StageDetail } from '@/api'
import { useState, useEffect, useCallback, useMemo } from 'react'
import { createSelectorQuery } from '@tarojs/taro'
import classNames from 'classnames'
import { useBoolean } from '@/hooks'
import { useStoreState, useStoreActions } from '@/store/hooks'
import { type StageDetail, StageType } from '@/api'
import styles from './count-up.module.scss'
......@@ -15,10 +17,12 @@ type CountUpProps = {
const CountUp = (props: CountUpProps) => {
const { stageDetail } = props
const currentQuestionIndex = useStoreState(states => states.gameModel.currentQuestionIndex)
const counterId = useStoreState(states => states.gameModel.counterId)
const questionList = useStoreState(state => state.gameModel.questionList)
const isSubmit = useStoreState(state => state.gameModel.isSubmit)
const submit = useStoreActions(actions => actions.gameModel.submit)
const [width, setWidth] = useState(0)
const countUp = useRef<any>(null)
const [isExceed, exceedActions] = useBoolean(false)
const questionLength = useMemo(() => {
return questionList.length
......@@ -35,6 +39,17 @@ const CountUp = (props: CountUpProps) => {
})
}, [])
const isOneStop = useMemo(() => {
return stageDetail.type === StageType.OneStop
}, [stageDetail])
const startTick = useMemo(() => {
if (stageDetail.type === StageType.OneStop) {
return stageDetail.bTime
}
return 0
}, [stageDetail])
const roleStyle = useMemo(() => {
return {
transform: `translateX(${width}px)`,
......@@ -42,14 +57,6 @@ const CountUp = (props: CountUpProps) => {
}
}, [width, stageDetail.bTime])
useEffect(() => {
if (isSubmit && countUp.current?.sid) {
console.log(countUp.current)
const comp = getCurrentInstance()?.page?.selectComponent?.(`#${countUp.current.sid}`) as any
comp?.stop?.()
}
}, [isSubmit])
const processInnerStyle = useMemo(() => {
if (isSubmit) {
return {
......@@ -63,21 +70,37 @@ const CountUp = (props: CountUpProps) => {
const handleTimeUp = useCallback(() => {
console.log('upd1')
}, [])
if (isOneStop) {
submit()
}
}, [submit, isOneStop])
return (
<View className={styles.count}>
<View className={classNames(styles.count, isOneStop && styles.is_stop)}>
<View className={styles.process} id={id}>
<View className={styles.process_inner} style={processInnerStyle}></View>
<View className={styles.role} style={roleStyle}>
<View className={styles.tick}></View>
<Image src={require('../assets/count-cat.png')} className={styles.cat}></Image>
<View className={styles.tips}>通关要求</View>
</View>
{!isOneStop && (
<View className={styles.role} style={roleStyle}>
<View className={styles.tick}></View>
<Image src={require('../assets/count-cat.png')} className={styles.cat}></Image>
<View className={styles.tips}>通关要求</View>
</View>
)}
</View>
<View className={styles.time}>
<Image src={require('../assets/count-time.png')} className={styles.icon}></Image>
<count-up-time max-value={60 * 60} onTimeup={handleTimeUp} ref={countUp} />
<View className={classNames(styles.time, isExceed && styles.red)}>
{isExceed
? (<Image src={require('../assets/time-red.png')} className={styles.icon}></Image>)
: (<Image src={require('../assets/count-time.png')} className={styles.icon}></Image>)
}
<count-up-time
exceedTime={20}
onExceed={exceedActions.setTrue}
maxValue={60 * 60}
startValue={startTick}
isDown={isOneStop}
onTimeup={handleTimeUp}
id={counterId}
/>
</View>
</View>
)
......
......@@ -19,6 +19,8 @@ const ModalContinue = (props: ModalContinueProps) => {
const cardNum = useStoreState(state => state.userModel.cardNum)
const fetchAccount = useStoreActions(actions => actions.userModel.fetchAccount)
const submit = useStoreActions(actions => actions.gameModel.submit)
const reborn = useStoreActions(actions => actions.gameModel.reborn)
const handleClick = useCallback(() => {
if (closeOnClickModal) {
......@@ -32,6 +34,10 @@ const ModalContinue = (props: ModalContinueProps) => {
}
}, [fetchAccount, modalContinueVisible])
const handleReborn = useCallback(() => {
reborn()
}, [reborn])
return (
<RootPortal>
<View className={classNames(styles.mask, modalContinueVisible && styles.is_show)} onClick={handleClick}>
......@@ -43,12 +49,14 @@ const ModalContinue = (props: ModalContinueProps) => {
<View
className={styles.btn_left}
hoverClass={styles.is_active}
onClick={() => submit()}
>
放弃
</View>
<View
className={classNames(styles.btn_right, !canGoNext && styles.disabled)}
hoverClass={canGoNext ? styles.is_active : null}
onClick={handleReborn}
>
<Image src={require('@/pages/main/assets/ph.png')} className={styles.icon}></Image>
<Text>-1 继续</Text>
......
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'
import { getQuestionList, type StageDetail, getStageDetail, completeStage, StageType, type CompleteStageOut, resumeGame } from '@/api'
import { showLoading, hideLoading, showModal, redirectTo, vibrateShort, getCurrentInstance } from '@tarojs/taro'
import {
QuestionType,
QuestionAnswer,
......@@ -10,13 +10,20 @@ import {
} from '../types'
import { buildCompleteStageParam, convertQuestion, determinQuestion } from './utils'
import questionListJson from './test.json'
interface CompleteStageDetail extends CompleteStageOut {
errNum: number;
levelTime: number;
}
const COUNTER_ID = 'z__countdown__'
const getCounter = () => {
return getCurrentInstance()?.page?.selectComponent?.(`#${COUNTER_ID}`) as any
}
const stopCounter = () => getCounter()?.stop()
const startCounter = () => getCounter()?.start()
interface GameModelState {
/** 题目列表 */
questionList: QuestionType[];
......@@ -30,6 +37,11 @@ interface GameModelState {
isSubmit: boolean;
modalContinueVisible: boolean;
/** 是否复活过 */
isReborn: boolean;
/** 计时器id */
counterId: string;
}
export interface GameModel extends GameModelState {
......@@ -58,28 +70,15 @@ export interface GameModel extends GameModelState {
handleGoNext: Thunk<GameModel, void, void, AppStoreModel>;
submit: Thunk<GameModel, void, void, AppStoreModel>;
reborn: Thunk<GameModel, void, void, AppStoreModel>;
}
const gameModel: GameModel = {
questionList: questionListJson as QuestionType[],
gameResult: {
/** 排名档位 */
gear: 10,
gearReward: 10,
levelBefore: StageLevel.B,
levelReward: 20,
upGearReward: 40,
errNum: 0,
/** 成就等级:SAB */
level: StageLevel.B,
levelTime: 50,
/** 排名 */
ranks: [],
/** 耗时 */
resultTime: 60,
/** 是否升档奖励 */
upGear: true
},
counterId: COUNTER_ID,
questionList: [],
gameResult: null,
isReborn: false,
modalContinueVisible: false,
gameStartTime: 0,
isSubmit: false,
......@@ -171,26 +170,49 @@ const gameModel: GameModel = {
}),
handleGoNext: thunk(async (actions, _, helpers) => {
const { canGoNext, currentQuestionIndex, questionList, stageDetail, currentQuestion } = helpers.getState()
const { canGoNext, currentQuestionIndex, questionList, stageDetail, currentQuestion, isReborn } = helpers.getState()
if (!canGoNext) return
if (questionList.length === currentQuestionIndex + 1) {
console.log('submit')
actions.submit()
if (stageDetail?.type === StageType.OneStop && currentQuestion && !determinQuestion(currentQuestion)) {
const cardNum = helpers.getStoreState().userModel.cardNum
/** 没有复活过并且有答题卡 */
if (!isReborn && cardNum > 0) {
stopCounter()
actions.updateState({ modalContinueVisible: true, isReborn: true })
} else {
actions.submit()
}
return
}
if (stageDetail?.type === StageType.OneStop) {
if (currentQuestion && !determinQuestion(currentQuestion)) {
actions.updateState({
modalContinueVisible: true,
})
return
}
if (questionList.length === currentQuestionIndex + 1) {
actions.submit()
return
}
actions.updateCurrentIndex(currentQuestionIndex + 1)
}),
reborn: thunk(async (actions, _, helpers) => {
const { stageDetail } = helpers.getState()
if (!stageDetail) return
try {
await resumeGame(stageDetail.id)
helpers.getStoreActions().userModel.fetchAccount()
startCounter()
actions.updateState({ modalContinueVisible: false })
} catch (err) {
showModal({
title: '提示',
showCancel: false,
content: err.message,
success: () => {
actions.submit()
}
})
}
}),
getStageDetail: thunk(async (actions, round) => {
try {
showLoading()
......@@ -210,7 +232,7 @@ const gameModel: GameModel = {
}
}),
getQuestionList: thunk(async (actions, round) => {
getQuestionList: thunk(async (actions, round, helpers) => {
try {
// showLoading()
const { data: questionList } = await getQuestionList(round)
......@@ -220,8 +242,11 @@ const gameModel: GameModel = {
isSubmit: false,
currentQuestionIndex: 0,
modalContinueVisible: false,
isReborn: false,
gameStartTime: Date.now(),
})
/** 更新账户余额 */
helpers.getStoreActions().userModel.fetchAccount()
// hideLoading()
} catch (err) {
// hideLoading()
......@@ -245,8 +270,9 @@ const gameModel: GameModel = {
title: '提交中'
})
actions.updateState({ isSubmit: true })
const { questionList, gameStartTime, stageDetail } = helpers.getState()
const params = buildCompleteStageParam(questionList, stageDetail!, gameStartTime)
stopCounter()
const { questionList, stageDetail } = helpers.getState()
const params = buildCompleteStageParam(questionList, stageDetail!, getCounter()?.getCount() ?? 0)
const { data: gameResult } = await completeStage(params)
actions.updateState({
gameResult: {
......
[
{
"answers": [{ "contentText": "11", "sort": 0 }],
"contentText": "1<MathSymbol value=\"+\" />10<MathSymbol value=\"=\" /><AnswerBlank index=\"0\" />",
"questionItems": [
{ "contentText": "1", "sort": 0 },
{ "contentText": "10", "sort": 1 },
{ "contentText": "11", "sort": 2 }
],
"questionType": "随机填空",
"simpleType": false
},
{
"answers": [{ "contentText": "11", "sort": 0 }],
"contentText": "1<MathSymbol value=\"+\" />10<MathSymbol value=\"=\" /><AnswerBlank index=\"0\" />",
"questionItems": [
{ "contentText": "1", "sort": 0 },
{ "contentText": "10", "sort": 1 },
{ "contentText": "11", "sort": 2 }
],
"questionType": "随机填空",
"simpleType": false
},
{
"answers": [{ "contentText": "30", "sort": 0 }],
"contentText": "18<MathSymbol value=\"+\" />12<MathSymbol value=\"=\" /><AnswerBlank index=\"0\" />",
"questionItems": [
{ "contentText": "18", "sort": 0 },
{ "contentText": "12", "sort": 1 },
{ "contentText": "30", "sort": 2 }
],
"questionType": "随机填空",
"simpleType": false
},
{
"answers": [{ "contentText": "39", "sort": 0 }],
"contentText": "34<MathSymbol value=\"+\" />5<MathSymbol value=\"=\" /><AnswerBlank index=\"0\" />",
"questionItems": [
{ "contentText": "34", "sort": 0 },
{ "contentText": "5", "sort": 1 },
{ "contentText": "39", "sort": 2 }
],
"questionType": "随机填空",
"simpleType": false
},
{
"answers": [{ "contentText": "95", "sort": 0 }],
"contentText": "48<MathSymbol value=\"+\" />47<MathSymbol value=\"=\" /><AnswerBlank index=\"0\" />",
"questionItems": [
{ "contentText": "48", "sort": 0 },
{ "contentText": "47", "sort": 1 },
{ "contentText": "95", "sort": 2 }
],
"questionType": "随机填空",
"simpleType": false
},
{
"answers": [{ "contentText": "65", "sort": 0 }],
"contentText": "22<MathSymbol value=\"+\" />43<MathSymbol value=\"=\" /><AnswerBlank index=\"0\" />",
"questionItems": [
{ "contentText": "22", "sort": 0 },
{ "contentText": "43", "sort": 1 },
{ "contentText": "65", "sort": 2 }
],
"questionType": "随机填空",
"simpleType": false
},
{
"answers": [{ "contentText": "28", "sort": 0 }],
"contentText": "16<MathSymbol value=\"+\" />12<MathSymbol value=\"=\" /><AnswerBlank index=\"0\" />",
"questionItems": [
{ "contentText": "16", "sort": 0 },
{ "contentText": "12", "sort": 1 },
{ "contentText": "28", "sort": 2 }
],
"questionType": "随机填空",
"simpleType": false
},
{
"answers": [{ "contentText": "50", "sort": 0 }],
"contentText": "2<MathSymbol value=\"+\" />48<MathSymbol value=\"=\" /><AnswerBlank index=\"0\" />",
"questionItems": [
{ "contentText": "2", "sort": 0 },
{ "contentText": "48", "sort": 1 },
{ "contentText": "50", "sort": 2 }
],
"questionType": "随机填空",
"simpleType": false
},
{
"answers": [{ "contentText": "65", "sort": 0 }],
"contentText": "46<MathSymbol value=\"+\" />19<MathSymbol value=\"=\" /><AnswerBlank index=\"0\" />",
"questionItems": [
{ "contentText": "46", "sort": 0 },
{ "contentText": "19", "sort": 1 },
{ "contentText": "65", "sort": 2 }
],
"questionType": "随机填空",
"simpleType": false
},
{
"answers": [{ "contentText": "84", "sort": 0 }],
"contentText": "48<MathSymbol value=\"+\" />36<MathSymbol value=\"=\" /><AnswerBlank index=\"0\" />",
"questionItems": [
{ "contentText": "48", "sort": 0 },
{ "contentText": "36", "sort": 1 },
{ "contentText": "84", "sort": 2 }
],
"questionType": "随机填空",
"simpleType": false
}
]
[
{
"answers": [{ "contentText": "32", "sort": 0 }],
"contentText": "48<MathSymbol value=\"+\" /><AnswerBlank index=\"0\" /><MathSymbol value=\"=\" />80",
"questionItems": [
{ "contentText": "48", "sort": 0 },
{ "contentText": "32", "sort": 1 },
{ "contentText": "80", "sort": 2 }
],
"questionType": "随机填空",
"simpleType": false
},
{
"answers": [{ "contentText": "53", "sort": 0 }],
"contentText": "14<MathSymbol value=\"+\" />39<MathSymbol value=\"=\" /><AnswerBlank index=\"0\" />",
"questionItems": [
{ "contentText": "14", "sort": 0 },
{ "contentText": "39", "sort": 1 },
{ "contentText": "53", "sort": 2 }
],
"questionType": "随机填空",
"simpleType": false
},
{
"answers": [{ "contentText": "62", "sort": 0 }],
"contentText": "39<MathSymbol value=\"+\" />23<MathSymbol value=\"=\" /><AnswerBlank index=\"0\" />",
"questionItems": [
{ "contentText": "39", "sort": 0 },
{ "contentText": "23", "sort": 1 },
{ "contentText": "62", "sort": 2 }
],
"questionType": "随机填空",
"simpleType": false
},
{
"answers": [{ "contentText": "83", "sort": 0 }],
"contentText": "49<MathSymbol value=\"+\" />34<MathSymbol value=\"=\" /><AnswerBlank index=\"0\" />",
"questionItems": [
{ "contentText": "49", "sort": 0 },
{ "contentText": "34", "sort": 1 },
{ "contentText": "83", "sort": 2 }
],
"questionType": "随机填空",
"simpleType": false
},
{
"answers": [{ "contentText": "35", "sort": 0 }],
"contentText": "10<MathSymbol value=\"+\" /><AnswerBlank index=\"0\" /><MathSymbol value=\"=\" />45",
"questionItems": [
{ "contentText": "10", "sort": 0 },
{ "contentText": "35", "sort": 1 },
{ "contentText": "45", "sort": 2 }
],
"questionType": "随机填空",
"simpleType": false
},
{
"answers": [{ "contentText": "58", "sort": 0 }],
"contentText": "48<MathSymbol value=\"+\" />10<MathSymbol value=\"=\" /><AnswerBlank index=\"0\" />",
"questionItems": [
{ "contentText": "48", "sort": 0 },
{ "contentText": "10", "sort": 1 },
{ "contentText": "58", "sort": 2 }
],
"questionType": "随机填空",
"simpleType": false
},
{
"answers": [{ "contentText": "18", "sort": 0 }],
"contentText": "4<MathSymbol value=\"+\" />14<MathSymbol value=\"=\" /><AnswerBlank index=\"0\" />",
"questionItems": [
{ "contentText": "4", "sort": 0 },
{ "contentText": "14", "sort": 1 },
{ "contentText": "18", "sort": 2 }
],
"questionType": "随机填空",
"simpleType": false
},
{
"answers": [{ "contentText": "1", "sort": 0 }],
"contentText": "<AnswerBlank index=\"0\" /><MathSymbol value=\"+\" />44<MathSymbol value=\"=\" />45",
"questionItems": [
{ "contentText": "1", "sort": 0 },
{ "contentText": "44", "sort": 1 },
{ "contentText": "45", "sort": 2 }
],
"questionType": "随机填空",
"simpleType": false
},
{
"answers": [{ "contentText": "0", "sort": 0 }],
"contentText": "9<MathSymbol value=\"+\" /><AnswerBlank index=\"0\" /><MathSymbol value=\"=\" />9",
"questionItems": [
{ "contentText": "9", "sort": 0 },
{ "contentText": "0", "sort": 1 },
{ "contentText": "9", "sort": 2 }
],
"questionType": "随机填空",
"simpleType": false
},
{
"answers": [{ "contentText": "6", "sort": 0 }],
"contentText": "<AnswerBlank index=\"0\" /><MathSymbol value=\"+\" />44<MathSymbol value=\"=\" />50",
"questionItems": [
{ "contentText": "6", "sort": 0 },
{ "contentText": "44", "sort": 1 },
{ "contentText": "50", "sort": 2 }
],
"questionType": "随机填空",
"simpleType": false
}
]
[
{
"answers": [{ "contentText": "20", "sort": 0 }],
"contentText": "<AnswerBlank index=\"0\" />元钱可以买1元笔记本21本",
"questionItems": [
{ "contentText": "20", "sort": 0 },
{ "contentText": "1", "sort": 1 },
{ "contentText": "21", "sort": 2 }
],
"questionType": "随机填空",
"simpleType": false
},
{
"answers": [{ "contentText": "74", "sort": 0 }],
"contentText": "48元钱可以买26元笔记本<AnswerBlank index=\"0\" />本",
"questionItems": [
{ "contentText": "48", "sort": 0 },
{ "contentText": "26", "sort": 1 },
{ "contentText": "74", "sort": 2 }
],
"questionType": "随机填空",
"simpleType": false
},
{
"answers": [{ "contentText": "32", "sort": 0 }],
"contentText": "<AnswerBlank index=\"0\" />元钱可以买24元笔记本56本",
"questionItems": [
{ "contentText": "32", "sort": 0 },
{ "contentText": "24", "sort": 1 },
{ "contentText": "56", "sort": 2 }
],
"questionType": "随机填空",
"simpleType": false
},
{
"answers": [{ "contentText": "19", "sort": 0 }],
"contentText": "9元钱可以买10元笔记本<AnswerBlank index=\"0\" />本",
"questionItems": [
{ "contentText": "9", "sort": 0 },
{ "contentText": "10", "sort": 1 },
{ "contentText": "19", "sort": 2 }
],
"questionType": "随机填空",
"simpleType": false
},
{
"answers": [{ "contentText": "12", "sort": 0 }],
"contentText": "11元钱可以买1元笔记本<AnswerBlank index=\"0\" />本",
"questionItems": [
{ "contentText": "11", "sort": 0 },
{ "contentText": "1", "sort": 1 },
{ "contentText": "12", "sort": 2 }
],
"questionType": "随机填空",
"simpleType": false
},
{
"answers": [{ "contentText": "66", "sort": 0 }],
"contentText": "30元钱可以买36元笔记本<AnswerBlank index=\"0\" />本",
"questionItems": [
{ "contentText": "30", "sort": 0 },
{ "contentText": "36", "sort": 1 },
{ "contentText": "66", "sort": 2 }
],
"questionType": "随机填空",
"simpleType": false
},
{
"answers": [{ "contentText": "2", "sort": 0 }],
"contentText": "<AnswerBlank index=\"0\" />元钱可以买7元笔记本9本",
"questionItems": [
{ "contentText": "2", "sort": 0 },
{ "contentText": "7", "sort": 1 },
{ "contentText": "9", "sort": 2 }
],
"questionType": "随机填空",
"simpleType": false
},
{
"answers": [{ "contentText": "3", "sort": 0 }],
"contentText": "<AnswerBlank index=\"0\" />元钱可以买14元笔记本17本",
"questionItems": [
{ "contentText": "3", "sort": 0 },
{ "contentText": "14", "sort": 1 },
{ "contentText": "17", "sort": 2 }
],
"questionType": "随机填空",
"simpleType": false
},
{
"answers": [{ "contentText": "16", "sort": 0 }],
"contentText": "27元钱可以买<AnswerBlank index=\"0\" />元笔记本43本",
"questionItems": [
{ "contentText": "27", "sort": 0 },
{ "contentText": "16", "sort": 1 },
{ "contentText": "43", "sort": 2 }
],
"questionType": "随机填空",
"simpleType": false
},
{
"answers": [{ "contentText": "13", "sort": 0 }],
"contentText": "6元钱可以买<AnswerBlank index=\"0\" />元笔记本19本",
"questionItems": [
{ "contentText": "6", "sort": 0 },
{ "contentText": "13", "sort": 1 },
{ "contentText": "19", "sort": 2 }
],
"questionType": "随机填空",
"simpleType": false
}
]
[
{
"answers": [
{
"contentText": "69",
"sort": 0
}
],
"contentText": "28<MathSymbol value=\"+\" />41<MathSymbol value=\"=\" /><AnswerBlank index=\"0\" />",
"questionItems": [
{
"contentText": "28",
"sort": 0
},
{
"contentText": "41",
"sort": 1
},
{
"contentText": "69",
"sort": 2
}
],
"questionType": "随机填空",
"simpleType": true,
"sort": 11
},
{
"answers": [
{
"contentText": "44",
"sort": 0
}
],
"contentText": "30元钱可以买<AnswerBlank index=\"0\" />元笔记本74本",
"questionItems": [
{
"contentText": "30",
"sort": 0
},
{
"contentText": "44",
"sort": 1
},
{
"contentText": "74",
"sort": 2
}
],
"questionType": "随机填空",
"simpleType": false,
"sort": 13
},
{
"answers": [
{
"contentText": "C",
"sort": 1
}
],
"contentText": "爸爸把一盘糖果的一半给了弟弟,把剩下的糖果给了一半给姐姐,这时盘里还剩8块,请问盘里原来有几块糖?",
"options": [
{
"answer": false,
"contentText": "16块",
"index": "A"
},
{
"answer": false,
"contentText": "24块",
"index": "B"
},
{
"answer": true,
"contentText": "32块",
"index": "C"
},
{
"answer": false,
"contentText": "64块",
"index": "D"
}
],
"questionType": "选择题",
"simpleType": false,
"sort": 28
},
{
"answers": [
{
"contentText": "35",
"sort": 0
}
],
"contentText": "22<MathSymbol value=\"+\" />13<MathSymbol value=\"=\" /><AnswerBlank index=\"0\" />",
"questionItems": [
{
"contentText": "22",
"sort": 0
},
{
"contentText": "13",
"sort": 1
},
{
"contentText": "35",
"sort": 2
}
],
"questionType": "随机填空",
"simpleType": true,
"sort": 49
},
{
"answers": [
{
"contentText": "59",
"sort": 0
}
],
"contentText": "43元钱可以买16元笔记本<AnswerBlank index=\"0\" />本",
"questionItems": [
{
"contentText": "43",
"sort": 0
},
{
"contentText": "16",
"sort": 1
},
{
"contentText": "59",
"sort": 2
}
],
"questionType": "随机填空",
"simpleType": false,
"sort": 51
},
{
"answers": [
{
"contentText": "13",
"sort": 0
}
],
"contentText": "<AnswerBlank index=\"0\" />元钱可以买21元笔记本34本",
"questionItems": [
{
"contentText": "13",
"sort": 0
},
{
"contentText": "21",
"sort": 1
},
{
"contentText": "34",
"sort": 2
}
],
"questionType": "随机填空",
"simpleType": false,
"sort": 82
},
{
"answers": [
{
"contentText": "45",
"sort": 0
}
],
"contentText": "33<MathSymbol value=\"+\" />12<MathSymbol value=\"=\" /><AnswerBlank index=\"0\" />",
"questionItems": [
{
"contentText": "33",
"sort": 0
},
{
"contentText": "12",
"sort": 1
},
{
"contentText": "45",
"sort": 2
}
],
"questionType": "随机填空",
"simpleType": true,
"sort": 83
},
{
"answers": [
{
"contentText": "20",
"sort": 0
}
],
"contentText": "8<MathSymbol value=\"+\" />12<MathSymbol value=\"=\" /><AnswerBlank index=\"0\" />",
"questionItems": [
{
"contentText": "8",
"sort": 0
},
{
"contentText": "12",
"sort": 1
},
{
"contentText": "20",
"sort": 2
}
],
"questionType": "随机填空",
"simpleType": true,
"sort": 92
},
{
"answers": [
{
"contentText": "18",
"sort": 0
}
],
"contentText": "7<MathSymbol value=\"+\" />11<MathSymbol value=\"=\" /><AnswerBlank index=\"0\" />",
"questionItems": [
{
"contentText": "7",
"sort": 0
},
{
"contentText": "11",
"sort": 1
},
{
"contentText": "18",
"sort": 2
}
],
"questionType": "随机填空",
"simpleType": true,
"sort": 95
},
{
"answers": [
{
"contentText": "C",
"sort": 1
}
],
"contentText": "《钢铁是怎样炼成的》是前苏联作家奥斯特洛夫斯基的自传体小说,小说的主人公是()?",
"options": [
{
"answer": false,
"contentText": "格列佛",
"index": "A"
},
{
"answer": false,
"contentText": "汤姆·索亚",
"index": "B"
},
{
"answer": true,
"contentText": "保尔·柯察金",
"index": "C"
},
{
"answer": false,
"contentText": "海伦",
"index": "D"
}
],
"questionType": "选择题",
"simpleType": false,
"sort": 98
}
]
[
{
"answers": [
{
"contentText": "C",
"sort": 1
}
],
"contentText": "爸爸把一盘糖果的一半给了弟弟,把剩下的糖果给了一半给姐姐,这时盘里还剩8块,请问盘里原来有几块糖?",
"options": [
{
"answer": false,
"contentText": "16块",
"index": "A"
},
{
"answer": false,
"contentText": "24块",
"index": "B"
},
{
"answer": true,
"contentText": "32块",
"index": "C"
},
{
"answer": false,
"contentText": "64块",
"index": "D"
}
],
"questionType": "选择题",
"simpleType": false
},
{
"contentText": "<p>某班50名学生在一次百米测试中,成绩全部介于13秒与19秒之间,将测试结果分成六组,得到频率分布直方图(如图).设成绩小于16秒的学生人数占全班总人数的百分比为<i>x</i>,成绩大于等于15秒且小于17秒的学生人数为<i>y</i>,则从频率分布直方图中可分析出<i>x</i>和<i>y</i>分别为(  )</p><p><img src=\"https://profile-1257124244.cos.ap-chengdu.myqcloud.com/question/image/943c1ee2-ed62-42d7-b381-d0e3d31677a7.png\" style=\"max-width:90vw;max-height:62.005104vw\" alt=\"\" width=\"202.90031\" height=\"139.78728\"></p>",
"options": [
{
"contentText": "<p>0.56,35</p>",
"answer": true,
"index": "A"
},
{
"contentText": "<p>0.56,45</p>",
"answer": false,
"index": "B"
},
{
"contentText": "<p>0.44,35</p>",
"answer": false,
"index": "C"
},
{
"contentText": "<p>0.44,45</p>",
"answer": false,
"index": "D"
}
],
"answers": [
{
"contentText": "C",
"sort": 1
}
],
"questionType": "选择题",
"simpleType": false,
"sort": 98
},
{
"answers": [
{
"contentText": "C",
"sort": 1
}
],
"contentText": "《钢铁是怎样炼成的》是前苏联作家奥斯特洛夫斯基的自传体小说,小说的主人公是()?",
"options": [
{
"answer": false,
"contentText": "格列佛",
"index": "A"
},
{
"answer": false,
"contentText": "汤姆·索亚",
"index": "B"
},
{
"answer": true,
"contentText": "保尔·柯察金",
"index": "C"
},
{
"answer": false,
"contentText": "海伦",
"index": "D"
}
],
"questionType": "选择题",
"simpleType": false,
"sort": 98
},
{
"answers": [
{
"contentText": "20",
"sort": 0
}
],
"contentText": "<AnswerBlank index=\"0\" />元钱可以买1元笔记本21本",
"questionItems": [
{
"contentText": "20",
"sort": 0
},
{
"contentText": "1",
"sort": 1
},
{
"contentText": "21",
"sort": 2
}
],
"questionType": "随机填空",
"simpleType": false
},
{
"contentText": "7998<AnswerBlank index=\"0\" compare=\"1\" />7988",
"questionType": "选择题",
"answers": [
{
"sort": 0,
"contentText": "C"
}
],
"simpleType": true,
"options": [
{
"index": "A",
"contentText": "<b>&lt;</b>",
"answer": false
},
{
"index": "B",
"contentText": "<b>=</b>",
"answer": false
},
{
"index": "C",
"contentText": "<b>&gt;</b>",
"answer": true
}
]
},
{
"questionItems": [
{
"sort": 0,
"contentText": "57"
},
{
"sort": 1,
"contentText": "8"
}
],
"simpleType": true,
"questionType": "竖式除法",
"answers": [
{
"sort": 0,
"contentText": "A"
},
{
"sort": 1,
"contentText": "A"
},
{
"sort": 2,
"contentText": "A"
},
{
"sort": 3,
"contentText": "A"
}
]
},
{
"answers": [
{
"contentText": "28",
"sort": 0
}
],
"contentText": "16<MathSymbol value=\"+\" />12<MathSymbol value=\"=\" /><AnswerBlank index=\"0\" />",
"questionItems": [
{
"contentText": "16",
"sort": 0
},
{
"contentText": "12",
"sort": 1
},
{
"contentText": "28",
"sort": 2
}
],
"questionType": "随机填空",
"simpleType": true
},
{
"answers": [
{
"contentText": "50",
"sort": 0
}
],
"contentText": "2<MathSymbol value=\"+\" />48<MathSymbol value=\"=\" /><AnswerBlank index=\"0\" />",
"questionItems": [
{
"contentText": "2",
"sort": 0
},
{
"contentText": "48",
"sort": 1
},
{
"contentText": "50",
"sort": 2
}
],
"questionType": "随机填空",
"simpleType": true
},
{
"answers": [
{
"contentText": "32",
"sort": 0
}
],
"contentText": "<AnswerBlank index=\"0\" />元钱可以买24元笔记本56本",
"questionItems": [
{
"contentText": "32",
"sort": 0
},
{
"contentText": "24",
"sort": 1
},
{
"contentText": "56",
"sort": 2
}
],
"questionType": "随机填空",
"simpleType": false
},
{
"answers": [
{
"contentText": "53",
"sort": 0
}
],
"contentText": "14<MathSymbol value=\"+\" />39<MathSymbol value=\"=\" /><AnswerBlank index=\"0\" />",
"questionItems": [
{
"contentText": "14",
"sort": 0
},
{
"contentText": "39",
"sort": 1
},
{
"contentText": "53",
"sort": 2
}
],
"questionType": "随机填空",
"simpleType": true
},
{
"answers": [
{
"contentText": "62",
"sort": 0
}
],
"contentText": "39<MathSymbol value=\"+\" />23<MathSymbol value=\"=\" /><AnswerBlank index=\"0\" />",
"questionItems": [
{
"contentText": "39",
"sort": 0
},
{
"contentText": "23",
"sort": 1
},
{
"contentText": "62",
"sort": 2
}
],
"questionType": "随机填空",
"simpleType": true
},
{
"answers": [
{
"contentText": "83",
"sort": 0
}
],
"contentText": "49<MathSymbol value=\"+\" />34<MathSymbol value=\"=\" /><AnswerBlank index=\"0\" />",
"questionItems": [
{
"contentText": "49",
"sort": 0
},
{
"contentText": "34",
"sort": 1
},
{
"contentText": "83",
"sort": 2
}
],
"questionType": "随机填空",
"simpleType": true
},
{
"answers": [
{
"contentText": "19",
"sort": 0
}
],
"contentText": "9元钱可以买10元笔记本<AnswerBlank index=\"0\" />本",
"questionItems": [
{
"contentText": "9",
"sort": 0
},
{
"contentText": "10",
"sort": 1
},
{
"contentText": "19",
"sort": 2
}
],
"questionType": "随机填空",
"simpleType": false
},
{
"answers": [
{
"contentText": "12",
"sort": 0
}
],
"contentText": "11元钱可以买1元笔记本<AnswerBlank index=\"0\" />本",
"questionItems": [
{
"contentText": "11",
"sort": 0
},
{
"contentText": "1",
"sort": 1
},
{
"contentText": "12",
"sort": 2
}
],
"questionType": "随机填空",
"simpleType": false
},
{
"answers": [
{
"contentText": "66",
"sort": 0
}
],
"contentText": "30元钱可以买36元笔记本<AnswerBlank index=\"0\" />本",
"questionItems": [
{
"contentText": "30",
"sort": 0
},
{
"contentText": "36",
"sort": 1
},
{
"contentText": "66",
"sort": 2
}
],
"questionType": "随机填空",
"simpleType": false
}
]
......@@ -35,11 +35,9 @@ export function convertQuestion (question: QuestionType): QuestionType {
return question
}
export function buildCompleteStageParam (questionList: QuestionType[], stageDetail: StageDetail, gameStartTime: number): CompleteStageParam {
export function buildCompleteStageParam (questionList: QuestionType[], stageDetail: StageDetail, resultTime: number): CompleteStageParam {
const correctNum = questionList.map(c => determinQuestion(c)).filter(Boolean).length
const resultTime = Math.round((Date.now() - gameStartTime) / 1000)
const { sTime, aTime, bTime } = stageDetail
let level: StageLevel | null = null
......@@ -67,7 +65,7 @@ export function buildCompleteStageParam (questionList: QuestionType[], stageDeta
stageId: stageDetail.id,
questions: questionList.map(convert),
num,
resultTime: Math.round((Date.now() - gameStartTime) / 1000),
resultTime,
}
}
......
......@@ -6,8 +6,10 @@
color: #FFFFFF;
display: flex;
align-items: center;
width: 750px;
box-sizing: border-box;
position: relative;
z-index: 1;
box-shadow: 0 1px 14px rgba(0, 81, 231, 0.1);
}
.chapterContent {
......
......@@ -47,6 +47,27 @@ let evenIndex = 0
let oddIndex = 0
let specialIndex = 0
export function stageToParts (stageList: Stage[]): Part[] {
evenIndex = 0
oddIndex = 0
specialIndex = 0
const ret: Part[] = []
stageList.forEach(item => {
const last = ret.find(c => c.number === (item.part ?? 1) - 1)
if (last) {
last.stages.push(item)
} else {
ret.push({
number: (item.part ?? 1) - 1,
stages: [item]
})
}
})
return ret
}
export function groupRoundToSmallPart (list: Stage[]): SmallPart[] {
const ret: SmallPart[] = []
let flag: 'even' | 'odd' = 'even'
......@@ -56,10 +77,10 @@ export function groupRoundToSmallPart (list: Stage[]): SmallPart[] {
while (start < len) {
if (flag === 'even') {
const rounds = list.slice(start, start + 2)
const stages = list.slice(start, start + 2)
let partType: SmallPart['type'] = 'even'
let bg: ImageSource
if (rounds.length < 2) {
if (stages.length < 2) {
specialIndex += 1
partType = 'special'
bg = getSmallPartBg(specialIndex, partType)
......@@ -68,7 +89,7 @@ export function groupRoundToSmallPart (list: Stage[]): SmallPart[] {
bg = getSmallPartBg(evenIndex, partType)
}
ret.push({
rounds,
stages,
bg,
offset: start,
type: partType
......@@ -78,7 +99,7 @@ export function groupRoundToSmallPart (list: Stage[]): SmallPart[] {
} else if (flag === 'odd') {
oddIndex += 1
ret.push({
rounds: list.slice(start, start + 1),
stages: list.slice(start, start + 1),
bg: getSmallPartBg(oddIndex, 'odd'),
offset: start,
type: 'odd'
......@@ -91,17 +112,8 @@ export function groupRoundToSmallPart (list: Stage[]): SmallPart[] {
return ret
}
export const enum RoundState {
/** 未解锁 */
Locked = 1,
/** 已完成 */
Clear = 2,
/** 已解锁 */
UnLocked = 3
}
export type SmallPart = {
rounds: Stage[];
stages: Stage[];
bg: ImageSource;
offset: number;
type: 'odd' | 'even' | 'special';
......
......@@ -2,34 +2,16 @@ import { View } from '@tarojs/components'
import assets from '@/assets/oss/assets-main'
import { useMemo } from 'react'
import LazeImage from '../lazy-image'
import { Part, Stage } from './constants'
import { stageToParts, type Stage } from './constants'
import ScenePart from './part'
type SceneProps = {
stageList: Stage[];
}
function toPart (stageList: Stage[]): Part[] {
const ret: Part[] = []
stageList.forEach(item => {
const last = ret.find(c => c.number === (item.part || 0))
if (last) {
last.stages.push(item)
} else {
ret.push({
number: item.part ?? 0,
stages: [item]
})
}
})
return ret
}
const Scene = (props: SceneProps) => {
const partList = useMemo(() => {
return toPart(props.stageList)
return stageToParts(props.stageList)
}, [props.stageList])
return (
......
......@@ -24,7 +24,7 @@ const SceneSmallPart = (props: SceneSmallPartProps) => {
const { part } = props
return (
<LazeImage source={part.bg}>
{part.rounds.map((item, index) => {
{part.stages.map((item, index) => {
return (
<RoundComp stage={item} key={item.id} className={getClassName(index, part.type)} />
)
......
......@@ -3,7 +3,8 @@ import assets from '@/assets/oss/assets-main'
import { useEffect, useState, useRef } from 'react'
import { usePageScroll, createIntersectionObserver } from '@tarojs/taro'
import classNames from 'classnames'
import { CurrentRoundId } from './scene/constants'
import { useStoreState } from '@/store/hooks'
import { CurrentRoundId, StageStatus } from './scene/constants'
import styles from './short-cut.module.scss'
......@@ -16,12 +17,16 @@ const ShortCut = (props: ShortCutProps) => {
const [isDown, setIsDown] = useState(false)
const scrollRef = useRef(0)
const lastEffectedScroll = useRef(0)
const stageList = useStoreState(state => state.mainModel.stageList)
usePageScroll((payload) => {
scrollRef.current = payload.scrollTop
})
useEffect(() => {
if (!stageList.some(c => c.status === StageStatus.CURRENT)) {
return
}
lastEffectedScroll.current = scrollRef.current
// @ts-ignore
let observer = createIntersectionObserver()
......@@ -42,7 +47,7 @@ const ShortCut = (props: ShortCutProps) => {
observer = null!
}
}
}, [])
}, [stageList])
return (
<View className={styles.shortcut}>
......
......@@ -4,7 +4,7 @@ import { useState, useMemo, useEffect, useCallback } from 'react'
import { useStoreActions, useStoreState } from '@/store/hooks'
import type { TabbarRef } from '../../custom-tab-bar/index'
import { CurrentRoundId, SceneContext } from './components/scene/constants'
import { CurrentRoundId, SceneContext, StageStatus } from './components/scene/constants'
import MainHeader from './components/header'
import MainChapter from './components/chapter'
import MainScene from './components/scene'
......@@ -18,14 +18,8 @@ const MainPage = () => {
const fetchStage = useStoreActions(actions => actions.mainModel.fetchStage)
const stageList = useStoreState(state => state.mainModel.stageList)
const fetchAccount = useStoreActions(actions => actions.userModel.fetchAccount)
useDidShow(() => {
fetchAccount()
const tabbar = getTabBar<TabbarRef>(page)
tabbar?.setSelected(0)
})
const [nav] = useState(getMenuButtonBoundingClientRect())
const scrollToCurrent = useCallback((callback?: () => void) => {
const height = getSystemInfoSync().windowHeight
pageScrollTo({
......@@ -35,15 +29,22 @@ const MainPage = () => {
})
}, [])
useEffect(() => {
fetchStage().then(() => {
useDidShow(() => {
fetchAccount()
const tabbar = getTabBar<TabbarRef>(page)
tabbar?.setSelected(0)
fetchStage().then((list) => {
setTimeout(() => {
scrollToCurrent(() => {
if (!list.find(c => c.status === StageStatus.CURRENT)) {
setIsReady(true)
})
} else {
scrollToCurrent(() => {
setIsReady(true)
})
}
}, 1000)
})
}, [scrollToCurrent, fetchStage])
})
return (
<>
......
......@@ -7,7 +7,7 @@ import { type Stage, getStageList } from '@/api'
export interface MainModel {
stageList: Stage[];
updateStageList: Action<MainModel, Stage[]>;
fetchStage: Thunk<MainModel, void, void, AppStoreModel>;
fetchStage: Thunk<MainModel, void, void, AppStoreModel, Promise<Stage[]>>;
}
const mainModel: MainModel = {
......@@ -16,12 +16,15 @@ const mainModel: MainModel = {
state.stageList = stageList
}),
fetchStage: thunk(async (actions, _) => {
let ret: Stage[] = []
try {
const { data: stageList } = await getStageList()
actions.updateStageList(stageList)
ret = stageList
} catch (err) {
actions.updateStageList([])
ret = []
}
actions.updateStageList(ret)
return ret
}),
}
......
......@@ -41,6 +41,8 @@ const Prepare = () => {
const [isVisible, { setTrue, setFalse }] = useBoolean(false)
const stageDetail = useStoreState(state => state.gameModel.stageDetail)
const getStageDetail = useStoreActions(actions => actions.gameModel.getStageDetail)
const getQuestionList = useStoreActions(actions => actions.gameModel.getQuestionList)
const cardNum = useStoreState(state => state.userModel.cardNum)
const { run: exchange, loading } = useRequest(pointToCard, { immediate: false })
......
......@@ -12,12 +12,16 @@ export interface UserModel {
point: number;
updateState: Action<UserModel, { cardNum: number; point: number }>;
fetchAccount: Thunk<UserModel, void, void, AppStoreModel>;
updateUserInfo: Action<UserModel, UserInfo>;
}
const userModel: UserModel = {
userInfo: getStorage(StorageKeys.userInfo)!,
cardNum: 0,
point: 0,
updateUserInfo: action((state, user) => {
state.userInfo = user
}),
updateState: action((state, { cardNum, point }) => {
state.cardNum = cardNum
state.point = point
......
import type Taro from '@tarojs/taro'
export type UserInfo = {
openId: string;
userId?: number;
phone?: string | null;
city?: string;
nickname?: string | null;
avatarUrl?: string | null;
expire?: number;
phone?: string | null;
}
export type RequestResultPagingLike<T> = RequestResult<PagingLike<T>>
......
import { silentLoginApi } from '@/api'
// import store from '@/store';
import store from '@/store'
import Taro from '@tarojs/taro'
import { setProfile } from './skynet'
import { Deferred } from './deferred'
......@@ -27,11 +27,8 @@ async function silentLogin () {
const { data } = await silentLoginApi(code)
updateStorage(StorageKeys.openid, data.openId)
updateStorage(StorageKeys.unionid, data.unionId)
updateStorage(StorageKeys.token, data.token)
updateStorage(StorageKeys.userInfo, {
userId: data.userId,
})
updateStorage(StorageKeys.userInfo, data)
store.getActions().userModel.updateUserInfo(data)
setProfile(data.openId, `${data.userId}`)
} catch (silentLoginError) {
......
......@@ -6,19 +6,13 @@ const storagePrefix = `${process.env.TARO_STORAGE_KEY}`
export enum StorageKeys {
/** 用户信息 */
userInfo = 1,
/** token */
token,
/** openid */
openid,
/** unionid */
unionid,
}
type Storage = {
[StorageKeys.userInfo]: UserInfo | null;
[StorageKeys.token]: string | null;
[StorageKeys.openid]: string | null;
[StorageKeys.unionid]: string | null;
[StorageKeys.openid]: string | null | undefined
}
const store: Storage = {} as Storage
......@@ -32,9 +26,7 @@ export function reloadStore () {
try {
[
StorageKeys.openid,
StorageKeys.userInfo,
StorageKeys.token,
StorageKeys.unionid
StorageKeys.userInfo
].forEach((element) => {
updateStorage(element, Taro.getStorageSync(`${storagePrefix}${element}`) ?? null)
})
......@@ -45,8 +37,6 @@ export function reloadStore () {
reloadStore()
console.log(store, 1111111)
export function getStorage<T extends StorageKeys> (key: T): Storage[T] | null {
return store[key]
}
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