Commit 2d023620 authored by hewenhao's avatar hewenhao

feat: 滚动完成后才显示引导

parent 70778009
...@@ -37,6 +37,7 @@ const MainPage = () => { ...@@ -37,6 +37,7 @@ const MainPage = () => {
const fetchAccount = useStoreActions(actions => actions.userModel.fetchAccount) const fetchAccount = useStoreActions(actions => actions.userModel.fetchAccount)
const updateGroupGuideActive = useStoreActions(actions => actions.guideModel.updateGroupGuideActive) const updateGroupGuideActive = useStoreActions(actions => actions.guideModel.updateGroupGuideActive)
const fetchTribeInfo = useStoreActions(actions => actions.groupModel.fetchTribeInfo) const fetchTribeInfo = useStoreActions(actions => actions.groupModel.fetchTribeInfo)
const updateGuideState = useStoreActions(actions => actions.guideModel.updateState)
const userInfo = useStoreState(state => state.userModel.userInfo) const userInfo = useStoreState(state => state.userModel.userInfo)
const showPkGuideFromHis = useStoreState(state => state.guideModel.showPkGuideFromHis) const showPkGuideFromHis = useStoreState(state => state.guideModel.showPkGuideFromHis)
...@@ -94,20 +95,22 @@ const MainPage = () => { ...@@ -94,20 +95,22 @@ const MainPage = () => {
} }
}, [player, isFocus]) }, [player, isFocus])
const scrollToLastPassed = useCallback(() => { const scrollToLastPassed = useCallback((cb: () => void) => {
const height = getSystemInfoSync().windowHeight const height = getSystemInfoSync().windowHeight
pageScrollTo({ pageScrollTo({
selector: `#${LastPassedStageId}`, selector: `#${LastPassedStageId}`,
offsetTop: -height / 2, offsetTop: -height / 2,
complete: () => {} complete: cb
}) })
}, []) }, [])
useEffect(() => { useEffect(() => {
if (showPkGuideFromHis) { if (showPkGuideFromHis) {
scrollToLastPassed() scrollToLastPassed(() => {
updateGuideState({ activePkGuideFromHis: true })
})
} }
}, [showPkGuideFromHis, scrollToLastPassed]) }, [showPkGuideFromHis, scrollToLastPassed, updateGuideState])
useEffect(() => { useEffect(() => {
if (isFocus && userInfo.city && userInfo.grade) { if (isFocus && userInfo.city && userInfo.grade) {
......
...@@ -153,6 +153,7 @@ const StageComp = (props: StageProps) => { ...@@ -153,6 +153,7 @@ const StageComp = (props: StageProps) => {
const nextPkGuide = useStoreActions(state => state.guideModel.nextPkGuide) const nextPkGuide = useStoreActions(state => state.guideModel.nextPkGuide)
const showPkGuideFromHis = useStoreState(state => state.guideModel.showPkGuideFromHis) const showPkGuideFromHis = useStoreState(state => state.guideModel.showPkGuideFromHis)
const updateGuideState = useStoreActions(state => state.guideModel.updateState) const updateGuideState = useStoreActions(state => state.guideModel.updateState)
const activePkGuideFromHis = useStoreState(state => state.guideModel.activePkGuideFromHis)
const isSpecialRound = useMemo(() => { const isSpecialRound = useMemo(() => {
return stage.type === StageType.Special return stage.type === StageType.Special
...@@ -166,9 +167,9 @@ const StageComp = (props: StageProps) => { ...@@ -166,9 +167,9 @@ const StageComp = (props: StageProps) => {
} }
if (stage.$lastPassedStage) { if (stage.$lastPassedStage) {
return showPkGuideFromHis return showPkGuideFromHis && activePkGuideFromHis
} }
}, [pkGuideActive, pkGuideStep, stage, showPkGuideFromHis, isSpecialRound]) }, [pkGuideActive, pkGuideStep, stage, showPkGuideFromHis, isSpecialRound, activePkGuideFromHis])
const handleClick = () => { const handleClick = () => {
if (stage.status !== StageStatus.DISABLED || !isProduction) { if (stage.status !== StageStatus.DISABLED || !isProduction) {
...@@ -196,7 +197,7 @@ const StageComp = (props: StageProps) => { ...@@ -196,7 +197,7 @@ const StageComp = (props: StageProps) => {
if (isSpecialRound) return if (isSpecialRound) return
if (showPkGuideFromHis) { if (showPkGuideFromHis) {
updateGuideState({ showPkGuideFromHis: false }) updateGuideState({ showPkGuideFromHis: false, activePkGuideFromHis: false })
} else { } else {
nextPkGuide() nextPkGuide()
} }
...@@ -254,7 +255,7 @@ const StageComp = (props: StageProps) => { ...@@ -254,7 +255,7 @@ const StageComp = (props: StageProps) => {
isActive={isPkGuideShow} isActive={isPkGuideShow}
wrapClass={styles.pk_guide_wrap} wrapClass={styles.pk_guide_wrap}
verticalPadding={0} verticalPadding={0}
delay={showPkGuideFromHis ? 300 : 0} delay={100}
horizonPadding={0} horizonPadding={0}
guideViewId="first_pk_guide" guideViewId="first_pk_guide"
guideContent={( guideContent={(
......
...@@ -47,6 +47,7 @@ export interface GuideModel { ...@@ -47,6 +47,7 @@ export interface GuideModel {
nextPkGuide: Action<GuideModel>; nextPkGuide: Action<GuideModel>;
addPkGuideTimes: Action<GuideModel, void>; addPkGuideTimes: Action<GuideModel, void>;
showPkGuideFromHis: boolean; showPkGuideFromHis: boolean;
activePkGuideFromHis: boolean;
pointToCardNum: number; pointToCardNum: number;
completeAddDeskGuide: Thunk<GuideModel, void, void, AppStoreModel>; completeAddDeskGuide: Thunk<GuideModel, void, void, AppStoreModel>;
...@@ -67,6 +68,7 @@ const guideModel: GuideModel = { ...@@ -67,6 +68,7 @@ const guideModel: GuideModel = {
storeGuideStep: 0, storeGuideStep: 0,
pointToCardNum: 0, pointToCardNum: 0,
pkGuideStep: 0, pkGuideStep: 0,
activePkGuideFromHis: false,
showPkGuideFromHis: false, showPkGuideFromHis: false,
pkGuideTimes: getStorage(StorageKeys.pkGuideTimes), pkGuideTimes: getStorage(StorageKeys.pkGuideTimes),
......
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