Commit cf7c7825 authored by hewenhao's avatar hewenhao

Merge branch 'feature/2023-04-19-iter' of…

Merge branch 'feature/2023-04-19-iter' of dev.jiuaoedu.com:hewenhao/GeekLearnMathWeapp into feature/2023-04-19-iter
parents 48f179ed e9301aa7
...@@ -94,5 +94,29 @@ ...@@ -94,5 +94,29 @@
"w": 750, "w": 750,
"h": 960, "h": 960,
"ossName": "/pk-math/39zMBKhthpUN8JGaLtJ5e1qmnewc/750x960" "ossName": "/pk-math/39zMBKhthpUN8JGaLtJ5e1qmnewc/750x960"
},
"arror-bottom-left.png": {
"u": "https://cdn.jkwljy.com/pk-math/21nmtfooeLeoKtMNsHqa2AMinWSi/128x128",
"w": 128,
"h": 128,
"ossName": "/pk-math/21nmtfooeLeoKtMNsHqa2AMinWSi/128x128"
},
"arrow-top-left.png": {
"u": "https://cdn.jkwljy.com/pk-math/3VAxvzEMBNyVZMuwf8hRTWDvgtnC/128x128",
"w": 128,
"h": 128,
"ossName": "/pk-math/3VAxvzEMBNyVZMuwf8hRTWDvgtnC/128x128"
},
"cat-4.png": {
"u": "https://cdn.jkwljy.com/pk-math/3tYeViwvJo7vFGEUsNhaCSfx8G55/300x300",
"w": 300,
"h": 300,
"ossName": "/pk-math/3tYeViwvJo7vFGEUsNhaCSfx8G55/300x300"
},
"cat-5.png": {
"u": "https://cdn.jkwljy.com/pk-math/2kSynNrNPPyZCzys49Bs9yVkqCr/200x300",
"w": 200,
"h": 300,
"ossName": "/pk-math/2kSynNrNPPyZCzys49Bs9yVkqCr/200x300"
} }
} }
...@@ -80,5 +80,25 @@ export default { ...@@ -80,5 +80,25 @@ export default {
"u": "https://cdn.jkwljy.com/pk-math/39zMBKhthpUN8JGaLtJ5e1qmnewc/750x960", "u": "https://cdn.jkwljy.com/pk-math/39zMBKhthpUN8JGaLtJ5e1qmnewc/750x960",
"w": 750, "w": 750,
"h": 960 "h": 960
},
"arror-bottom-left.png": {
"u": "https://cdn.jkwljy.com/pk-math/21nmtfooeLeoKtMNsHqa2AMinWSi/128x128",
"w": 128,
"h": 128
},
"arrow-top-left.png": {
"u": "https://cdn.jkwljy.com/pk-math/3VAxvzEMBNyVZMuwf8hRTWDvgtnC/128x128",
"w": 128,
"h": 128
},
"cat-4.png": {
"u": "https://cdn.jkwljy.com/pk-math/3tYeViwvJo7vFGEUsNhaCSfx8G55/300x300",
"w": 300,
"h": 300
},
"cat-5.png": {
"u": "https://cdn.jkwljy.com/pk-math/2kSynNrNPPyZCzys49Bs9yVkqCr/200x300",
"w": 200,
"h": 300
} }
} as const } as const
...@@ -63,8 +63,13 @@ ...@@ -63,8 +63,13 @@
} }
.performance { .performance {
width: 50%;
animation: fadeInLeft 1s ease-in-out forwards; animation: fadeInLeft 1s ease-in-out forwards;
width: 50%;
.performanceInner {
margin: 0 24PX;
padding: 12PX 0;
}
.details { .details {
@include flexLayout(row, center, center); @include flexLayout(row, center, center);
...@@ -161,73 +166,73 @@ ...@@ -161,73 +166,73 @@
} }
} }
.details { }
@include flexLayout(column); }
gap: 12PX;
// animation: fadeInLeft 1s ease-in-out forwards;
.detail {
animation: fadeInScale 1s ease-in backwards;
@include flexLayout(row, center, space-between);
background: rgba(226,233,255,0.3);
border-radius: 12PX;
color: #fff;
&:nth-child(1) { .againDetails {
animation-delay: 0.3s; @include flexLayout(column);
} gap: 12PX;
// animation: fadeInLeft 1s ease-in-out forwards;
&:nth-child(2) {
animation-delay: 0.6s;
}
&:nth-child(3) {
animation-delay: 0.9s;
}
.content {
@include flexLayout(row, center);
.badge { .againDetail {
width: 84px; // animation: fadeInScale 1s ease-in backwards;
height: 84px; @include flexLayout(row, center, space-between);
margin-right: 32px; background: rgba(226,233,255,0.3);
} border-radius: 12PX;
color: #fff;
.center {
@include flexLayout(row, center); &:nth-child(1) {
gap: 4PX; animation-delay: 0.3s;
font-size: 12PX; }
}
} &:nth-child(2) {
animation-delay: 0.6s;
.icon { }
width: 22PX;
height: 22PX; &:nth-child(3) {
} animation-delay: 0.9s;
}
.score {
margin-right: 32px; .content {
@include flexLayout(row, center); @include flexLayout(row, center);
.icon { .badge {
position: relative; width: 84px;
right: -10PX; height: 84px;
} margin-right: 32px;
}
.text {
background: #0084FF; .center {
border-radius: 14px; @include flexLayout(row, center);
font-size: 10PX; gap: 4PX;
width: 72px; font-size: 12PX;
padding: 1PX 6PX; }
} }
}
.icon {
width: 22PX;
height: 22PX;
}
.score {
margin-right: 32px;
@include flexLayout(row, center);
.icon {
position: relative;
right: -10PX;
}
.text {
background: #0084FF;
border-radius: 14px;
font-size: 10PX;
width: 72px;
padding: 1PX 6PX;
} }
} }
} }
} }
@keyframes fadeInRight { @keyframes fadeInRight {
0% { 0% {
opacity: 0; opacity: 0;
......
...@@ -4,7 +4,9 @@ import classNames from 'classnames' ...@@ -4,7 +4,9 @@ import classNames from 'classnames'
import { useStoreState } from '@/store/hooks' import { useStoreState } from '@/store/hooks'
import { StageLevel, StageGear } from '@/api' import { StageLevel, StageGear } from '@/api'
import assets from '@/assets/oss/assets-prepare' import assets from '@/assets/oss/assets-prepare'
import GuideFirstScene from '../guide/first/scene-1'
import GuideCompleteScene from '../guide/complete/scene-1'
import GuideCompleteScene2 from '../guide/complete/scene-2'
import styles from './main-header.module.scss' import styles from './main-header.module.scss'
import { formatNextStep, formatLevelAchieve, formatTopAchieve, formatType } from '../format' import { formatNextStep, formatLevelAchieve, formatTopAchieve, formatType } from '../format'
...@@ -23,7 +25,7 @@ const MainHeader = () => { ...@@ -23,7 +25,7 @@ const MainHeader = () => {
return null return null
} }
return ( return (
<View key={u} className={styles.detail}> <View key={u} className={styles.againDetail}>
<View className={styles.content}> <View className={styles.content}>
<Image className={styles.badge} src={u} mode="widthFix" /> <Image className={styles.badge} src={u} mode="widthFix" />
<View className={styles.center}> <View className={styles.center}>
...@@ -46,17 +48,17 @@ const MainHeader = () => { ...@@ -46,17 +48,17 @@ const MainHeader = () => {
const renderFirst = useCallback(() => stageDetail === null const renderFirst = useCallback(() => stageDetail === null
? null ? null
: ( : (
<View className={styles.details}> <GuideFirstScene>
{renderItem({ u: assets['level-big-s.png'].u, v: setting.sPoint!, t: stageDetail.sTime })} {renderItem({ u: assets['level-big-s.png'].u, v: setting.sPoint!, t: stageDetail.sTime })}
{renderItem({ u: assets['level-big-a.png'].u, v: setting.aPoint!, t: stageDetail.aTime })} {renderItem({ u: assets['level-big-a.png'].u, v: setting.aPoint!, t: stageDetail.aTime })}
{renderItem({ u: assets['level-big-b.png'].u, v: setting.bPoint!, t: stageDetail.bTime })} {renderItem({ u: assets['level-big-b.png'].u, v: setting.bPoint!, t: stageDetail.bTime })}
</View> </GuideFirstScene>
), [stageDetail, stageDetail?.sTime, stageDetail?.aTime, stageDetail?.bTime]) ), [stageDetail, stageDetail?.sTime, stageDetail?.aTime, stageDetail?.bTime])
const renderAgain = useCallback(() => ( const renderAgain = useCallback(() => (
<View className={styles.details}> <View className={styles.againDetails}>
{stageDetail?.nextSteps?.map((item, index) => ( {stageDetail?.nextSteps?.map((item, index) => (
<View key={index} className={styles.detail}> <GuideCompleteScene2 index={index + 2}>
<View className={styles.content}> <View className={styles.content}>
<Image className={styles.badge} style={{ marginRight: 10 }} src={formatNextStep(item).u} mode="widthFix" /> <Image className={styles.badge} style={{ marginRight: 10 }} src={formatNextStep(item).u} mode="widthFix" />
<View className={styles.center}> <View className={styles.center}>
...@@ -72,9 +74,9 @@ const MainHeader = () => { ...@@ -72,9 +74,9 @@ const MainHeader = () => {
<Image className={styles.icon} src={assets['diamond.png'].u} mode="widthFix" /> <Image className={styles.icon} src={assets['diamond.png'].u} mode="widthFix" />
<Text className={styles.text}>+{item.nextStepReward}</Text> <Text className={styles.text}>+{item.nextStepReward}</Text>
</View> </View>
</View> </GuideCompleteScene2>
))} ))}
</View> </View>
), [stageDetail?.nextSteps]) ), [stageDetail?.nextSteps])
if (!stageDetail) { if (!stageDetail) {
...@@ -108,12 +110,15 @@ const MainHeader = () => { ...@@ -108,12 +110,15 @@ const MainHeader = () => {
{(stageDetail.firstTime || !stageDetail.level) {(stageDetail.firstTime || !stageDetail.level)
? null ? null
: <View className={styles.replay}> : <View className={styles.replay}>
<View className={styles.performance}> <View className={styles.performance}>
<Text>当前档位</Text> <GuideCompleteScene>
<View className={styles.details}> <Text>当前档位</Text>
<Text className={styles.consume}>排名<Text style={{ color: '#FEB645' }}>前{stageDetail.gear || 0}%</Text></Text> <View className={styles.details}>
<Text className={styles.consume}>排名<Text style={{ color: '#FEB645' }}>前{stageDetail.gear || 0}%</Text></Text>
</View>
</GuideCompleteScene>
</View> </View>
</View>
<View className={styles.achievement}> <View className={styles.achievement}>
<Text className={styles.text}>勋章成就</Text> <Text className={styles.text}>勋章成就</Text>
{/* 以后优化 */} {/* 以后优化 */}
......
...@@ -2,6 +2,7 @@ import { View, Image, Text } from '@tarojs/components' ...@@ -2,6 +2,7 @@ import { View, Image, Text } from '@tarojs/components'
import { useMemo } from 'react' import { useMemo } from 'react'
import { navigateTo, getMenuButtonBoundingClientRect, navigateBack, getSystemInfoSync } from '@tarojs/taro' import { navigateTo, getMenuButtonBoundingClientRect, navigateBack, getSystemInfoSync } from '@tarojs/taro'
import { useStoreState } from '@/store/hooks' import { useStoreState } from '@/store/hooks'
import Scene3 from '../guide/complete/scene-3'
import styles from './top-bar.module.scss' import styles from './top-bar.module.scss'
...@@ -36,10 +37,10 @@ export default () => { ...@@ -36,10 +37,10 @@ export default () => {
<Image className={styles.back_icon} src={require('../assets/back.png')} mode="widthFix" onClick={() => navigateBack()} /> <Image className={styles.back_icon} src={require('../assets/back.png')} mode="widthFix" onClick={() => navigateBack()} />
<View style={rightStyle} className={styles.left}></View> <View style={rightStyle} className={styles.left}></View>
<View className={styles.main}> <View className={styles.main}>
<View className={styles.score} onClick={goStore}> <Scene3 onClickConent={goStore}>
<Image src={require('@/pages/main/assets/score.png')} className={styles.icon} /> <Image src={require('@/pages/main/assets/score.png')} className={styles.icon} />
<Text>{point}</Text> <Text>{point}</Text>
</View> </Scene3>
<View className={styles.ph} onClick={goStore}> <View className={styles.ph} onClick={goStore}>
<Image src={require('@/pages/main/assets/ph.png')} className={styles.icon} /> <Image src={require('@/pages/main/assets/ph.png')} className={styles.icon} />
<Text>{cardNum}</Text> <Text>{cardNum}</Text>
......
.wrapper {
border-radius: 32px;
margin-left: 50px;
}
.guide {
position: absolute;
margin-top: 80px;
left: -100px;
display: flex;
align-items: center;
}
.guideCat {
position: relative;
z-index: 10;
width: 268px;
height: 300px;
}
.guideMain {
position: relative;
left: -40px;
top: 36px;
z-index: 1;
width: 510px;
background: url('https://cdn.jkwljy.com/pk-math/mFR86xsmGbKnCC9yu5ak2yadejB/510x272') no-repeat;
background-size: 100% 100%;
> .inner {
padding: 12PX 10PX 0 20PX;
line-height: 1.6;
color: #465164;
font-size: 14PX;
.strong {
color: #FEB645;
}
> .continue {
margin-top: 4PX;
justify-content: flex-end;
color: #1786F7;
margin-bottom: 12PX;
display: flex;
align-items: center;
gap: 2PX;
}
}
}
.bordered {
border-radius: 32px;
padding: 8PX;
border: 2PX dashed #FFFFFF;
}
\ No newline at end of file
import { View, Image, Text } from '@tarojs/components'
import { useEffect, useMemo } from 'react'
import UserGuideView from '@/components/UserGuideView'
import classNames from 'classnames'
import { useStoreState, useStoreActions } from '@/store/hooks'
import tutorialAssets from '@/assets/oss/assets-tutorial'
import styles from './scene-1.module.scss'
import wrapStyles from '../../components/main-header.module.scss'
export const Scene = ({ children }: { children: React.ReactNode }) => {
const passStep = useStoreState(state => state.prepareModel.passStep)
const guideActive = useStoreState(state => state.prepareModel.guideActive)
const guideComplete = useStoreState(state => state.prepareModel.passGuideComplete)
const updateState = useStoreActions(actions => actions.prepareModel.updateState)
const stageDetail = useStoreState(state => state.gameModel.stageDetail)
const showMask = useMemo(() => {
return !guideComplete && guideActive && passStep === 1
}, [guideComplete, guideActive, passStep])
useEffect(() => {
if (!guideComplete) {
updateState({ guideActive: true })
}
}, [guideComplete, updateState])
return (
<UserGuideView
wrapClass={styles.wrapper}
className={classNames(wrapStyles.performanceInner, showMask ? styles.bordered : null)}
isActive={showMask && passStep < 3}
guideContent={(
<View className={styles.guide}>
<Image className={styles.guideCat} src={tutorialAssets['cat-4.png'].u} />
<View className={styles.guideMain}>
<View className={styles.inner} onClick={() => updateState({ passStep: passStep + 1 })}>
<Text>
哇,你通关了,表现不错哦;你的熟练度,
<Text className={styles.strong}>打败了{stageDetail?.gear || 0}%的同学</Text>
,当然相信你还可以变得更好!
</Text>
<View className={styles.continue}>
<Image style={{ width: 14, height: 14 }} src={tutorialAssets['continue-arrow.png'].u} /></View>
</View>
</View>
</View>
)}
>
{children}
</UserGuideView>
)
}
export default Scene
.wrapperScene {
border-radius: 20px;
}
.bordered {
border-radius: 32px;
// padding: 8PX;
border: 2PX dashed #FFFFFF;
}
.guide {
position: absolute;
margin-top: 80px;
left: -20px;
display: flex;
align-items: center;
}
.guideCat {
width: 200px;
height: 300px;
}
.guideMain {
position: relative;
top: 10px;
flex: 1;
z-index: 1;
background: url('https://cdn.jkwljy.com/pk-math/mFR86xsmGbKnCC9yu5ak2yadejB/510x272') no-repeat;
background-size: 100% 100%;
> .inner {
padding: 12PX 10PX 0 20PX;
line-height: 1.6;
color: #465164;
font-size: 14PX;
.strong {
color: #FEB645;
}
> .continue {
margin-top: 4PX;
justify-content: flex-end;
color: #1786F7;
margin-bottom: 12PX;
display: flex;
align-items: center;
gap: 2PX;
}
}
}
\ No newline at end of file
import { View, Image, Text } from '@tarojs/components'
import { useCallback, useEffect, useMemo } from 'react'
import { pageScrollTo } from '@tarojs/taro'
import tutorialAssets from '@/assets/oss/assets-tutorial'
import UserGuideView from '@/components/UserGuideView'
import classNames from 'classnames'
import { useStoreState, useStoreActions } from '@/store/hooks'
import styles from './scene-2.module.scss'
import wrapStyles from '../../components/main-header.module.scss'
const useStepDetails = (stageDetail, targetSteps) => {
return useMemo(() => {
const details = targetSteps.reduce((result, targetStep) => {
const detail = stageDetail?.nextSteps?.find(
step => step.nextStep === targetStep
)
const index = stageDetail?.nextSteps?.findIndex(
step => step.nextStep === targetStep
)
if (detail !== undefined && index !== -1) {
if (['S', 'A', 'B'].includes(targetStep)) {
result.level = { detail, index }
} else if (['10', '20', '30'].includes(targetStep)) {
result.gear = { detail, index }
} else if (targetStep === 'upGear') {
result.upGear = { detail, index }
}
}
return result
}, {})
return details
}, [stageDetail?.nextSteps, targetSteps])
}
const MessageRenderer = ({ step, level, gear, upGear }) => {
const renderMessage = useCallback(() => {
const detailIndexMap = { level, gear, upGear }
const targetStep = Object.keys(detailIndexMap).find(
key => detailIndexMap[key]?.index + 2 === step
)
if (!targetStep) {
return null
}
const { detail } = detailIndexMap[targetStep]
const textTemplate = {
upGear: (
<>
你只要
<Text className={styles.strong}>再快{detail.nextStepTime}秒</Text>
,就可以领先更多同学,提升你的档位,
<Text className={styles.strong}>
获得【升档】勋章和{detail.nextStepReward}水晶奖励
</Text>
,粗心大意可是通不了关的哦。
</>
),
gear: (
<>
如果你更加熟练,
<Text className={styles.strong}>再快{detail.nextStepTime}秒</Text>
,就说明你到这个技能的顶尖水平了,并
<Text className={styles.strong}>
获得象征荣耀的【TOP】(前30%、20%、10%)勋章和水晶奖励
</Text>
。
</>
),
level: (
<>
只要你
<Text className={styles.strong}>再提高{detail.nextStepTime}秒</Text>,
就可以达到
<Text className={styles.strong}>【{detail.nextStep}级水准】</Text>,了哦,并
<Text className={styles.strong}>获得{detail.nextStepReward}水晶奖励</Text>
。
</>
),
}
return <Text>{textTemplate[targetStep]}</Text>
}, [upGear, gear, level, step])
return renderMessage()
}
export const Scene = ({ children, index }: { index: number, children: React.ReactNode }) => {
const step = useStoreState(state => state.prepareModel.passStep)
const guideActive = useStoreState(state => state.prepareModel.guideActive)
const guideComplete = useStoreState(state => state.prepareModel.passGuideComplete)
const updateState = useStoreActions(actions => actions.prepareModel.updateState)
const stageDetail = useStoreState(state => state.gameModel.stageDetail)
const { level, gear, upGear } = useStepDetails(stageDetail, ['S', 'A', 'B', '10', '20', '30', 'upGear'])
const scrollToBottom = useCallback((scrollTop?: number) => {
pageScrollTo({
duration: 600,
selector: '#guideScrollView',
scrollTop: scrollTop ?? 60,
})
}, [])
const showMask = useMemo(() => {
return !guideComplete && guideActive && step === index
}, [guideComplete, guideActive, step, index])
useEffect(() => {
if (!guideComplete) {
updateState({ guideActive: true })
}
}, [guideComplete, updateState])
const onClick = () => {
const stepDetails = { level, gear, upGear }
const activeSteps = Object.values(stepDetails).filter(item => item)
const activeStepIndex = activeSteps.length
if (step === activeStepIndex + 1) {
if (activeStepIndex >= 2) {
scrollToBottom(0)
setTimeout(() => {
updateState({ passStep: -1 })
}, 666)
} else {
updateState({ passStep: -1 })
}
} else {
scrollToBottom()
updateState({ passStep: step + 1 })
}
}
return (
<View id="guideScrollView">
<UserGuideView
horizonPadding={0}
verticalPadding={0}
wrapClass={styles.wrapperScene}
className={classNames(wrapStyles.againDetail, showMask ? styles.bordered : null)}
isActive={showMask}
guideContent={(
<View className={styles.guide}>
<Image className={styles.guideCat} src={tutorialAssets['cat.png'].u} />
<View className={styles.guideMain}>
<View className={styles.inner} onClick={onClick}>
<MessageRenderer step={step} level={level} gear={gear} upGear={upGear} />
<View className={styles.continue}>
<Text>继续</Text>
<Image style={{ width: 14, height: 14 }} src={tutorialAssets['continue-arrow.png'].u} /></View>
</View>
</View>
</View>
)}
>
{children}
</UserGuideView>
</View>
)
}
export default Scene
.wrap {
border-radius: 12px;
.guide {
position: absolute;
margin-top: 80px;
left: calc(-100% - 28px);
display: flex;
}
.guideCat {
width: 180px;
height: 300px;
}
.guideMain {
flex: 1;
color: white;
font-size: 18PX;
position: relative;
top: -100px;
left: 20px;
@keyframes arrowAnimation {
0% {
transform: translate(0, 0) rotate(0);
}
50% {
transform: translate(16px, 16px) rotate(0);
}
100% {
transform: translate(0, 0) rotate(0);
}
}
.tutorialArrow {
width: 128px;
height: 128px;
margin-right: 30px;
position: relative;
left: 130px;
animation: arrowAnimation 1.6s linear infinite;
}
.text {
width: 400px;
line-height: 1.6;
margin: 40px 0 0 40px;
}
}
}
.bordered {
border-radius: 20px;
padding: 2PX 14PX;
border: 2PX dashed #FFFFFF;
}
\ No newline at end of file
import { View, Image } from '@tarojs/components'
import { useMemo } from 'react'
import UserGuideView from '@/components/UserGuideView'
import classNames from 'classnames'
import { useStoreState, useStoreActions } from '@/store/hooks'
import tutorialAssets from '@/assets/oss/assets-tutorial'
import styles from './scene-3.module.scss'
import wrapStyles from '../../components/top-bar.module.scss'
export const Scene = ({ children, onClickConent }: { onClickConent: () => void, children: React.ReactNode }) => {
const step = useStoreState(state => state.prepareModel.passStep)
const guideActive = useStoreState(state => state.prepareModel.guideActive)
const guideComplete = useStoreState(state => state.prepareModel.passGuideComplete)
const completePassGuide = useStoreActions(actions => actions.prepareModel.completePassGuide)
const showMask = useMemo(() => {
return !guideComplete && guideActive && step === -1
}, [guideComplete, guideActive, step])
const handleCompleteGuide = async () => {
await completePassGuide()
onClickConent()
}
return (
<UserGuideView
wrapClass={styles.wrap}
className={classNames(wrapStyles.score, showMask ? styles.bordered : null)}
isActive={showMask}
onClickConent={handleCompleteGuide}
guideContent={(
<View className={styles.guide}>
<Image className={styles.guideCat} src={tutorialAssets['cat-3.png'].u} />
<View className={styles.guideMain}>
<View className={styles.tutorialFailInner}>
<Image src={tutorialAssets['arrow-top-left.png'].u} className={styles.tutorialArrow} />
<View className={styles.text}>对了,水晶有什么用呢?我来介绍一下。</View>
</View>
</View>
</View>
)}
>
{children}
</UserGuideView>
)
}
export default Scene
.wrapper {
border-radius: 32px;
}
.bordered {
border-radius: 32px;
padding: 8PX;
border: 2PX dashed #FFFFFF;
}
.top {
position: absolute;
top: 0px;
left: 0;
right: 0;
transform: translateY(calc(-100% + 20px));
display: flex;
align-items: center;
.content {
position: absolute;
left: 100PX;
flex: 1;
bottom: 20PX;
background: url('https://cdn.jkwljy.com/pk-math/mFR86xsmGbKnCC9yu5ak2yadejB/510x272') no-repeat;
background-size: 100% 100%;
.inner {
padding: 12PX 10PX 0 20PX;
line-height: 1.6;
color: #465164;
font-size: 14PX;
.strong {
color: #FEB645;
}
.continue {
margin-top: 4PX;
justify-content: flex-end;
color: #1786F7;
margin-bottom: 12PX;
display: flex;
align-items: center;
gap: 2PX;
}
}
}
}
\ No newline at end of file
import { View, Image, Text } from '@tarojs/components'
import UserGuideView from '@/components/UserGuideView'
import { useEffect, useMemo } from 'react'
import classNames from 'classnames'
import { useStoreState, useStoreActions } from '@/store/hooks'
import tutorialAssets from '@/assets/oss/assets-tutorial'
import styles from './scene-1.module.scss'
import wrapStyles from '../../components/main-header.module.scss'
const renderMessage = (step: number) => {
switch (step) {
case 1:
return (
<Text>
速度代表了你的
<Text className={styles.strong}>熟练度</Text>
,能达到【S级】的水准,才能在考试中游刃有余。
</Text>
)
case 2:
return (
<Text>
想通关,首先要
<Text className={styles.strong}>考验你的准确性</Text>
,粗心大意可是通不了关的哦。
</Text>
)
}
}
export const Scene = ({ children }: { children: React.ReactNode }) => {
const step = useStoreState(state => state.prepareModel.step)
const guideActive = useStoreState(state => state.prepareModel.guideActive)
const guideComplete = useStoreState(state => state.prepareModel.guideComplete)
const updateState = useStoreActions(actions => actions.prepareModel.updateState)
const showMask = useMemo(() => {
return !guideComplete && guideActive && step < 3
}, [guideComplete, guideActive, step])
useEffect(() => {
if (!guideComplete) {
updateState({ guideActive: true })
}
}, [guideComplete, updateState])
return (
<UserGuideView
wrapClass={styles.wrapper}
className={classNames(wrapStyles.againDetails, showMask ? styles.bordered : null)}
isActive={showMask}
guideContent={(
<View className={styles.top}>
<Image style={{ width: 100, height: 110 }} src={tutorialAssets['cat-2.png'].u} />
<View className={styles.content}>
<View
className={styles.inner}
onClick={() => updateState({
step: step + 1
})
}
>
{renderMessage(step)}
<View className={styles.continue}>
<Text>继续</Text>
<Image style={{ width: 14, height: 14 }} src={tutorialAssets['continue-arrow.png'].u} /></View>
</View>
</View>
</View>
)}
>
{children}
</UserGuideView>
)
}
export default Scene
...@@ -282,3 +282,91 @@ ...@@ -282,3 +282,91 @@
background-image: url('./assets/btn-disabled.png'); background-image: url('./assets/btn-disabled.png');
color: #C2C8D1; color: #C2C8D1;
} }
.mask {
position: fixed;
left: 0;
right: 0;
top: 0;
bottom: 0;
z-index: 9999997;
}
.mask {
position: fixed;
left: 0;
right: 0;
top: 0;
bottom: 0;
z-index: 9999997;
background: transparent;
}
.maskWrap {
position: absolute;
z-index: 9999998;
opacity: 1;
border-radius: 100%;
box-shadow: rgba(0,0,0, .6) 0px 0px 0px 5000PX;
}
.tutorial {
z-index: 9999999;
right: 140px;
position: absolute;
top: -190px;
font-size: 18PX;
font-weight: 600;
color: #fff;
display: flex;
flex-direction: column;
@keyframes arrowAnimation {
0% {
transform: translate(0, 0) rotate(0);
}
50% {
transform: translate(-16px, 16px) rotate(0);
}
100% {
transform: translate(0, 0) rotate(0);
}
}
&_arrow {
margin-top: 18px;
margin-left: 50px;
width: 128px;
height: 128px;
animation: arrowAnimation 1.6s linear infinite;
}
}
.tutorialFail {
top: -180PX;
display: flex;
left: 10PX;
right: 10PX;
flex-direction: row;
.tutorialFailInner {
flex: 1;
margin-left: 12PX;
display: flex;
align-items: center;
line-height: 1.6;
}
.failGuideCat {
width: 200px;
height: 300px;
}
.tutorial_arrow {
left: 50%;
bottom: -30PX;
transform: translateX(-50%);
position: absolute;
}
}
...@@ -8,12 +8,14 @@ import Loading from '@/components/Loading' ...@@ -8,12 +8,14 @@ import Loading from '@/components/Loading'
import ShareView from '@/pages/group/components/share-view' import ShareView from '@/pages/group/components/share-view'
import { useStoreState, useStoreActions } from '@/store/hooks' import { useStoreState, useStoreActions } from '@/store/hooks'
import { useBoolean, useRequest, useShare } from '@/hooks' import { useBoolean, useRequest, useShare } from '@/hooks'
import { pointToCard } from '@/api/account' import { pointToCard } from '@/api/account'
import assets from '@/assets/oss/assets-prepare' import assets from '@/assets/oss/assets-prepare'
import assetsGroup from '@/assets/oss/assets-group' import assetsGroup from '@/assets/oss/assets-group'
import { palyAudio } from '@/utils/play-audio' import { palyAudio } from '@/utils/play-audio'
import audio from '@/assets/oss/assets-audio' import audio from '@/assets/oss/assets-audio'
import { EyeProtectionView } from '@/components' import { EyeProtectionView } from '@/components'
import tutorialAssets from '@/assets/oss/assets-tutorial'
import Tabs, { type TabItem } from './components/tabs' import Tabs, { type TabItem } from './components/tabs'
import TopBar from './components/top-bar' import TopBar from './components/top-bar'
...@@ -35,6 +37,7 @@ const Prepare = () => { ...@@ -35,6 +37,7 @@ const Prepare = () => {
const cardNum = useStoreState(state => state.userModel.cardNum) const cardNum = useStoreState(state => state.userModel.cardNum)
const point = useStoreState(state => state.userModel.point) const point = useStoreState(state => state.userModel.point)
const userInfo = useStoreState(state => state.userModel.userInfo) const userInfo = useStoreState(state => state.userModel.userInfo)
// const isSubmit = true
const isSubmit = useStoreState(state => state.gameModel.isSubmit) const isSubmit = useStoreState(state => state.gameModel.isSubmit)
const tribeInfo = useStoreState(state => state.groupModel.tribeInfo) const tribeInfo = useStoreState(state => state.groupModel.tribeInfo)
const stageList = useStoreState(state => state.mainModel.stageList) const stageList = useStoreState(state => state.mainModel.stageList)
...@@ -99,14 +102,24 @@ const Prepare = () => { ...@@ -99,14 +102,24 @@ const Prepare = () => {
}) })
} }
}) })
const guideComplete = useStoreState(state => state.prepareModel.guideComplete)
const completeGuide = useStoreActions(actions => actions.prepareModel.completeGuide)
const completeFailGuide = useStoreActions(actions => actions.prepareModel.completeFailGuide)
const handleClick = async () => {
/** 首次闯关引导完成 */
!guideComplete && await completeGuide()
/** 首次闯关失败引导完成 */
isSubmit && !failGuideComplete && await completeFailGuide()
const handleClick = () => {
if (cardNum < 1 && !stageDetail?.firstTime) { if (cardNum < 1 && !stageDetail?.firstTime) {
setTrue() setTrue()
} else { } else {
if (isClickRef.current) return if (isClickRef.current) return
isClickRef.current = true isClickRef.current = true
palyAudio(audio['蹦蹦top出现首页.wav'].u) palyAudio(audio['蹦蹦top出现首页.wav'].u)
getQuestionList(+router.params.id || 1).then(() => { getQuestionList(+router.params.id || 1).then(() => {
isClickRef.current = false isClickRef.current = false
navigateTo({ navigateTo({
...@@ -116,18 +129,34 @@ const Prepare = () => { ...@@ -116,18 +129,34 @@ const Prepare = () => {
} }
} }
const step = useStoreState(state => state.prepareModel.step)
const guideActive = useStoreState(state => state.prepareModel.guideActive)
const updateGuideState = useStoreActions(actions => actions.prepareModel.updateState)
/** 显示首次闯关引导开始闯关按钮 */
const showMask = useMemo(() => {
return step === 3 && guideActive && !guideComplete
}, [step, guideActive, guideComplete])
const renderFisrtActions = () => ( const renderFisrtActions = () => (
<View className={styles.challenge}> <View>
<Button size="large" onClick={handleClick} image={styles.image} hoverImage={styles.hover_image}> {showMask && <View className={styles.mask}></View>}
<Text className={styles.challenge_text}>开始闯关</Text> {showMask && <View className={styles.tutorial}>
<View className={styles.card} style={{ position: 'absolute', right: 60 }}> <Text>让我们开始试试吧!</Text>
<Image className={styles.card_icon} src={require('@/pages/main/assets/ph.png')} /> <Image src={tutorialAssets['arror-bottom-left.png'].u} className={styles.tutorial_arrow}></Image>
{!stageDetail?.firstTime && <Text className={styles.card_text}>-1</Text>} </View>}
</View> <View className={classNames(styles.challenge, showMask ? styles.maskWrap : null)}>
{stageDetail?.firstTime && <View className={styles.tip}> <Button size="large" onClick={handleClick} image={styles.image} hoverImage={styles.hover_image}>
<Text className={styles.tip_text}>首次免答题卡</Text> <Text className={styles.challenge_text}>开始闯关</Text>
</View>} <View className={styles.card} style={{ position: 'absolute', right: 60 }}>
</Button> <Image className={styles.card_icon} src={require('@/pages/main/assets/ph.png')} />
{!stageDetail?.firstTime && <Text className={styles.card_text}>-1</Text>}
</View>
{stageDetail?.firstTime && <View className={styles.tip}>
<Text className={styles.tip_text}>首次免答题卡</Text>
</View>}
</Button>
</View>
</View> </View>
) )
...@@ -148,25 +177,51 @@ const Prepare = () => { ...@@ -148,25 +177,51 @@ const Prepare = () => {
return stageDetail?.level && isSubmit && !isLast return stageDetail?.level && isSubmit && !isLast
}, [stageDetail, isSubmit, isLast]) }, [stageDetail, isSubmit, isLast])
const failGuideComplete = useStoreState(state => state.prepareModel.failGuideComplete)
useEffect(() => {
// 首次失败引导
if (!failGuideComplete && isSubmit && !stageDetail?.level && !stageDetail?.firstTime) {
updateGuideState({
guideActive: true
})
}
}, [isSubmit, failGuideComplete, stageDetail?.level, stageDetail?.firstTime, updateGuideState])
const showFailMask = useMemo(() => {
return guideActive && !failGuideComplete && isSubmit && !hasNextBtn
}, [guideActive, failGuideComplete, hasNextBtn, isSubmit])
const renderAgainActions = () => ( const renderAgainActions = () => (
<View className={styles.challenge}> <View>
{hasNextBtn && ( {showFailMask && <View className={styles.mask}></View>}
<Button onClick={onNext} size="large" image={styles.short_image} hoverImage={styles.short_hover_image}> {showFailMask && <View className={classNames(styles.tutorial, styles.tutorialFail)}>
下一关 <Image className={styles.failGuideCat} src={tutorialAssets['cat-5.png'].u} />
</Button> <View className={styles.tutorialFailInner}>
)} <Text>嗯,说明这个技能还需要提高哦。我们再来一次吧!</Text>
<Button <Image src={tutorialAssets['arror-bottom-left.png'].u} className={styles.tutorial_arrow}></Image>
size="large"
onClick={handleClick}
image={classNames(!hasNextBtn ? styles.image : styles.long_image)}
hoverImage={classNames(!hasNextBtn ? styles.hover_image : styles.long_hover_image)}
>
<View className={styles.card} style={{ marginRight: 12 }}>
<Image className={styles.card_icon} src={require('@/pages/main/assets/ph.png')} />
<Text className={styles.card_text}>-1</Text>
</View> </View>
<Text className={styles.challenge_text}>再次提升</Text> </View>}
</Button>
<View className={classNames(styles.challenge, showFailMask ? styles.maskWrap : null)}>
{hasNextBtn && (
<Button onClick={onNext} size="large" image={styles.short_image} hoverImage={styles.short_hover_image}>
下一关
</Button>
)}
<Button
size="large"
onClick={handleClick}
image={classNames(!hasNextBtn ? styles.image : styles.long_image)}
hoverImage={classNames(!hasNextBtn ? styles.hover_image : styles.long_hover_image)}
>
<View className={styles.card} style={{ marginRight: 12 }}>
<Image className={styles.card_icon} src={require('@/pages/main/assets/ph.png')} />
<Text className={styles.card_text}>-1</Text>
</View>
<Text className={styles.challenge_text}>再次提升</Text>
</Button>
</View>
</View> </View>
) )
......
import { Action, action, Thunk, thunk, State } from 'easy-peasy'
import { getStorage, StorageKeys, updateStorage } from '@/utils/storage'
export interface PrepareModel {
/** 首次闯关引导step */
step: number;
/** 首次通关关引导step */
passStep: number;
/** 是否显示引导 */
guideActive: boolean;
/** 首次闯关引导 */
guideComplete: boolean | null;
/** 首次闯关失败引导 */
failGuideComplete: boolean | null;
/** 首次通关引导 */
passGuideComplete: boolean | null;
updateState: Action<PrepareModel, Partial<State<PrepareModel>>>;
completeGuide: Thunk<PrepareModel>;
completeFailGuide: Thunk<PrepareModel>;
completePassGuide: Thunk<PrepareModel>;
}
const prepareModel: PrepareModel = {
step: 1,
passStep: 1,
guideActive: false,
guideComplete: getStorage(StorageKeys.prepareGuideComplete),
failGuideComplete: getStorage(StorageKeys.prepareFailGuideComplete),
passGuideComplete: getStorage(StorageKeys.preparePassGuideComplete),
updateState: action((state, payload) => {
for (const k in payload) {
state[k] = payload[k]
}
}),
completeGuide: thunk(async (actions) => {
actions.updateState({
guideComplete: true,
guideActive: false,
})
updateStorage(StorageKeys.prepareGuideComplete, true)
}),
completeFailGuide: thunk(async (actions) => {
actions.updateState({
failGuideComplete: true,
guideActive: false,
})
updateStorage(StorageKeys.prepareFailGuideComplete, true)
}),
completePassGuide: thunk(async (actions) => {
actions.updateState({
passGuideComplete: true,
guideActive: false,
})
updateStorage(StorageKeys.preparePassGuideComplete, true)
}),
}
export default prepareModel
import { View, Text, Image } from '@tarojs/components' import { View, Text, Image } from '@tarojs/components'
import { switchTab } from '@tarojs/taro' import { switchTab } from '@tarojs/taro'
import classNames from 'classnames' import classNames from 'classnames'
import { type StageRank } from '@/api/game' import { NextStep, type StageRank } from '@/api/game'
import assets from '@/assets/oss/assets-prepare' import assets from '@/assets/oss/assets-prepare'
import assetsGroup from '@/assets/oss/assets-group' import assetsGroup from '@/assets/oss/assets-group'
import Thead from './components/thead' import Thead from './components/thead'
import styles from './index.module.scss' import styles from './index.module.scss'
import { formatNextStep } from './format'
export const renderList = (list: StageRank[]) => { export const renderList = (list: StageRank[]) => {
const isEmpty = list.length < 1 const isEmpty = list.length < 1
......
import { computed, Action, Computed, action } from 'easy-peasy'
import WithPaging from '@/utils/with-paging'
import { PagingFn } from '@/types'
import { User } from '@/pages/prepare/types'
interface Model {
// setTitle: Action<PrepareModel, string>;
// setTotalQuestions: Action<PrepareModel, number>;
// setPassingRequirement: Action<PrepareModel, string>;
// setDuration: Action<PrepareModel, number>;
currentUser: User;
setCurrentUser: Action<PrepareModel, User>;
topThreeUsers: Computed<PrepareModel, User[]>;
currentUserInTopThree: Computed<PrepareModel, boolean>;
}
const api: PagingFn<any, {}> = async () => {
return {
code: 0,
sysTime: Date.now(),
data: {
list: [
{
nickname: 'index1',
schoolName: 'index1',
avatar: 'index1',
time: 10,
},
{
nickname: 'index2',
schoolName: 'index2',
avatar: 'index1',
time: 20,
},
{
nickname: 'index3',
schoolName: 'index3',
avatar: 'index1',
time: 30,
},
{
nickname: 'index4',
schoolName: 'index4',
avatar: 'index4',
time: 110,
},
{
nickname: 'index5',
schoolName: 'index5',
avatar: 'index1',
time: 30,
},
{
nickname: 'index6',
schoolName: 'inex6',
avatar: 'index6',
time: 110,
},
],
total: 400,
hasNextPage: true
}
}
}
const prepareModel = WithPaging<User, Model, {}>(api)({
currentUser: {
nickname: 'index4',
schoolName: 'index4',
avatar: 'index4',
time: 30,
},
// panelCard: {
// title: '表内除法',
// totalQuestions: 10,
// passingRequirement: '全√',
// duration: 80,
// },
topThreeUsers: computed((state) => state.list.slice(0, 3)),
currentUserInTopThree: computed(
(state) => state.topThreeUsers.some(
(user) => user.nickname === state.currentUser.nickname
),
),
setCurrentUser: action((state, user) => {
state.currentUser = user
}),
// setTitle: action((state, payload) => {
// state.levelInfo.title = payload;
// }),
// setTotalQuestions: action((state, payload) => {
// state.levelInfo.totalQuestions = payload;
// }),
// setPassingRequirement: action((state, payload) => {
// state.levelInfo.passingRequirement = payload;
// }),
// setDuration: action((state, payload) => {
// state.levelInfo.duration = payload;
// }),
})
export default prepareModel
export type PrepareModel = typeof prepareModel;
import gameModel from '@/pages/game/play/model' import gameModel from '@/pages/game/play/model'
import mainModel from '@/pages/main/model' import mainModel from '@/pages/main/model'
import groupModel from '@/pages/group/model' import groupModel from '@/pages/group/model'
import prepareModel from './modules/prepare' import prepareModel from '@/pages/prepare/model'
import userModel from './modules/user' import userModel from './modules/user'
import guideModel from './modules/guide' import guideModel from './modules/guide'
......
...@@ -10,6 +10,14 @@ export enum StorageKeys { ...@@ -10,6 +10,14 @@ export enum StorageKeys {
openid, openid,
/** 完成首页引导 */ /** 完成首页引导 */
mainGuideComplete,
/** 完成准备页首次闯关引导 */
prepareGuideComplete,
/** 完成准备页首次失败引导 */
prepareFailGuideComplete,
/** 完成准备页首次通关 引导 */
preparePassGuideComplete,
isMainGuideComplete, isMainGuideComplete,
/** 完成页查看错题引导 */ /** 完成页查看错题引导 */
isErrQuestionGuideComplete, isErrQuestionGuideComplete,
...@@ -24,6 +32,10 @@ export enum StorageKeys { ...@@ -24,6 +32,10 @@ export enum StorageKeys {
type Storage = { type Storage = {
[StorageKeys.userInfo]: UserInfo | null; [StorageKeys.userInfo]: UserInfo | null;
[StorageKeys.openid]: string | null | undefined; [StorageKeys.openid]: string | null | undefined;
[StorageKeys.mainGuideComplete]: boolean | null;
[StorageKeys.prepareGuideComplete]: boolean | null;
[StorageKeys.prepareFailGuideComplete]: boolean | null;
[StorageKeys.preparePassGuideComplete]: boolean | null;
[StorageKeys.isMainGuideComplete]: boolean | null; [StorageKeys.isMainGuideComplete]: boolean | null;
[StorageKeys.isErrQuestionGuideComplete]: boolean | null; [StorageKeys.isErrQuestionGuideComplete]: boolean | null;
[StorageKeys.isGroupGuideComplete]: boolean | null; [StorageKeys.isGroupGuideComplete]: boolean | null;
...@@ -42,6 +54,10 @@ export function reloadStore () { ...@@ -42,6 +54,10 @@ export function reloadStore () {
[ [
StorageKeys.openid, StorageKeys.openid,
StorageKeys.userInfo, StorageKeys.userInfo,
StorageKeys.mainGuideComplete,
StorageKeys.prepareGuideComplete,
StorageKeys.prepareFailGuideComplete,
StorageKeys.preparePassGuideComplete,
StorageKeys.isMainGuideComplete, StorageKeys.isMainGuideComplete,
StorageKeys.isErrQuestionGuideComplete, StorageKeys.isErrQuestionGuideComplete,
StorageKeys.isGroupGuideComplete, StorageKeys.isGroupGuideComplete,
......
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