Commit 2a898e6d authored by hewenhao's avatar hewenhao

feat: pk 答题

parent af4c01c4
......@@ -4,5 +4,11 @@
"w": 344,
"h": 144,
"ossName": "/pk-math/3Nps4sxqLzBwdY3oQiN6G1zXEwNy/344x144"
},
"battle-icon.png": {
"u": "https://cdn.jkwljy.com/pk-math/3rh5MFpZF96fZE91zu7G1dcjdnsX/80x80",
"w": 80,
"h": 80,
"ossName": "/pk-math/3rh5MFpZF96fZE91zu7G1dcjdnsX/80x80"
}
}
......@@ -5,5 +5,10 @@ export default {
"u": "https://cdn.jkwljy.com/pk-math/3Nps4sxqLzBwdY3oQiN6G1zXEwNy/344x144",
"w": 344,
"h": 144
},
"battle-icon.png": {
"u": "https://cdn.jkwljy.com/pk-math/3rh5MFpZF96fZE91zu7G1dcjdnsX/80x80",
"w": 80,
"h": 80
}
} as const
......@@ -58,6 +58,16 @@
top: -8px;
margin-left: -40px;
&.is_battle {
.tips {
background-color: #FFB400;
}
.tick {
background-color: #FFB400;
}
}
.tick {
width: 6px;
border-radius: 3px;
......
......@@ -6,16 +6,18 @@ import { useBoolean } from '@/hooks'
import { useStoreState, useStoreActions } from '@/store/hooks'
import { type StageDetail, StageType } from '@/api'
import audio from '@/assets/oss/assets-audio'
import assetsGame from '@/assets/oss/assets-game'
import { palyAudio } from '@/utils/play-audio'
import styles from './count-up.module.scss'
type CountUpProps = {
stageDetail: StageDetail
stageDetail: StageDetail;
isBattle: boolean;
}
const CountUp = (props: CountUpProps) => {
const { stageDetail } = props
const { stageDetail, isBattle } = props
const currentQuestionIndex = useStoreState(states => states.gameModel.currentQuestionIndex)
const counterId = useStoreState(states => states.gameModel.counterId)
const questionList = useStoreState(state => state.gameModel.questionList)
......@@ -70,7 +72,6 @@ const CountUp = (props: CountUpProps) => {
}, [currentQuestionIndex, questionLength, isSubmit])
const handleTimeUp = useCallback(() => {
console.log('upd1')
if (isOneStop) {
submit()
}
......@@ -87,10 +88,16 @@ const CountUp = (props: CountUpProps) => {
<View className={styles.process_inner} style={processInnerStyle}></View>
{!isOneStop && (
<View className={styles.roleWrap} style={roleStyle}>
<View className={styles.role}>
<View className={classNames(styles.role, isBattle && styles.is_battle)}>
<View className={styles.tick}></View>
<Image src={require('../assets/count-cat.png')} className={styles.cat}></Image>
<View className={styles.tips}>通关要求</View>
{isBattle
? (
<Image src={assetsGame['battle-icon.png'].u} className={styles.cat}></Image>
)
: (
<Image src={require('../assets/count-cat.png')} className={styles.cat}></Image>
)}
<View className={styles.tips}>{isBattle ? '对手用时' : '通关要求'}</View>
</View>
</View>
)}
......
......@@ -5,7 +5,12 @@ import { useStoreState } from '@/store/hooks'
import styles from './page-head.module.scss'
const PageHead = () => {
type PageHeadProps = {
isBattle: boolean;
}
const PageHead = (props: PageHeadProps) => {
const { isBattle } = props
const [nav] = useState(getMenuButtonBoundingClientRect())
const questionList = useStoreState(states => states.gameModel.questionList)
const currentQuestionIndex = useStoreState(states => states.gameModel.currentQuestionIndex)
......@@ -19,7 +24,9 @@ const PageHead = () => {
}}
>
<View className={styles.inner} style={{ height: `${nav.height + 10}px` }}>
<Image src={require('../assets/arrow.png')} className={styles.arrow} onClick={() => navigateBack()}></Image>
{!isBattle && (
<Image src={require('../assets/arrow.png')} className={styles.arrow} onClick={() => navigateBack()}></Image>
)}
{questionList.length > 0
? (<Text>{currentQuestionIndex + 1}/{questionList.length}</Text>)
: (<Text>出错了</Text>)
......
......@@ -2,7 +2,7 @@ import { ScrollView, Image } from '@tarojs/components'
import { useStoreState, useStoreActions } from '@/store/hooks'
import { preloadImage } from '@/utils/preload-image'
import { useEffect, useMemo } from 'react'
import { useDidShow, enableAlertBeforeUnload, disableAlertBeforeUnload } from '@tarojs/taro'
import { useDidShow, enableAlertBeforeUnload, disableAlertBeforeUnload, useRouter } from '@tarojs/taro'
import assets from '@/assets/oss/assets-complete'
import { EyeProtectionView } from '@/components'
......@@ -42,6 +42,12 @@ const GamePlay = () => {
const clearUserAnswer = useStoreActions(actions => actions.gameModel.clearUserAnswer)
const handleGoNext = useStoreActions(actions => actions.gameModel.handleGoNext)
const router = useRouter()
const isBattle = useMemo(() => {
return router.params.isBattle === 'true'
}, [router])
useEffect(() => {
enableAlertBeforeUnload({
message: '还没有答完哦,确定要离开吗?',
......@@ -61,9 +67,9 @@ const GamePlay = () => {
return (
<>
<EyeProtectionView className={styles.viewport}>
<PageHead />
<PageHead isBattle={isBattle} />
{currentQuestion && stageDetail && (
<CountUp stageDetail={stageDetail} />
<CountUp stageDetail={stageDetail} isBattle={isBattle} />
)}
<ScrollView className={styles.body} scrollY>
{currentQuestion && (
......
......@@ -43,7 +43,7 @@
flex: 1;
position: relative;
width: 100%;
transition: transform .5s ease-out;
transition: transform .5s ease-in;
}
.top {
......@@ -92,9 +92,9 @@
left: 50%;
margin-left: -155px;
animation-name: shake;
animation-timing-function: ease-out;
animation-timing-function: ease-in;
animation-fill-mode: backwards;
animation-duration: 1s;
animation-duration: 0.8s;
animation-delay: .5s;
}
......@@ -146,8 +146,8 @@
.pk_flash_left, .pk_flash_right {
width: 360px;
height: 200px;
animation-timing-function: ease-out;
animation-duration: 1s;
animation-timing-function: ease-in;
animation-duration: 0.8s;
animation-fill-mode: backwards;
animation-delay: 0.5s;
}
......
......@@ -41,6 +41,7 @@ const CreatePk = (props: CreatePkProps) => {
<Image src={assetsMainNext['pk-close.png'].u} className={styles.close_icon}></Image>
</View>
</View>
<View className={classNames(styles.top, visible && styles.is_show)}>
<Image src={assetsMainNext['pk-top.png'].u} className={styles.bg_top} mode="widthFix"></Image>
<View className={styles.top_content}>
......@@ -56,6 +57,7 @@ const CreatePk = (props: CreatePkProps) => {
</View>
</View>
</View>
<View className={classNames(styles.bottom, visible && styles.is_show)}>
<Image src={assetsMainNext['pk-slogen.png'].u} className={styles.pk_slogan}></Image>
<Image src={assetsMainNext['pk-bottom.png'].u} className={styles.bg_bottom} mode="widthFix"></Image>
......@@ -70,6 +72,7 @@ const CreatePk = (props: CreatePkProps) => {
<View className={styles.tips}>会以你的最佳表现与对方答题数据进行PK</View>
</View>
</View>
{visible && (
<View className={styles.center}>
<View className={styles.pk_flash}>
......
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