Commit 32ba5d59 authored by hewenhao's avatar hewenhao

feat: 添加引导页

parent dbcc2f6d
{
"cat.png": {
"u": "https://cdn.jkwljy.com/pk-math/2G8dDyjuzbMbZ94UhwCpn7zUpw7V/300x300",
"w": 300,
"h": 300,
"ossName": "/pk-math/2G8dDyjuzbMbZ94UhwCpn7zUpw7V/300x300"
},
"modal-1.png": {
"u": "https://cdn.jkwljy.com/pk-math/eFWwoxVC4mzX1hZZojv23VEh9hz/500x180",
"w": 500,
"h": 180,
"ossName": "/pk-math/eFWwoxVC4mzX1hZZojv23VEh9hz/500x180"
},
"modal-2.png": {
"u": "https://cdn.jkwljy.com/pk-math/2tGxMZeki8g2zJdm36HkhuqnvpMS/500x260",
"w": 500,
"h": 260,
"ossName": "/pk-math/2tGxMZeki8g2zJdm36HkhuqnvpMS/500x260"
},
"modal-3.png": {
"u": "https://cdn.jkwljy.com/pk-math/3NgKAZuGvJYoXv4mhU1mqosBKyGz/500x204",
"w": 500,
"h": 204,
"ossName": "/pk-math/3NgKAZuGvJYoXv4mhU1mqosBKyGz/500x204"
},
"modal-4.png": {
"u": "https://cdn.jkwljy.com/pk-math/3hFqx2truFemx4DtRgZ4Q3mgEH6/468x168",
"w": 468,
"h": 168,
"ossName": "/pk-math/3hFqx2truFemx4DtRgZ4Q3mgEH6/468x168"
},
"modal-5.png": {
"u": "https://cdn.jkwljy.com/pk-math/2LAQN5FBeoW6UrQEaRVQVP6HTU25/468x224",
"w": 468,
"h": 224,
"ossName": "/pk-math/2LAQN5FBeoW6UrQEaRVQVP6HTU25/468x224"
},
"up-1-off.png": {
"u": "https://cdn.jkwljy.com/pk-math/2tz1rQ6Ywqtbx9csqwV83kMofdzV/112x112",
"w": 112,
"h": 112,
"ossName": "/pk-math/2tz1rQ6Ywqtbx9csqwV83kMofdzV/112x112"
},
"up-1.png": {
"u": "https://cdn.jkwljy.com/pk-math/3YmiUBnWLqC3kZjHyRWAxDQGm734/112x112",
"w": 112,
"h": 112,
"ossName": "/pk-math/3YmiUBnWLqC3kZjHyRWAxDQGm734/112x112"
},
"up-2-off.png": {
"u": "https://cdn.jkwljy.com/pk-math/cWrk9XA8oZuDDuR6f9LzQXjTAAs/112x112",
"w": 112,
"h": 112,
"ossName": "/pk-math/cWrk9XA8oZuDDuR6f9LzQXjTAAs/112x112"
},
"up-2.png": {
"u": "https://cdn.jkwljy.com/pk-math/3pnrN4xtFGxJZQ2we75b317pfg5c/112x112",
"w": 112,
"h": 112,
"ossName": "/pk-math/3pnrN4xtFGxJZQ2we75b317pfg5c/112x112"
},
"up-3.png": {
"u": "https://cdn.jkwljy.com/pk-math/3oxdN76M7H3AohpdC49BxegfhjHh/112x112",
"w": 112,
"h": 112,
"ossName": "/pk-math/3oxdN76M7H3AohpdC49BxegfhjHh/112x112"
},
"btn-active.png": {
"u": "https://cdn.jkwljy.com/pk-math/hijKKpX1GS7rJoezNKJwDFwMFQC/686x112",
"w": 686,
"h": 112,
"ossName": "/pk-math/hijKKpX1GS7rJoezNKJwDFwMFQC/686x112"
},
"btn.png": {
"u": "https://cdn.jkwljy.com/pk-math/wbVXwYUGCx63qjnAcoCW4mL2pvh/686x112",
"w": 686,
"h": 112,
"ossName": "/pk-math/wbVXwYUGCx63qjnAcoCW4mL2pvh/686x112"
},
"all-right.png": {
"u": "https://cdn.jkwljy.com/pk-math/uaviYod5USw6zCCDhdrG4uNsSqZ/60x60",
"w": 60,
"h": 60,
"ossName": "/pk-math/uaviYod5USw6zCCDhdrG4uNsSqZ/60x60"
},
"time-count.png": {
"u": "https://cdn.jkwljy.com/pk-math/3h62nBD3nCnEjm4WDuFnpMVMaF2L/60x60",
"w": 60,
"h": 60,
"ossName": "/pk-math/3h62nBD3nCnEjm4WDuFnpMVMaF2L/60x60"
},
"a.png": {
"u": "https://cdn.jkwljy.com/pk-math/8zLvUEn6QTBg5N5Jxqo7WZKdVJa/112x112",
"w": 112,
"h": 112,
"ossName": "/pk-math/8zLvUEn6QTBg5N5Jxqo7WZKdVJa/112x112"
},
"b.png": {
"u": "https://cdn.jkwljy.com/pk-math/TtiXEBcjksrm7FPnhBsZRu52f11/112x112",
"w": 112,
"h": 112,
"ossName": "/pk-math/TtiXEBcjksrm7FPnhBsZRu52f11/112x112"
},
"s.png": {
"u": "https://cdn.jkwljy.com/pk-math/2WzGP7PvULiS4HG5ijBg73iojMuM/112x112",
"w": 112,
"h": 112,
"ossName": "/pk-math/2WzGP7PvULiS4HG5ijBg73iojMuM/112x112"
},
"top10.png": {
"u": "https://cdn.jkwljy.com/pk-math/2vdztxsFGgL8ywoKh3U6kEQ8LA9i/112x112",
"w": 112,
"h": 112,
"ossName": "/pk-math/2vdztxsFGgL8ywoKh3U6kEQ8LA9i/112x112"
},
"top20.png": {
"u": "https://cdn.jkwljy.com/pk-math/2WWzAKoRs8S128CBLKif5MrcNkL4/112x112",
"w": 112,
"h": 112,
"ossName": "/pk-math/2WWzAKoRs8S128CBLKif5MrcNkL4/112x112"
},
"top30.png": {
"u": "https://cdn.jkwljy.com/pk-math/K3u3cLpWaE8ce1WY8vADeZUc9S2/112x112",
"w": 112,
"h": 112,
"ossName": "/pk-math/K3u3cLpWaE8ce1WY8vADeZUc9S2/112x112"
},
"book-1.png": {
"u": "https://cdn.jkwljy.com/pk-math/25Kj6Scn2oUhKdTGjJZWNokbeNzu/112x112",
"w": 112,
"h": 112,
"ossName": "/pk-math/25Kj6Scn2oUhKdTGjJZWNokbeNzu/112x112"
},
"book-2.png": {
"u": "https://cdn.jkwljy.com/pk-math/P4fSz2ChXCpQtaDeRh72MpLAnoo/112x112",
"w": 112,
"h": 112,
"ossName": "/pk-math/P4fSz2ChXCpQtaDeRh72MpLAnoo/112x112"
},
"book-3.png": {
"u": "https://cdn.jkwljy.com/pk-math/maDVi3ZWmg1EbNzkRwCjGxG6A2W/112x112",
"w": 112,
"h": 112,
"ossName": "/pk-math/maDVi3ZWmg1EbNzkRwCjGxG6A2W/112x112"
},
"right.png": {
"u": "https://cdn.jkwljy.com/pk-math/33KAtnQhvUCtcZRQNYtfYyZooMs9/48x48",
"w": 48,
"h": 48,
"ossName": "/pk-math/33KAtnQhvUCtcZRQNYtfYyZooMs9/48x48"
},
"score.png": {
"u": "https://cdn.jkwljy.com/pk-math/4KFwGDX3kZsUuKh4V83eWgTzaoTZ/64x64",
"w": 64,
"h": 64,
"ossName": "/pk-math/4KFwGDX3kZsUuKh4V83eWgTzaoTZ/64x64"
},
"touzi.png": {
"u": "https://cdn.jkwljy.com/pk-math/3vsWjE3z8sWZh1xg9pa5cFh48ANZ/64x64",
"w": 64,
"h": 64,
"ossName": "/pk-math/3vsWjE3z8sWZh1xg9pa5cFh48ANZ/64x64"
}
}
...@@ -55,3 +55,11 @@ export function getSetting () { ...@@ -55,3 +55,11 @@ export function getSetting () {
data: {} data: {}
})) }))
} }
export function updateUserPhone (code: string) {
return requestAfterSilentLogin<void, { code: string; userId?: number }>((userInfo) => ({
url: '/service-idea/stage/user/getUserPhone',
method: 'GET',
data: { code, userId: userInfo?.userId }
}))
}
/* eslint-disable quotes */
/* eslint-disable quote-props */
export default {
"cat.png": {
"u": "https://cdn.jkwljy.com/pk-math/2G8dDyjuzbMbZ94UhwCpn7zUpw7V/300x300",
"w": 300,
"h": 300
},
"modal-1.png": {
"u": "https://cdn.jkwljy.com/pk-math/eFWwoxVC4mzX1hZZojv23VEh9hz/500x180",
"w": 500,
"h": 180
},
"modal-2.png": {
"u": "https://cdn.jkwljy.com/pk-math/2tGxMZeki8g2zJdm36HkhuqnvpMS/500x260",
"w": 500,
"h": 260
},
"modal-3.png": {
"u": "https://cdn.jkwljy.com/pk-math/3NgKAZuGvJYoXv4mhU1mqosBKyGz/500x204",
"w": 500,
"h": 204
},
"modal-4.png": {
"u": "https://cdn.jkwljy.com/pk-math/3hFqx2truFemx4DtRgZ4Q3mgEH6/468x168",
"w": 468,
"h": 168
},
"modal-5.png": {
"u": "https://cdn.jkwljy.com/pk-math/2LAQN5FBeoW6UrQEaRVQVP6HTU25/468x224",
"w": 468,
"h": 224
},
"up-1-off.png": {
"u": "https://cdn.jkwljy.com/pk-math/2tz1rQ6Ywqtbx9csqwV83kMofdzV/112x112",
"w": 112,
"h": 112
},
"up-1.png": {
"u": "https://cdn.jkwljy.com/pk-math/3YmiUBnWLqC3kZjHyRWAxDQGm734/112x112",
"w": 112,
"h": 112
},
"up-2-off.png": {
"u": "https://cdn.jkwljy.com/pk-math/cWrk9XA8oZuDDuR6f9LzQXjTAAs/112x112",
"w": 112,
"h": 112
},
"up-2.png": {
"u": "https://cdn.jkwljy.com/pk-math/3pnrN4xtFGxJZQ2we75b317pfg5c/112x112",
"w": 112,
"h": 112
},
"up-3.png": {
"u": "https://cdn.jkwljy.com/pk-math/3oxdN76M7H3AohpdC49BxegfhjHh/112x112",
"w": 112,
"h": 112
},
"btn-active.png": {
"u": "https://cdn.jkwljy.com/pk-math/hijKKpX1GS7rJoezNKJwDFwMFQC/686x112",
"w": 686,
"h": 112
},
"btn.png": {
"u": "https://cdn.jkwljy.com/pk-math/wbVXwYUGCx63qjnAcoCW4mL2pvh/686x112",
"w": 686,
"h": 112
},
"all-right.png": {
"u": "https://cdn.jkwljy.com/pk-math/uaviYod5USw6zCCDhdrG4uNsSqZ/60x60",
"w": 60,
"h": 60
},
"time-count.png": {
"u": "https://cdn.jkwljy.com/pk-math/3h62nBD3nCnEjm4WDuFnpMVMaF2L/60x60",
"w": 60,
"h": 60
},
"a.png": {
"u": "https://cdn.jkwljy.com/pk-math/8zLvUEn6QTBg5N5Jxqo7WZKdVJa/112x112",
"w": 112,
"h": 112
},
"b.png": {
"u": "https://cdn.jkwljy.com/pk-math/TtiXEBcjksrm7FPnhBsZRu52f11/112x112",
"w": 112,
"h": 112
},
"s.png": {
"u": "https://cdn.jkwljy.com/pk-math/2WzGP7PvULiS4HG5ijBg73iojMuM/112x112",
"w": 112,
"h": 112
},
"top10.png": {
"u": "https://cdn.jkwljy.com/pk-math/2vdztxsFGgL8ywoKh3U6kEQ8LA9i/112x112",
"w": 112,
"h": 112
},
"top20.png": {
"u": "https://cdn.jkwljy.com/pk-math/2WWzAKoRs8S128CBLKif5MrcNkL4/112x112",
"w": 112,
"h": 112
},
"top30.png": {
"u": "https://cdn.jkwljy.com/pk-math/K3u3cLpWaE8ce1WY8vADeZUc9S2/112x112",
"w": 112,
"h": 112
},
"book-1.png": {
"u": "https://cdn.jkwljy.com/pk-math/25Kj6Scn2oUhKdTGjJZWNokbeNzu/112x112",
"w": 112,
"h": 112
},
"book-2.png": {
"u": "https://cdn.jkwljy.com/pk-math/P4fSz2ChXCpQtaDeRh72MpLAnoo/112x112",
"w": 112,
"h": 112
},
"book-3.png": {
"u": "https://cdn.jkwljy.com/pk-math/maDVi3ZWmg1EbNzkRwCjGxG6A2W/112x112",
"w": 112,
"h": 112
},
"right.png": {
"u": "https://cdn.jkwljy.com/pk-math/33KAtnQhvUCtcZRQNYtfYyZooMs9/48x48",
"w": 48,
"h": 48
},
"score.png": {
"u": "https://cdn.jkwljy.com/pk-math/4KFwGDX3kZsUuKh4V83eWgTzaoTZ/64x64",
"w": 64,
"h": 64
},
"touzi.png": {
"u": "https://cdn.jkwljy.com/pk-math/3vsWjE3z8sWZh1xg9pa5cFh48ANZ/64x64",
"w": 64,
"h": 64
}
} as const
...@@ -13,6 +13,7 @@ type TabbarRef = { ...@@ -13,6 +13,7 @@ type TabbarRef = {
const Tabbar: ForwardRefRenderFunction<TabbarRef, {}> = (_, ref) => { const Tabbar: ForwardRefRenderFunction<TabbarRef, {}> = (_, ref) => {
const [selected, setSelected] = useState(0) const [selected, setSelected] = useState(0)
const hasPoint = useStoreState(state => state.groupModel.hasPoint) const hasPoint = useStoreState(state => state.groupModel.hasPoint)
const userInfo = useStoreState(state => state.userModel.userInfo)
const _switchTab = useCallback((index: number, url: string) => { const _switchTab = useCallback((index: number, url: string) => {
setSelected(index) setSelected(index)
...@@ -26,6 +27,10 @@ const Tabbar: ForwardRefRenderFunction<TabbarRef, {}> = (_, ref) => { ...@@ -26,6 +27,10 @@ const Tabbar: ForwardRefRenderFunction<TabbarRef, {}> = (_, ref) => {
} }
}) })
if (!userInfo.nickName) {
return null
}
return ( return (
<View className={styles.wrap}> <View className={styles.wrap}>
<View className={styles.inner}> <View className={styles.inner}>
......
import { View } from '@tarojs/components' import { View } from '@tarojs/components'
import { useStoreActions } from '@/store/hooks'
import { memo } from 'react' import { memo } from 'react'
import styles from './number-keyboard.module.scss' import styles from './number-keyboard.module.scss'
const alphbet = '1234567890'.split('') const alphbet = '1234567890'.split('')
const NumberKeyboard = () => { type NumberKeyboardProps = {
const updateUserAnswer = useStoreActions(actions => actions.gameModel.updateUserAnswer) onClick: (val: string) => void
console.log('memo1') }
const NumberKeyboard = (props: NumberKeyboardProps) => {
const { onClick } = props
return ( return (
<View className={styles.keyboard}> <View className={styles.keyboard}>
{alphbet.map(item => { {alphbet.map(item => {
return ( return (
<View key={item} className={styles.keyboard_item} hoverClass={styles.is_active} onClick={() => updateUserAnswer(item)}>{item}</View> <View key={item} className={styles.keyboard_item} hoverClass={styles.is_active} onClick={() => onClick(item)}>{item}</View>
) )
})} })}
</View> </View>
......
import { View, Image, CustomWrapper } from '@tarojs/components' import { View, Image, CustomWrapper } from '@tarojs/components'
import { useStoreState, useStoreActions } from '@/store/hooks'
import { 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'
const PageFooter = () => { type PageFooterProps = {
const currentQuestionIndex = useStoreState(states => states.gameModel.currentQuestionIndex) canGoNext: boolean;
const canGoNext = useStoreState(states => states.gameModel.canGoNext) isLastQuestion: boolean;
const questionList = useStoreState(states => states.gameModel.questionList) clearUserAnswer: () => void;
const isLastQuestion = useMemo(() => { handleGoNext: () => void;
return questionList.length === currentQuestionIndex + 1 confirmText?: string;
}, [questionList, currentQuestionIndex]) }
const clearUserAnswer = useStoreActions(actions => actions.gameModel.clearUserAnswer)
const handleGoNext = useStoreActions(actions => actions.gameModel.handleGoNext) const PageFooter = (props: PageFooterProps) => {
const { clearUserAnswer, handleGoNext, isLastQuestion, canGoNext, confirmText = '提交' } = props
return ( return (
<CustomWrapper> <CustomWrapper>
...@@ -31,7 +31,7 @@ const PageFooter = () => { ...@@ -31,7 +31,7 @@ const PageFooter = () => {
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 ? confirmText : '下一题'}</View>
</View> </View>
</View> </View>
</CustomWrapper> </CustomWrapper>
......
import { View, ScrollView } from '@tarojs/components' import { View, ScrollView } from '@tarojs/components'
import { useStoreState, useStoreActions } from '@/store/hooks' import { useStoreState, useStoreActions } from '@/store/hooks'
import { preloadImage } from '@/utils/preload-image' import { preloadImage } from '@/utils/preload-image'
import { useEffect } from 'react' import { useEffect, useMemo } from 'react'
import { useDidShow } from '@tarojs/taro' import { useDidShow } from '@tarojs/taro'
import assets from '@/assets/oss/assets-complete' import assets from '@/assets/oss/assets-complete'
...@@ -29,6 +29,16 @@ const GamePlay = () => { ...@@ -29,6 +29,16 @@ const GamePlay = () => {
const currentQuestion = useStoreState(states => states.gameModel.currentQuestion) const currentQuestion = useStoreState(states => states.gameModel.currentQuestion)
const stageDetail = useStoreState(state => state.gameModel.stageDetail) const stageDetail = useStoreState(state => state.gameModel.stageDetail)
const updateState = useStoreActions(actions => actions.gameModel.updateState) const updateState = useStoreActions(actions => actions.gameModel.updateState)
const updateUserAnswer = useStoreActions(actions => actions.gameModel.updateUserAnswer)
const currentQuestionIndex = useStoreState(states => states.gameModel.currentQuestionIndex)
const canGoNext = useStoreState(states => states.gameModel.canGoNext)
const questionList = useStoreState(states => states.gameModel.questionList)
const isLastQuestion = useMemo(() => {
return questionList.length === currentQuestionIndex + 1
}, [questionList, currentQuestionIndex])
const clearUserAnswer = useStoreActions(actions => actions.gameModel.clearUserAnswer)
const handleGoNext = useStoreActions(actions => actions.gameModel.handleGoNext)
useEffect(() => { useEffect(() => {
preloadCompleteImages() preloadCompleteImages()
...@@ -55,9 +65,14 @@ const GamePlay = () => { ...@@ -55,9 +65,14 @@ const GamePlay = () => {
{currentQuestion && ( {currentQuestion && (
<> <>
{currentQuestion?.questionType !== '选择题' && ( {currentQuestion?.questionType !== '选择题' && (
<NumberKeyboard /> <NumberKeyboard onClick={updateUserAnswer} />
)} )}
<PageFooter /> <PageFooter
clearUserAnswer={clearUserAnswer}
handleGoNext={handleGoNext}
isLastQuestion={isLastQuestion}
canGoNext={canGoNext}
/>
</> </>
)} )}
</View> </View>
......
import { useState, useEffect } from 'react' import { useState, useEffect } from 'react'
import { Text } from '@tarojs/components' import { Text } from '@tarojs/components'
const TextPrinter = ({ text, speed = 100 }: { text: string, speed?: number }) => { type TextPrinterProps = {
text: string;
speed?: number;
onEnd?: () => void;
}
const TextPrinter = (props: TextPrinterProps) => {
const { text, speed = 100, onEnd } = props
const [visibleText, setVisibleText] = useState('') const [visibleText, setVisibleText] = useState('')
const [charIndex, setCharIndex] = useState(0) const [charIndex, setCharIndex] = useState(0)
...@@ -26,6 +33,7 @@ const TextPrinter = ({ text, speed = 100 }: { text: string, speed?: number }) => ...@@ -26,6 +33,7 @@ const TextPrinter = ({ text, speed = 100 }: { text: string, speed?: number }) =>
const animateText = (timestamp) => { const animateText = (timestamp) => {
if (charIndex >= text.length) { if (charIndex >= text.length) {
onEnd && onEnd()
return return
} }
...@@ -44,7 +52,7 @@ const TextPrinter = ({ text, speed = 100 }: { text: string, speed?: number }) => ...@@ -44,7 +52,7 @@ const TextPrinter = ({ text, speed = 100 }: { text: string, speed?: number }) =>
cancelAnimationFrame(animationFrameId) cancelAnimationFrame(animationFrameId)
} }
} }
}, [text, speed, charIndex]) }, [text, speed, charIndex, onEnd])
return ( return (
<Text>{visibleText}</Text> <Text>{visibleText}</Text>
......
.body {
position: relative;
z-index: 1;
padding-bottom: 56PX;
}
@supports (height: constant(safe-area-inset-bottom)) or (height: env(safe-area-inset-bottom)) {
.gap {
height: constant(safe-area-inset-bottom);
height : env(safe-area-inset-bottom);
}
}
import { View } from '@tarojs/components'
import {
getMenuButtonBoundingClientRect, useDidShow,
getCurrentInstance, getTabBar, pageScrollTo, getSystemInfoSync,
nextTick
} from '@tarojs/taro'
import { useState, useMemo, useCallback, useEffect } from 'react'
import { useStoreActions, useStoreState } from '@/store/hooks'
import { useFocus } from '@/hooks/use-focus'
import type { TabbarRef } from '../../../custom-tab-bar/index'
import { CurrentRoundId, SceneContext, StageStatus } from './scene/constants'
import MainHeader from './header'
import MainChapter from './chapter'
import MainScene from './scene'
import MainShortCut from './short-cut'
import useShowShareModal from '../use-show-share-modal'
import styles from './main-component.module.scss'
const MainPage = () => {
const page = useMemo(() => getCurrentInstance().page, [])
const updateReady = useStoreActions(actions => actions.mainModel.updateReady)
const fetchStage = useStoreActions(actions => actions.mainModel.fetchStage)
const stageList = useStoreState(state => state.mainModel.stageList)
const isReady = useStoreState(state => state.mainModel.isReady)
const fetchAccount = useStoreActions(actions => actions.userModel.fetchAccount)
const nav = useMemo(getMenuButtonBoundingClientRect, [])
useShowShareModal()
const scrollToCurrent = useCallback((callback?: () => void) => {
const height = getSystemInfoSync().windowHeight
pageScrollTo({
selector: `#${CurrentRoundId}`,
offsetTop: -height / 2,
complete: callback
})
}, [])
const isFocus = useFocus()
useEffect(() => {
if (isFocus) {
fetchAccount()
const tabbar = getTabBar<TabbarRef>(page)
tabbar?.setSelected(0)
fetchStage().then((list) => {
setTimeout(() => {
nextTick(() => {
if (!list.find(c => c.status === StageStatus.CURRENT)) {
updateReady(true)
} else {
scrollToCurrent(() => {
updateReady(true)
})
}
})
}, 500)
})
}
}, [isFocus, fetchAccount, fetchStage, page, scrollToCurrent, updateReady])
return (
<>
<MainHeader />
<View className={styles.body} style={{ paddingTop: `${nav.height + nav.top + 5}px` }}>
<MainChapter />
<MainScene stageList={stageList} />
<View className={styles.gap}></View>
</View>
{isReady && (
<MainShortCut onClick={() => scrollToCurrent()} />
)}
</>
)
}
export default MainPage
...@@ -31,6 +31,7 @@ const StageTag = (props: StageTagProps) => { ...@@ -31,6 +31,7 @@ const StageTag = (props: StageTagProps) => {
useEffect(() => { useEffect(() => {
let observer: IntersectionObserver | null = null let observer: IntersectionObserver | null = null
console.log(ready, 111111111, isFocus)
const fn = () => { const fn = () => {
if (ready && isFocus) { if (ready && isFocus) {
const navVal = nav.current const navVal = nav.current
......
...@@ -4,9 +4,9 @@ import classNames from 'classnames' ...@@ -4,9 +4,9 @@ import classNames from 'classnames'
import { cs } from '@/styles' import { cs } from '@/styles'
import { navigateTo } from '@tarojs/taro' import { navigateTo } from '@tarojs/taro'
import type { ImageSource } from '@/types' import type { ImageSource } from '@/types'
import { useStoreActions } from '@/store/hooks' import { useStoreActions, useStoreState } from '@/store/hooks'
import { type Stage, StageType, StageStatus, StageLevel, CurrentRoundId, SceneContext } from './constants' import { type Stage, StageType, StageStatus, StageLevel, CurrentRoundId } from './constants'
import StageTag from './stage-tag' import StageTag from './stage-tag'
import styles from './stage.module.scss' import styles from './stage.module.scss'
...@@ -105,6 +105,7 @@ const getIconClassNames = (type?: StageType, extra: string[] = []) => { ...@@ -105,6 +105,7 @@ const getIconClassNames = (type?: StageType, extra: string[] = []) => {
const StageComp = (props: StageProps) => { const StageComp = (props: StageProps) => {
const { stage } = props const { stage } = props
const updateState = useStoreActions(actions => actions.gameModel.updateState) const updateState = useStoreActions(actions => actions.gameModel.updateState)
const isReady = useStoreState(state => state.mainModel.isReady)
const renderRound = (ready: boolean) => { const renderRound = (ready: boolean) => {
switch (stage.status) { switch (stage.status) {
...@@ -152,19 +153,15 @@ const StageComp = (props: StageProps) => { ...@@ -152,19 +153,15 @@ const StageComp = (props: StageProps) => {
} }
return ( return (
<SceneContext.Consumer>
{({ ready }) => (
<View <View
className={classNames(props.className, cs.bounce_btn)} className={classNames(props.className, cs.bounce_btn)}
hoverClass={cs.bounce_btn_hover} hoverClass={cs.bounce_btn_hover}
id={stage.status === StageStatus.CURRENT ? CurrentRoundId : undefined} id={stage.status === StageStatus.CURRENT ? CurrentRoundId : undefined}
onClick={handleClick} onClick={handleClick}
> >
{renderRound(ready)} {renderRound(isReady)}
<View className={styles.roundName}>{stage.name}</View> <View className={styles.roundName}>{stage.name}</View>
</View> </View>
)}
</SceneContext.Consumer>
) )
} }
......
.blank {
display: inline-block;
margin: 0 8px;
vertical-align: middle;
background: #F7F7F7;
border: 6px solid #E5E5E5;
font-family: HelveticaNeue-Medium, HelveticaNeue;
font-weight: 500;
color: #465164;
text-align: center;
min-width: 84px;
line-height: 72px;
height: 84px;
font-size: 50px;
padding: 0 8px;
box-sizing: border-box;
border-radius: 20px;
&.is_simple {
border-radius: 32px;
font-size: 80px;
line-height: 100px;
min-width: 112px;
height: 112px;
}
&.has_answer {
border-color: rgba(23,134,247,0.5);
background-color: #F1F5FF;
}
&.is_active {
border-color: #FFC056;
background-color: #FFF5E3;
}
&.is_wrong {
border-color: #FF7C3F;
animation-name: shake;
animation-duration: 1s;
animation-timing-function: ease-in-out;
animation-iteration-count: infinite;
}
}
@keyframes shake {
from,
to {
transform: translate3d(0, 0, 0);
}
10%,
30%,
50%,
70%,
90% {
transform: translate3d(-10px, 0, 0);
}
20%,
40%,
60%,
80% {
transform: translate3d(10px, 0, 0);
}
}
import { View, CustomWrapper } from '@tarojs/components'
import classNames from 'classnames'
import styles from './answer-blank.module.scss'
type AnswerBlankProps = {
value: string;
isWrong: boolean;
}
const AnswerBlank = (props: AnswerBlankProps) => {
const { value, isWrong } = props
return (
<CustomWrapper>
<View
className={classNames(styles.blank, styles.is_simple, value && styles.has_answer, styles.is_active, isWrong && styles.is_wrong)}
>{value}</View>
</CustomWrapper>
)
}
export default AnswerBlank
.count {
padding: 40px 32px 50px 32px;
display: flex;
align-items: center;
&.is_stop {
padding-bottom: 50px;
}
}
.process {
flex: 1;
background-color: #F0F2F9;
border-radius: 14px;
position: relative;
}
.process_inner {
height: 28px;
background-color: #1786F7;
border-radius: 14px;
transition: width .3s linear;
}
.time {
display: flex;
align-items: center;
margin-left: 32px;
font-size: 36px;
font-weight: 500;
color: #465164;
line-height: 46px;
&.red {
color: #FF7770;
}
.icon {
width: 32px;
height: 32px;
margin-right: 12px;
}
}
.roleWrap {
position: absolute;
left: 0;
top: 0;
right: 0;
width: 100%;
transform: translateX(0px);
}
.role {
position: absolute;
left: 0;
top: -8px;
margin-left: -40px;
.tick {
width: 6px;
border-radius: 3px;
height: 48px;
background-color: #FE9B45;
margin: 0 auto;
}
.tips {
position: absolute;
background: #FE9B45;
border-radius: 0px 12px 12px 0px;
color: #fff;
bottom: 20px;
left: 66px;
white-space: nowrap;
padding: 4px 8px 2px 12px;
z-index: 1;
font-size: 24px;
font-weight: 600;
line-height: 34px;
}
}
.cat {
width: 80px;
height: 80px;
position: relative;
z-index: 2;
display: block;
}
import { View, Image } from '@tarojs/components'
import { useMemo } from 'react'
import classNames from 'classnames'
import styles from './count-up.module.scss'
type CountUpProps = {
isSubmit: boolean;
currentIndex: number;
}
const questionLength = 3
const CountUp = (props: CountUpProps) => {
const { isSubmit, currentIndex } = props
const processInnerStyle = useMemo(() => {
if (isSubmit) {
return {
width: '100%'
}
}
return {
width: `${currentIndex * 100 / questionLength}%`
}
}, [currentIndex, isSubmit])
return (
<View className={classNames(styles.count)}>
<View className={styles.process}>
<View className={styles.process_inner} style={processInnerStyle}></View>
</View>
<View className={styles.time}>
<Image src={require('@/pages/game/play/assets/count-time.png')} className={styles.icon}></Image>
<count-up-time
exceedTime={20}
startValue={0}
isDown={false}
/>
</View>
</View>
)
}
export default CountUp
.sprite {
position: absolute;
left: 50%;
top: 50%;
margin-left: -150px;
margin-top: -60px;
transition: all .3s ease-in-out;
&.step_1 {
left: 0;
margin-left: 0;
margin-top: 0;
}
&.step_static {
position: relative;
left: 0;
top: 0;
margin-left: 0;
margin-top: 0;
}
}
.cat {
width: 300px;
height: 300px;
display: block;
}
.btn {
background-image: url(https://cdn.jkwljy.com/pk-math/wbVXwYUGCx63qjnAcoCW4mL2pvh/686x112);
background-size: 100% 100%;
height: 112px;
border-radius: 56px;
display: flex;
align-items: center;
justify-content: center;
font-size: 40px;
font-weight: 600;
color: #FFFFFF;
line-height: 56px;
background-color: #1786F7;
&.disabled {
background-image: none;
background-color: #E2E6ED;
color: #C2C8D1;
}
}
.is_hover {
background-image: url(https://cdn.jkwljy.com/pk-math/hijKKpX1GS7rJoezNKJwDFwMFQC/686x112);
}
@supports (padding-bottom: constant(safe-area-inset-bottom)) or (padding-bottom: env(safe-area-inset-bottom)) {
.footer {
padding-bottom: constant(safe-area-inset-bottom);
padding-bottom : env(safe-area-inset-bottom);
}
}
.footer_inner {
padding: 32px;
}
.viewport {
height: 100vh;
display: flex;
flex-direction: column;
}
.viewport_body {
flex: 1;
position: relative;
}
.viewport_body_inner {
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
}
import { useState, useMemo } from 'react'
import { getMenuButtonBoundingClientRect } from '@tarojs/taro'
import Scene1 from './scene-1'
import Scene2 from './scene-2'
import Scene3 from './scene-3'
import Scene4 from './scene-4'
import Scene5 from './scene-5'
import Scene6 from './scene-6'
type GuideProps = {
onDone: () => void;
}
const Guide = (props: GuideProps) => {
const { onDone } = props
const [step, setStep] = useState(0)
const nav = useMemo(getMenuButtonBoundingClientRect, [])
const spriteTop = useMemo(() => {
if (step > 0) {
return nav.top + 5 + 24
}
return 0
}, [nav, step])
return (
<>
{step === 0 && (
<Scene1 onNext={() => setStep(1)} />
)}
{step === 1 && (
<Scene2 spriteTop={spriteTop} onNext={() => setStep(2)} />
)}
{step === 2 && (
<Scene3 spriteTop={spriteTop} onNext={() => setStep(3)} />
)}
{step === 3 && (
<Scene4 spriteTop={spriteTop} onNext={() => setStep(4)} />
)}
{step === 4 && (
<Scene5 spriteTop={spriteTop} onNext={() => setStep(5)} />
)}
{step === 5 && (
<Scene6 spriteTop={spriteTop} onNext={onDone} />
)}
</>
)
}
export default Guide
.sprite {
position: absolute;
left: 50%;
top: 50%;
margin-left: -150px;
margin-top: -60px;
}
.cat {
width: 300px;
height: 300px;
display: block;
}
.dialog {
position: absolute;
top: -24px;
left: 0;
right: 0;
display: flex;
justify-content: center;
font-size: 40px;
font-weight: 500;
color: rgba(70,81,100,0.8);
line-height: 56px;
}
.modal_3 {
position: absolute;
top: -204px;
width: 500px;
height: 204px;
background-image: url(https://cdn.jkwljy.com/pk-math/3NgKAZuGvJYoXv4mhU1mqosBKyGz/500x204);
background-size: 100% 100%;
box-sizing: border-box;
padding: 28px;
}
.modal_2 {
position: absolute;
top: -260px;
width: 500px;
height: 260px;
background-image: url(https://cdn.jkwljy.com/pk-math/2tGxMZeki8g2zJdm36HkhuqnvpMS/500x260);
background-size: 100% 100%;
box-sizing: border-box;
padding: 32px 28px;
}
.modal_1 {
position: absolute;
top: -180px;
width: 500px;
height: 180px;
background-image: url(https://cdn.jkwljy.com/pk-math/eFWwoxVC4mzX1hZZojv23VEh9hz/500x180);
background-size: 100% 100%;
box-sizing: border-box;
padding: 48px 28px;
}
import { ScrollView, View, Image } from '@tarojs/components'
import { useState, useCallback } from 'react'
import classNames from 'classnames'
import TextPrinter from './text-printer'
import cs from './index.module.scss'
import styles from './scene-1.module.scss'
const Text1 = [
{ text: '嗨,' },
{ text: '你好,' },
{ text: '我是高斯。' },
]
const Text2 = [
{ text: '别看我是一只猫,' },
{ text: '我可是一名远近闻名的数学大师呢。' },
]
// text="我已经帮助很多同学,喜欢上数学,提升数学能力了。"
const Text3 = [
{ text: '我已经帮助很多同学,' },
{ text: '喜欢上数学,' },
{ text: '提升数学能力了。' },
]
// text="在开始前,我可以问几个问题互相了解一下吗?"
const Text4 = [
{ text: '在开始前,' },
{ text: '我可以问几个问题,' },
{ text: '互相了解一下吗?' },
]
type Scene1Props = {
onNext: () => void;
}
const Scene1 = ({ onNext }: Scene1Props) => {
const [current, setCurrent] = useState(0)
const [isActive, setIsActive] = useState(false)
const handleEnd = useCallback((index) => {
setTimeout(() => {
setCurrent(index)
}, 1000)
}, [])
const handleClick = useCallback(() => {
if (isActive) {
onNext && onNext()
}
}, [onNext, isActive])
return (
<View className={cs.viewport}>
<View className={cs.viewport_body}>
<ScrollView className={cs.viewport_body_inner} scrollY>
<View className={cs.sprite}>
<Image src="https://cdn.jkwljy.com/pk-math/2G8dDyjuzbMbZ94UhwCpn7zUpw7V/300x300" className={cs.cat} />
<View className={styles.dialog}>
{current === 0 && (
<View className={styles.modal_1}>
<TextPrinter textList={Text1} onEnd={() => handleEnd(1)}></TextPrinter>
</View>
)}
{current === 1 && (
<View className={styles.modal_2}>
<TextPrinter textList={Text2} onEnd={() => handleEnd(2)} />
</View>
)}
{current === 2 && (
<View className={styles.modal_2}>
<TextPrinter
textList={Text3}
onEnd={() => handleEnd(3)}
/>
</View>
)}
{current === 3 && (
<View className={styles.modal_3}>
<TextPrinter
textList={Text4}
onEnd={() => setIsActive(true)}
/>
</View>
)}
</View>
</View>
</ScrollView>
</View>
<View className={cs.footer}>
<View className={cs.footer_inner}>
<View
className={classNames(cs.btn, !isActive && cs.disabled)}
hoverClass={!isActive ? cs.is_hover : ''}
onClick={handleClick}
>继续</View>
</View>
</View>
</View>
)
}
export default Scene1
.modal_4 {
position: absolute;
top: 64px;
width: 468px;
height: 168px;
left: 250px;
background-image: url(https://cdn.jkwljy.com/pk-math/3hFqx2truFemx4DtRgZ4Q3mgEH6/468x168);
background-size: 100% 100%;
box-sizing: border-box;
padding: 28px 28px 28px 56px;
font-size: 40px;
font-weight: 500;
color: rgba(70,81,100,0.8);
line-height: 56px;
}
.em {
color: #1786F7;
}
.option {
bottom: -64px;
position: absolute;
left: 0;
padding: 0 32px;
width: 100vw;
box-sizing: border-box;
transform: translateY(100%);
}
.option_item {
display: flex;
align-items: center;
padding: 18px 32px 18px 60px;
background: #F4F6F8;
border-radius: 32px;
border: 6px solid transparent;
margin-bottom: 28px;
box-sizing: border-box;
&.active {
border-color: #FFC056;
}
&.disabled {
border-color: transparent;
.option_content {
color: #C2C8D1;
}
}
}
.option_icon {
width: 112px;
height: 112px;
display: block;
margin-right: 60px;
}
.option_content {
flex: 1;
font-size: 36px;
font-weight: 500;
line-height: 50px;
color: #465164;
}
import { View, Text, Image, ScrollView } from '@tarojs/components'
import classNames from 'classnames'
import assets from '@/assets/oss/assets-guide'
import { useBoolean } from '@/hooks'
import cs from './index.module.scss'
import styles from './scene-2.module.scss'
type Scene2Props = {
spriteTop: number;
onNext: () => void;
}
const Scene2 = (props: Scene2Props) => {
const { spriteTop, onNext } = props
const [active1, active1Action] = useBoolean(false)
const [active2, active2Action] = useBoolean(false)
const [active3, active3Action] = useBoolean(false)
const isActive = active1 || active2 || active3
return (
<View className={cs.viewport}>
<View className={cs.viewport_body}>
<ScrollView className={cs.viewport_body_inner} scrollY>
<View className={classNames(cs.sprite, cs.step_static)} style={{ paddingTop: `${spriteTop}px` }}>
<Image src="https://cdn.jkwljy.com/pk-math/2G8dDyjuzbMbZ94UhwCpn7zUpw7V/300x300" className={cs.cat} />
<View className={styles.modal_4} style={{ marginTop: `${spriteTop}px` }}>
<Text>请问同学有哪些<Text className={styles.em}>计算问题</Text>需要提高呢?</Text>
</View>
<View className={styles.option}>
<View className={classNames(styles.option_item, active1 && styles.active, active3 && styles.disabled)} onClick={active1Action.toggle}>
{active3
? (<Image src={assets['up-1-off.png'].u} className={styles.option_icon}></Image>)
: (<Image src={assets['up-1.png'].u} className={styles.option_icon}></Image>)
}
<View className={styles.option_content}>计算时不时会出错,想提高正确率</View>
</View>
<View className={classNames(styles.option_item, active2 && styles.active, active3 && styles.disabled)} onClick={active2Action.toggle}>
{active3
? (<Image src={assets['up-2-off.png'].u} className={styles.option_icon}></Image>)
: (<Image src={assets['up-2.png'].u} className={styles.option_icon}></Image>)
}
<View className={styles.option_content}>计算不熟练,想提高运算速度</View>
</View>
<View className={classNames(styles.option_item, active3 && styles.active)} onClick={active3Action.toggle}>
<Image src={assets['up-3.png'].u} className={styles.option_icon}></Image>
<View className={styles.option_content}>计算完全没有问题了,已经又快又准</View>
</View>
</View>
</View>
</ScrollView>
</View>
<View className={cs.footer}>
<View className={cs.footer_inner}>
<View
className={classNames(cs.btn, !isActive && cs.disabled)}
hoverClass={!isActive ? cs.is_hover : ''}
onClick={onNext}
>继续</View>
</View>
</View>
</View>
)
}
export default Scene2
.modal_4 {
position: absolute;
top: 64px;
width: 468px;
height: 168px;
left: 250px;
background-image: url(https://cdn.jkwljy.com/pk-math/3hFqx2truFemx4DtRgZ4Q3mgEH6/468x168);
background-size: 100% 100%;
box-sizing: border-box;
padding: 28px 28px 28px 56px;
font-size: 40px;
font-weight: 500;
color: rgba(70,81,100,0.8);
line-height: 56px;
}
.wrap {
height: 100vh;
display: flex;
flex-direction: column;
}
.question {
padding: 0 32px;
box-sizing: border-box;
}
.body {
flex: 1;
position: relative;
}
.body_inner {
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
}
.item {
font-weight: 500;
color: #465164;
padding: 60px 32px 0 32px;
box-sizing: border-box;
font-size: 80px;
display: flex;
line-height: 112px;
align-items: center;
flex-direction: column;
}
.simple {
display: flex;
align-items: center;
justify-content: center;
flex-wrap: wrap;
}
import { View, Text, Image, ScrollView } from '@tarojs/components'
import { useLocalStore, action, Action, Thunk, thunk, State } from 'easy-peasy'
import classNames from 'classnames'
import { useMemo } from 'react'
import assets from '@/assets/oss/assets-guide'
import { useBoolean } from '@/hooks'
import NumberKeyboard from '@/pages/game/play/components/number-keyboard'
import MathSymbol from '@/pages/game/play/components/math-symbol'
import PageFooter from '@/pages/game/play/components/page-footer'
import cs from './index.module.scss'
import styles from './scene-3.module.scss'
import AnswerBlank from './components/answer-blank'
import CountUp from './components/count-up'
type Scene3Props = {
spriteTop: number;
onNext: () => void;
}
type QuestionModel = {
values: string[];
wrong: boolean;
current: number;
isSubmit: boolean;
updateState: Action<QuestionModel, Partial<State<QuestionModel>>>;
updateAnswer: Action<QuestionModel, string>;
goNext: Thunk<QuestionModel, (() => void) | void>;
clearUserAnswers: Action<QuestionModel>;
updateWrong: Action<QuestionModel, boolean>;
}
const rightAnswers = ['15', '5', '18']
const Scene3 = (props: Scene3Props) => {
const { spriteTop, onNext } = props
const [state, actions] = useLocalStore<QuestionModel>(() => ({
values: ['', '', ''],
updateState: action((_state, p) => {
for (const k in p) {
_state[k] = p[k]
}
}),
wrong: false,
current: 0,
isSubmit: false,
updateWrong: action((_state, p) => {
_state.wrong = p
}),
updateAnswer: action((_state, str) => {
const pre = _state.values[_state.current]
_state.values[_state.current] = pre + str
}),
goNext: thunk((_act, cb, helpers) => {
const { current, values } = helpers.getState()
if (values[current] !== rightAnswers[current]) {
_act.updateState({ wrong: true })
setTimeout(() => {
_act.updateState({ wrong: false })
}, 1000)
} else if (current === 2) {
cb?.()
} else {
_act.updateState({ current: current + 1 })
}
}),
clearUserAnswers: action(_state => {
_state.values[_state.current] = ''
})
}))
const questionList = useMemo(() => {
return [
{
content: (
<View className={styles.simple}>
45<MathSymbol value="/"></MathSymbol>9<MathSymbol value="*"></MathSymbol>3<MathSymbol value="="></MathSymbol>
<AnswerBlank value={state.values[0]} isWrong={state.wrong}></AnswerBlank>
</View>
),
},
{
content: (
<View className={styles.simple}>
27<MathSymbol value="/"></MathSymbol>9<MathSymbol value="*"></MathSymbol><AnswerBlank value={state.values[1]} isWrong={state.wrong}></AnswerBlank><MathSymbol value="="></MathSymbol>
15
</View>
),
},
{
content: (
<View className={styles.simple}>
27<MathSymbol value="/"></MathSymbol>9<MathSymbol value="+"></MathSymbol>15<MathSymbol value="="></MathSymbol><AnswerBlank value={state.values[2]} isWrong={state.wrong}></AnswerBlank>
</View>
),
},
]
}, [state.values, state.wrong])
const canGoNext = useMemo(() => {
return !!state.values[state.current]
}, [state])
const handleGoNext = () => {
actions.goNext(onNext)
}
return (
<View className={cs.viewport}>
<View className={cs.viewport_body}>
<ScrollView className={cs.viewport_body_inner} scrollY>
<View className={classNames(cs.sprite, cs.step_static)} style={{ paddingTop: `${spriteTop}px` }}>
<Image src="https://cdn.jkwljy.com/pk-math/2G8dDyjuzbMbZ94UhwCpn7zUpw7V/300x300" className={cs.cat} />
<View className={styles.modal_4} style={{ marginTop: `${spriteTop}px` }}>
<View>我们来试试吧! </View>
<View>请在输入框填写答案</View>
</View>
<View className={styles.question}>
<CountUp currentIndex={state.current} isSubmit={state.isSubmit}></CountUp>
<View className={styles.item}>
{questionList[state.current].content}
</View>
</View>
</View>
</ScrollView>
</View>
<View>
<NumberKeyboard onClick={actions.updateAnswer}></NumberKeyboard>
<PageFooter
canGoNext={canGoNext}
confirmText="继续"
handleGoNext={handleGoNext}
clearUserAnswer={actions.clearUserAnswers}
isLastQuestion={state.current === 2}
></PageFooter>
</View>
</View>
)
}
export default Scene3
.modal_4 {
position: absolute;
top: 64px;
width: 468px;
height: 168px;
left: 250px;
background-image: url(https://cdn.jkwljy.com/pk-math/3hFqx2truFemx4DtRgZ4Q3mgEH6/468x168);
background-size: 100% 100%;
box-sizing: border-box;
padding: 28px 28px 28px 56px;
font-size: 40px;
font-weight: 500;
color: rgba(70,81,100,0.8);
line-height: 56px;
}
.tag {
display: flex;
align-items: center;
justify-content: center;
padding-top: 68px;
}
.tag_item {
display: flex;
align-items: center;
&:first-child {
margin-right: 32px;
}
}
.tag_icon {
width: 60px;
height: 60px;
display: block;
margin-right: -30px;
position: relative;
z-index: 1;
}
.tag_text {
height: 56px;
background: #F4F6F8;
border-radius: 30px;
display: flex;
align-items: center;
justify-content: center;
width: 152px;
font-size: 28px;
font-weight: 500;
color: #465164;
line-height: 34px;
}
.title {
font-size: 36px;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: #465164;
line-height: 50px;
padding: 48px 0 20px 54px;
position: relative;
&::after {
position: absolute;
content: " ";
left: 32px;
top: 53px;
width: 10px;
height: 40px;
background: #FE9B45;
border-radius: 6px;
}
}
.btn_tips {
font-size: 28px;
font-weight: 500;
color: #FE9B45;
line-height: 40px;
text-align: center;
padding-bottom: 32px;
}
.card {
margin: 0 32px 0 54px;
border-radius: 32px;
border: 6px solid #F4F6F8;
padding: 24px;
display: flex;
align-items: center;
.icon {
width: 112px;
height: 112px;
margin-right: 20px;
display: block;
flex-shrink: 0;
}
.text {
flex: 1;
font-size: 28px;
font-weight: 500;
color: rgba(70,81,100,0.8);
line-height: 44px;
}
}
.glod {
color: #FE9B45;
}
.tips {
font-size: 28px;
font-weight: 600;
color: rgba(70,81,100,0.5);
line-height: 40px;
margin-top: 16px;
text-align: center;
}
import { View, Text, Image, ScrollView } from '@tarojs/components'
import classNames from 'classnames'
import assets from '@/assets/oss/assets-guide'
import { useBoolean } from '@/hooks'
import cs from './index.module.scss'
import styles from './scene-4.module.scss'
type Scene4Props = {
spriteTop: number;
onNext: () => void;
}
const Scene4 = (props: Scene4Props) => {
const { spriteTop, onNext } = props
const isActive = true
return (
<View className={cs.viewport}>
<View className={cs.viewport_body}>
<ScrollView className={cs.viewport_body_inner} scrollY>
<View className={classNames(cs.sprite, cs.step_static)} style={{ paddingTop: `${spriteTop}px` }}>
<Image src="https://cdn.jkwljy.com/pk-math/2G8dDyjuzbMbZ94UhwCpn7zUpw7V/300x300" className={cs.cat} />
<View className={styles.modal_4} style={{ marginTop: `${spriteTop}px` }}>
<Text>恭喜你,表内乘除法,你掌握得不错哦</Text>
</View>
</View>
<View className={styles.tag}>
<View className={styles.tag_item}>
<Image src={assets['all-right.png'].u} className={styles.tag_icon}></Image>
<View className={styles.tag_text}>全对</View>
</View>
<View className={styles.tag_item}>
<Image src={assets['time-count.png'].u} className={styles.tag_icon}></Image>
<View className={styles.tag_text}>全对</View>
</View>
</View>
<View>
<View className={styles.title}>达标等级:</View>
<View className={styles.card}>
<Image src={assets['s.png'].u} className={styles.icon}></Image>
<View className={styles.text}>以本次练习的水准,继续答对15题,那你就达到<Text className={styles.glod}>B级实力</Text>了</View>
</View>
<View className={styles.tips}>* 共有 B → A → S 三个水准</View>
</View>
<View>
<View className={styles.title}>排行成就:</View>
<View className={styles.card}>
<Image src={assets['top10.png'].u} className={styles.icon}></Image>
<View className={styles.text}>
<View>本次练习非常优秀哦, </View>
<View>排在所有同学前百分<Text className={styles.glod}>前百分之三十</Text></View>
</View>
</View>
<View className={styles.tips}>* 共有 TOP30% → TOP20% → TOP10% 三个成就</View>
</View>
</ScrollView>
</View>
<View className={cs.footer}>
<View className={cs.footer_inner}>
<View className={styles.btn_tips}>如果每个技能达到S水准,那面对考试,就胜券在握了</View>
<View
className={classNames(cs.btn, !isActive && cs.disabled)}
hoverClass={!isActive ? cs.is_hover : ''}
onClick={onNext}
>继续</View>
</View>
</View>
</View>
)
}
export default Scene4
.modal_4 {
position: absolute;
top: 64px;
width: 468px;
height: 168px;
left: 250px;
background-image: url(https://cdn.jkwljy.com/pk-math/2LAQN5FBeoW6UrQEaRVQVP6HTU25/468x224);
background-size: 100% 100%;
box-sizing: border-box;
padding: 28px 28px 28px 56px;
font-size: 40px;
font-weight: 500;
color: rgba(70,81,100,0.8);
line-height: 56px;
}
.em {
color: #1786F7;
}
.option {
padding: 64px 32px 0 32px;
}
.option_item {
display: flex;
align-items: center;
padding: 18px 32px 18px 28px;
background: #F4F6F8;
border-radius: 32px;
border: 6px solid transparent;
margin-bottom: 28px;
box-sizing: border-box;
&.active {
border-color: #FFC056;
}
&.disabled {
border-color: transparent;
.option_content {
color: #C2C8D1;
}
}
}
.option_icon {
width: 112px;
height: 112px;
display: block;
margin-right: 20px;
}
.option_content {
flex: 1;
font-size: 36px;
font-weight: 400;
color: #465164;
line-height: 50px;
.b {
font-weight: 600;
}
}
.card_wrap {
display: flex;
align-items: center;
justify-content: center;
}
.card {
width: 218px;
border-radius: 24px;
border: 6px solid #F4F6F8;
margin-right: 16px;
padding: 28px 0 20px 0;
text-align: center;
position: relative;
&:last-child {
margin-right: 0;
}
}
.right {
position: absolute;
right: 0;
top: -16px;
width: 48px;
height: 48px;
}
.card_icon {
display: block;
width: 112px;
height: 112px;
margin: 0 auto;
}
.tip1 {
font-size: 36px;
font-weight: 500;
color: #465164;
line-height: 50px;
margin-top: 16px;
}
.tip2 {
font-size: 28px;
font-weight: 500;
color: rgba(70,81,100,0.5);
line-height: 40px;
margin-top: 8px;
}
.tips3 {
font-size: 36px;
font-weight: 500;
color: #465164;
line-height: 50px;
text-align: center;
padding: 112px 0 32px 0;
}
.gold {
color: #FE9B45;
}
import { View, Text, Image, ScrollView } from '@tarojs/components'
import classNames from 'classnames'
import assets from '@/assets/oss/assets-guide'
import { useBoolean } from '@/hooks'
import cs from './index.module.scss'
import styles from './scene-5.module.scss'
type Scene5Props = {
spriteTop: number;
onNext: () => void;
}
const Scene5 = (props: Scene5Props) => {
const { spriteTop, onNext } = props
const [active1, active1Action] = useBoolean(false)
const [active2, active2Action] = useBoolean(false)
const [active3, active3Action] = useBoolean(false)
const [isSubmit, submitAction] = useBoolean(false)
const isActive = active1 || active2 || active3
const handleClick = () => {
if (isSubmit) {
onNext()
} else {
submitAction.setTrue()
}
}
return (
<View className={cs.viewport}>
<View className={cs.viewport_body}>
<ScrollView className={cs.viewport_body_inner} scrollY>
<View className={classNames(cs.sprite, cs.step_static)} style={{ paddingTop: `${spriteTop}px` }}>
<Image src="https://cdn.jkwljy.com/pk-math/2G8dDyjuzbMbZ94UhwCpn7zUpw7V/300x300" className={cs.cat} />
<View className={styles.modal_4} style={{ marginTop: `${spriteTop}px` }}>
<Text>请问同学有哪些<Text className={styles.em}>计算问题</Text>需要提高呢?</Text>
</View>
{isSubmit && (
<View>
<View className={styles.tips3}>帮助你<Text className={styles.gold}>从易到难</Text>,逐个掌握。</View>
<View className={styles.card_wrap}>
<View className={styles.card}>
<Image src={assets['right.png'].u} className={styles.right} />
<Image src={assets['book-1.png'].u} className={styles.card_icon}></Image>
<View className={styles.tip1}>常考应用题</View>
<View className={styles.tip2}>每学期近30类</View>
</View>
<View className={styles.card}>
<Image src={assets['right.png'].u} className={styles.right} />
<Image src={assets['book-2.png'].u} className={styles.card_icon}></Image>
<View className={styles.tip1}>常考应用题</View>
<View className={styles.tip2}>每学期近30类</View>
</View>
<View className={styles.card}>
<Image src={assets['right.png'].u} className={styles.right} />
<Image src={assets['book-3.png'].u} className={styles.card_icon}></Image>
<View className={styles.tip1}>常考应用题</View>
<View className={styles.tip2}>每学期近30类</View>
</View>
</View>
</View>
)}
{!isSubmit && (
<View className={styles.option}>
<View className={classNames(styles.option_item, active1 && styles.active)} onClick={active1Action.toggle}>
<Image src={assets['book-1.png'].u} className={styles.option_icon}></Image>
<View className={styles.option_content}><Text className={styles.b}>常考应用题</Text>时不时会出错,想让应用题掌握更</View>
</View>
<View className={classNames(styles.option_item, active2 && styles.active)} onClick={active2Action.toggle}>
<Image src={assets['book-2.png'].u} className={styles.option_icon}></Image>
<View className={styles.option_content}><Text className={styles.b}>灵活应用题</Text>没有思路,想提升问题分析能力</View>
</View>
<View className={classNames(styles.option_item, active3 && styles.active)} onClick={active3Action.toggle}>
<Image src={assets['book-3.png'].u} className={styles.option_icon}></Image>
<View className={styles.option_content}><Text className={styles.b}>附加拓展题</Text>时常不会,想提升数学思维,掌握</View>
</View>
</View>
)}
</View>
</ScrollView>
</View>
<View className={cs.footer}>
<View className={cs.footer_inner}>
<View
className={classNames(cs.btn, !isActive && cs.disabled)}
hoverClass={!isActive ? cs.is_hover : ''}
onClick={handleClick}
>{isSubmit ? '开启我的快乐提升之旅' : '继续'}</View>
</View>
</View>
</View>
)
}
export default Scene5
.modal_4 {
position: absolute;
top: 64px;
width: 468px;
height: 168px;
left: 250px;
background-image: url(https://cdn.jkwljy.com/pk-math/3hFqx2truFemx4DtRgZ4Q3mgEH6/468x168);
background-size: 100% 100%;
box-sizing: border-box;
padding: 28px 28px 28px 56px;
font-size: 40px;
font-weight: 500;
color: rgba(70,81,100,0.8);
line-height: 56px;
}
.em {
color: #1786F7;
}
.tips {
font-size: 28px;
font-weight: 500;
color: rgba(70,81,100,0.5);
line-height: 40px;
margin-top: 8px;
}
.full {
min-height: 100%;
display: flex;
flex-direction: column;
}
.top {
flex: 2;
}
.bottom {
flex: 4;
}
.input {
display: flex;
align-items: center;
padding: 24px 28px 24px 48px;
margin: 0 120px;
background: #F4F6F8;
border-radius: 56px;
}
.input_item {
flex: 1;
font-size: 36px;
font-weight: 600;
color: #465164;
line-height: 50px;
}
.input_tip {
margin-top: 32px;
display: flex;
font-size: 28px;
font-weight: 600;
color: rgba(70,81,100,0.5);
line-height: 40px;
align-items: center;
justify-content: center;
}
.score {
width: 64px;
height: 64px;
display: block;
}
.input_icon {
width: 64px;
height: 64px;
display: block;
}
.btn_tip {
font-size: 28px;
font-weight: 600;
color: rgba(70,81,100,0.5);
line-height: 40px;
text-align: center;
padding-bottom: 32px;
}
import { View, Text, Image, ScrollView, Button, CommonEventFunction, ButtonProps } from '@tarojs/components'
import classNames from 'classnames'
import { useState, useCallback } from 'react'
import { useStoreActions } from '@/store/hooks'
import assets from '@/assets/oss/assets-guide'
import cs from './index.module.scss'
import styles from './scene-6.module.scss'
type Scene6Props = {
spriteTop: number;
onNext: () => void;
}
const Scene6 = (props: Scene6Props) => {
const { spriteTop, onNext } = props
const [name, setName] = useState('好娃娃')
const updateNickNameAndPhone = useStoreActions(actions => actions.userModel.updateNickNameAndPhone)
const handleGetPhone = useCallback<CommonEventFunction<ButtonProps.onGetPhoneNumberEventDetail>>((e) => {
updateNickNameAndPhone({ code: e.detail.code!, name })
.then(() => onNext())
}, [updateNickNameAndPhone, onNext, name])
return (
<View className={cs.viewport}>
<View className={cs.viewport_body}>
<ScrollView className={cs.viewport_body_inner} scrollY>
<View className={styles.full}>
<View className={classNames(cs.sprite, cs.step_static)} style={{ paddingTop: `${spriteTop}px` }}>
<Image src="https://cdn.jkwljy.com/pk-math/2G8dDyjuzbMbZ94UhwCpn7zUpw7V/300x300" className={cs.cat} />
<View className={styles.modal_4} style={{ marginTop: `${spriteTop}px` }}>
<View>请选择你的昵称</View>
<View className={styles.tips}>*仅用于排行榜展示哦</View>
</View>
</View>
<View className={styles.top}></View>
<View>
<View className={styles.input}>
<View className={styles.input_item}>阳光学习帮</View>
<Image src={assets['touzi.png'].u} className={styles.input_icon}></Image>
</View>
<View className={styles.input_tip}>
确定后奖励<Image src={assets['score.png'].u} className={styles.score}></Image><Text className={styles.em}>+100</Text>
</View>
</View>
<View className={styles.bottom}></View>
</View>
</ScrollView>
</View>
<View className={cs.footer}>
<View className={cs.footer_inner}>
<View className={styles.btn_tip}>同时为保存你的闯关数据,请进行授权</View>
{!name
? (
<View
className={classNames(cs.btn, cs.disabled)}
>确定</View>
)
: (
<Button
openType="getPhoneNumber"
onGetPhoneNumber={handleGetPhone}
className={cs.btn}
hoverClass={cs.is_hover}
>确定</Button>
)}
</View>
</View>
</View>
)
}
export default Scene6
import { useState, useEffect, useRef } from 'react'
import { Text } from '@tarojs/components'
type TextPrinterProps = {
textList: { text: string }[];
speed?: number;
pauseTime?: number;
onEnd?: () => void;
}
const TextPrinter = (props: TextPrinterProps) => {
const { textList, onEnd, speed = 200, pauseTime = 200 } = props
const [visibleText, setVisibleText] = useState('')
const charIndex = useRef(0)
const currentTextIndex = useRef(0)
const pauseTimeRef = useRef(0)
useEffect(() => {
let animationFrameId: number | null = null
let lastFrameTime: number | null = null
const shouldDisplayNextChar = (timestamp: number, spd: number) => {
if (!lastFrameTime) {
lastFrameTime = timestamp
}
const elapsed = timestamp - (lastFrameTime ?? 0)
if (elapsed >= spd) {
lastFrameTime = timestamp
return true
}
return false
}
const animateText = (timestamp) => {
let currentText = textList[currentTextIndex.current]
if (!currentText) return
if (charIndex.current >= currentText.text.length) {
charIndex.current = 0
currentTextIndex.current += 1
if (currentTextIndex.current >= textList.length) {
onEnd && onEnd()
return
}
/** 停顿 */
pauseTimeRef.current = pauseTime
}
currentText = textList[currentTextIndex.current]
if (shouldDisplayNextChar(timestamp, speed + pauseTimeRef.current)) {
setVisibleText((prevText) => prevText + currentText.text[charIndex.current])
charIndex.current += 1
pauseTimeRef.current = 0
}
animationFrameId = requestAnimationFrame(animateText)
}
animationFrameId = requestAnimationFrame(animateText)
return () => {
if (animationFrameId) {
cancelAnimationFrame(animationFrameId)
}
}
}, [textList, onEnd, speed, pauseTime])
return (
<Text>{visibleText}</Text>
)
}
export default TextPrinter
export default definePageConfig({ export default definePageConfig({
navigationBarTitleText: 'pk-math', navigationBarTitleText: 'pk-math',
navigationStyle: 'custom', navigationStyle: 'custom',
navigationBarTextStyle: 'white' navigationBarTextStyle: 'white',
usingComponents: {
'count-up-time': '../../native-components/count-up/index'
}
}) })
.loading {
.body { height: 100vh;
position: relative; display: flex;
z-index: 1; align-items: center;
padding-bottom: 56PX; justify-content: center;
} color: #1786F7;
@supports (height: constant(safe-area-inset-bottom)) or (height: env(safe-area-inset-bottom)) {
.gap {
height: constant(safe-area-inset-bottom);
height : env(safe-area-inset-bottom);
}
} }
import { useEffect, useState, useCallback } from 'react'
import { View } from '@tarojs/components' import { View } from '@tarojs/components'
import { import { getStorage, StorageKeys } from '@/utils/storage'
getMenuButtonBoundingClientRect, useDidShow, import { silentLoginDeferred } from '@/utils/silent-login'
getCurrentInstance, getTabBar, pageScrollTo, getSystemInfoSync, import Loading from '@/components/Loading'
nextTick
} from '@tarojs/taro'
import { useState, useMemo, useCallback } from 'react'
import { useStoreActions, useStoreState } from '@/store/hooks'
import type { TabbarRef } from '../../custom-tab-bar/index'
import { CurrentRoundId, SceneContext, StageStatus } from './components/scene/constants'
import MainHeader from './components/header'
import MainChapter from './components/chapter'
import MainScene from './components/scene'
import MainShortCut from './components/short-cut'
import useShowShareModal from './use-show-share-modal'
import styles from './main.module.scss' import styles from './main.module.scss'
import MainComponent from './components/main-component'
import Guide from './guide'
const MainPage = () => { const MainPage = () => {
const page = useMemo(() => getCurrentInstance().page, []) const [isDone, setIsDone] = useState(false)
const [isReady, setIsReady] = useState(false) const [isReady, setIsReady] = useState(false)
const fetchStage = useStoreActions(actions => actions.mainModel.fetchStage)
const stageList = useStoreState(state => state.mainModel.stageList)
const fetchAccount = useStoreActions(actions => actions.userModel.fetchAccount)
const nav = useMemo(getMenuButtonBoundingClientRect, [])
useShowShareModal() const handleDone = useCallback(() => {
setIsDone(true)
}, [])
const scrollToCurrent = useCallback((callback?: () => void) => { useEffect(() => {
const height = getSystemInfoSync().windowHeight silentLoginDeferred.getPromise().then(() => {
pageScrollTo({ const userInfo = getStorage(StorageKeys.userInfo)
selector: `#${CurrentRoundId}`, if (userInfo?.nickName) {
offsetTop: -height / 2, setIsDone(true)
complete: callback }
setIsReady(true)
}) })
}, []) }, [])
useDidShow(() => { if (!isReady) {
fetchAccount() return (
<View className={styles.loading}>
const tabbar = getTabBar<TabbarRef>(page) <Loading spinning size="large"></Loading>
tabbar?.setSelected(0) </View>
)
}
fetchStage().then((list) => { if (isDone) {
nextTick(() => { return (
if (!list.find(c => c.status === StageStatus.CURRENT)) { <MainComponent />
setIsReady(true) )
} else {
scrollToCurrent(() => {
setIsReady(true)
})
} }
})
})
})
return ( return (
<> <Guide onDone={handleDone} />
<MainHeader />
<View className={styles.body} style={{ paddingTop: `${nav.height + nav.top + 5}px` }}>
<MainChapter />
{/* <Button openType="getPhoneNumber" onGetPhoneNumber={handleClick}>shouji</Button> */}
<SceneContext.Provider value={{ ready: isReady }}>
<MainScene stageList={stageList} />
</SceneContext.Provider>
<View className={styles.gap}></View>
</View>
{isReady && (
<MainShortCut onClick={() => scrollToCurrent()} />
)}
</>
) )
} }
......
...@@ -6,12 +6,18 @@ import { type Stage, getStageList } from '@/api' ...@@ -6,12 +6,18 @@ import { type Stage, getStageList } from '@/api'
export interface MainModel { export interface MainModel {
stageList: Stage[]; stageList: Stage[];
isReady: boolean;
updateReady: Action<MainModel, boolean>;
updateStageList: Action<MainModel, Stage[]>; updateStageList: Action<MainModel, Stage[]>;
fetchStage: Thunk<MainModel, void, void, AppStoreModel, Promise<Stage[]>>; fetchStage: Thunk<MainModel, void, void, AppStoreModel, Promise<Stage[]>>;
} }
const mainModel: MainModel = { const mainModel: MainModel = {
isReady: false,
stageList: [], stageList: [],
updateReady: action((state, payload) => {
state.isReady = payload
}),
updateStageList: action((state, stageList) => { updateStageList: action((state, stageList) => {
state.stageList = stageList state.stageList = stageList
}), }),
......
import { import {
action, Action, Thunk, thunk, State action, Action, Thunk, thunk, State
} from 'easy-peasy' } from 'easy-peasy'
import { getAccountInfo, getSetting, updateUserInfo } from '@/api' import { getAccountInfo, getSetting, updateUserInfo, updateUserPhone } from '@/api'
import type { UserInfo } from '@/types' import type { UserInfo } from '@/types'
import { pointToCard } from '@/api/account' import { pointToCard } from '@/api/account'
import { showModal, showToast, showLoading, hideLoading } from '@tarojs/taro' import { showModal, showToast, showLoading, hideLoading } from '@tarojs/taro'
...@@ -16,9 +16,11 @@ export interface UserModel { ...@@ -16,9 +16,11 @@ export interface UserModel {
fetchAccount: Thunk<UserModel, void, void, AppStoreModel>; fetchAccount: Thunk<UserModel, void, void, AppStoreModel>;
setting: { pointToCard: number }; setting: { pointToCard: number };
getSetting: Thunk<UserModel, void, void, AppStoreModel>; getSetting: Thunk<UserModel, void, void, AppStoreModel>;
updateUserInfo: Thunk<UserModel, string, void, AppStoreModel>; // updateUserInfo: Thunk<UserModel, string, void, AppStoreModel>;
exchangeItem: Thunk<UserModel, { name: string; num: number; }, void, AppStoreModel>; exchangeItem: Thunk<UserModel, { name: string; num: number; }, void, AppStoreModel>;
updateNickNameAndPhone: Thunk<UserModel, { code: string; name: string }, void, AppStoreModel>;
} }
const userModel: UserModel = { const userModel: UserModel = {
...@@ -26,19 +28,15 @@ const userModel: UserModel = { ...@@ -26,19 +28,15 @@ const userModel: UserModel = {
cardNum: 0, cardNum: 0,
point: 0, point: 0,
setting: { pointToCard: Infinity }, setting: { pointToCard: Infinity },
getSetting: thunk(async (actions) => {
try { updateNickNameAndPhone: thunk(async (actions, payload, helpers) => {
const { data } = await getSetting()
actions.updateState({ setting: data })
} catch (err) {
actions.updateState({ setting: { pointToCard: Infinity } })
}
}),
updateUserInfo: thunk(async (actions, nickName, helpers) => {
try { try {
await updateUserInfo(nickName) await Promise.all([
updateUserPhone(payload.code),
updateUserInfo(payload.name),
])
const { userInfo } = helpers.getState() const { userInfo } = helpers.getState()
const current = { ...userInfo, nickName } const current = { ...userInfo, nickName: payload.name }
updateStorage(StorageKeys.userInfo, current) updateStorage(StorageKeys.userInfo, current)
actions.updateState({ actions.updateState({
userInfo: current userInfo: current
...@@ -47,6 +45,30 @@ const userModel: UserModel = { ...@@ -47,6 +45,30 @@ const userModel: UserModel = {
console.log(err) console.log(err)
} }
}), }),
getSetting: thunk(async (actions) => {
try {
const { data } = await getSetting()
actions.updateState({ setting: data })
} catch (err) {
actions.updateState({ setting: { pointToCard: Infinity } })
}
}),
// updateUserInfo: thunk(async (actions, nickName, helpers) => {
// try {
// await updateUserInfo(nickName)
// const { userInfo } = helpers.getState()
// const current = { ...userInfo, nickName }
// updateStorage(StorageKeys.userInfo, current)
// actions.updateState({
// userInfo: current
// })
// } catch (err) {
// console.log(err)
// }
// }),
exchangeItem: thunk(async (actions, payload) => { exchangeItem: thunk(async (actions, payload) => {
try { try {
showLoading({ mask: true, title: '兑换中...' }) showLoading({ mask: true, title: '兑换中...' })
...@@ -65,6 +87,7 @@ const userModel: UserModel = { ...@@ -65,6 +87,7 @@ const userModel: UserModel = {
}) })
} }
}), }),
updateState: action((state, payload) => { updateState: action((state, payload) => {
for (const key in payload) { for (const key in payload) {
state[key] = payload[key] state[key] = payload[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