Commit fa11ce92 authored by raca's avatar raca

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

Merge branch 'feature/2023-04-19-iter' of https://118.24.71.244/hewenhao/GeekLearnMathWeapp into feature/2023-04-19-iter
parents 9121ee6d b6efbee3
......@@ -306,6 +306,9 @@
"心善的",
"谦虚的",
"低调的",
"疯狂的",
"狂野的",
"奔放的",
"好客的",
"热心的",
"敬业的",
......
{
"name": "learn-math-weapp",
"version": "1.0.5",
"version": "1.0.6",
"private": true,
"description": "",
"scripts": {
......
......@@ -3,6 +3,12 @@
z-index: 9999998;
opacity: 1;
box-shadow: rgba(0,0,0, .6) 0px 0px 0px 5000PX;
animation-name: fadeIn_2;
animation-duration: .5s;
animation-timing-function: ease-out;
animation-iteration-count: 1;
animation-fill-mode: backwards;
animation-delay: 0s;
}
.content {
......@@ -17,4 +23,19 @@
top: 0;
bottom: 0;
z-index: 9999997;
animation-name: fadeIn_2;
animation-duration: .5s;
animation-timing-function: ease-out;
animation-iteration-count: 1;
animation-fill-mode: backwards;
animation-delay: 0s;
}
@keyframes fadeIn_2 {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
......@@ -147,7 +147,7 @@
top: -16px;
bottom: -16px;
pointer-events: none;
border: 4px dashed #fff;
border: 8px dashed #fff;
border-radius: 58px;
}
}
......
......@@ -217,12 +217,12 @@ const GameCompleteHead = () => {
<View className={styles.guide}>
<View className={styles.guide_inner}>
<Image src={tutorialAssets['cat.png'].u} className={styles.guide_icon}></Image>
<View className={styles.guide_modal}>
<View className={styles.guide_modal} onClick={completeGuide}>
<View>
点击此处,可以查看<Text className={styles.em}>本次闯关的错题</Text>哦~
</View>
<View className={styles.continue}>
<View className={styles.continue_btn} onClick={completeGuide}>
<View className={styles.continue_btn}>
我知道了<Image src={tutorialAssets['continue-arrow.png'].u} className={styles.continue_icon} />
</View>
</View>
......
......@@ -174,7 +174,7 @@
top: -16px;
bottom: -16px;
pointer-events: none;
border: 4px dashed #fff;
border: 8px dashed #fff;
border-radius: 32px;
}
}
......
......@@ -89,10 +89,10 @@ const Creator = ({ onClick }: { onClick: () => void }) => {
guideContent={(
<View className={styles.guide_content}>
<Image src={tutorialAssets['cat-2.png'].u} className={styles.guide_cat} />
<View className={classNames(styles.dialog, item.guideModalLow && styles.is_lower)}>
<View className={classNames(styles.dialog, item.guideModalLow && styles.is_lower)} onClick={() => nextGroupGuide()}>
{item.guideTips}
<View className={styles.continue}>
<View className={styles.continue_btn} onClick={() => nextGroupGuide()}>
<View className={styles.continue_btn}>
继续<Image src={tutorialAssets['continue-arrow.png'].u} className={styles.continue_icon} />
</View>
</View>
......
......@@ -7,8 +7,15 @@
background: rgba(0, 0, 0, 0.7);
z-index: 99999;
opacity: 1;
animation-name: fadeIn_2;
animation-duration: .5s;
animation-timing-function: ease-out;
animation-iteration-count: 1;
animation-fill-mode: backwards;
animation-delay: 0s;
}
.result_wrap {
position: fixed;
z-index: 100000;
......@@ -17,6 +24,12 @@
right: 0;
display: flex;
padding: 0 16px;
animation-name: fadeIn_2;
animation-duration: .5s;
animation-timing-function: ease-out;
animation-iteration-count: 1;
animation-fill-mode: backwards;
animation-delay: 0s;
}
.slogen {
......@@ -97,3 +110,12 @@
display: block;
margin-left: 4px;
}
@keyframes fadeIn_2 {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
......@@ -30,7 +30,7 @@ const GuideModal = () => {
<View>部落PK大赛</View>
</View>
</View>
<View className={classNames(styles.dialog)}>
<View className={classNames(styles.dialog)} onClick={() => completeGroupGuide()}>
<View>
让我们先从基本功开始。已经为你准备好了打好基本功所必须掌握的
<Text className={styles.em}>计算达标</Text>、
......@@ -38,7 +38,7 @@ const GuideModal = () => {
以及<Text className={styles.em}>附加思维题</Text>哦。
</View>
<View className={styles.continue}>
<View className={styles.continue_btn} onClick={() => completeGroupGuide()}>
<View className={styles.continue_btn}>
我知道了<Image src={tutorialAssets['continue-arrow.png'].u} className={styles.continue_icon} />
</View>
</View>
......
......@@ -32,10 +32,10 @@ const MainPage = () => {
const point = useStoreState(state => state.userModel.point)
const isGroupGuideComplete = useStoreState(state => state.guideModel.isGroupGuideComplete)
const isMainGuideComplete = useStoreState(state => state.guideModel.isMainGuideComplete)
const isStoreGuideComplete = useStoreState(state => state.guideModel.isStoreGuideComplete)
const fetchAccount = useStoreActions(actions => actions.userModel.fetchAccount)
const updateGroupGuideActive = useStoreActions(actions => actions.guideModel.updateGroupGuideActive)
const fetchTribeInfo = useStoreActions(actions => actions.groupModel.fetchTribeInfo)
const userInfo = useStoreState(state => state.userModel.userInfo)
const nav = useMemo(getMenuButtonBoundingClientRect, [])
......@@ -48,12 +48,21 @@ const MainPage = () => {
})
}, [])
useEffect(() => {
if (isGroupGuideComplete || !isMainGuideComplete || !isStoreGuideComplete) {
return
}
const isFocus = useFocus()
// 激活部落引导
useEffect(() => {
const fn = async () => {
if (
!isFocus ||
isGroupGuideComplete ||
userInfo.pointReceive === 'N' ||
!userInfo.city ||
!userInfo.grade
) {
return
}
const currentIndex = stageList.findIndex(c => c.status === StageStatus.CURRENT)
if (point < 50 || currentIndex >= 3) {
......@@ -64,20 +73,12 @@ const MainPage = () => {
}
}
fn()
}, [point, isGroupGuideComplete, stageList, updateGroupGuideActive, fetchTribeInfo, isMainGuideComplete, isStoreGuideComplete])
const isFocus = useFocus()
}, [point, isGroupGuideComplete, stageList, updateGroupGuideActive, userInfo, fetchTribeInfo, isMainGuideComplete, isFocus])
onAppHide(() => {
player.pause()
})
useEffect(() => {
if (isFocus) {
fetchTribeInfo()
}
}, [isFocus, fetchTribeInfo])
useEffect(() => {
if (isFocus) {
player.play()
......@@ -85,7 +86,7 @@ const MainPage = () => {
}, [player, isFocus])
useEffect(() => {
if (isFocus) {
if (isFocus && userInfo.city) {
fetchAccount()
const tabbar = getTabBar<TabbarRef>(page)
......@@ -112,7 +113,7 @@ const MainPage = () => {
}, 200)
})
}
}, [isFocus, fetchAccount, fetchStage, page, scrollToCurrent, updateReady])
}, [isFocus, fetchAccount, fetchStage, page, scrollToCurrent, updateReady, userInfo.city])
return (
<>
......
......@@ -18,7 +18,7 @@
top: -16px;
bottom: -16px;
pointer-events: none;
border: 4px dashed #fff;
border: 8px dashed #fff;
border-radius: 50%;
}
}
......
......@@ -103,6 +103,8 @@ const getIconClassNames = (type?: StageType, extra: string[] = []) => {
return classNames(styles.icon, type === StageType.OneStop && styles.isOneStop, ...extra)
}
const isProduction = process.env.SERVER_ENDPOINT === 'https://geek.jkwljy.com'
const StageComp = (props: StageProps) => {
const { stage } = props
const updateState = useStoreActions(actions => actions.gameModel.updateState)
......@@ -112,7 +114,7 @@ const StageComp = (props: StageProps) => {
const mainGuideActive = useStoreState(state => state.guideModel.mainGuideActive)
const handleClick = () => {
if (stage.status !== StageStatus.DISABLED) {
if (stage.status !== StageStatus.DISABLED || !isProduction) {
/** 从首页进入更新状态 */
updateState({ isSubmit: false })
navigateTo({ url: `/pages/prepare/index?id=${stage.id}` })
......@@ -185,7 +187,7 @@ const StageComp = (props: StageProps) => {
onClick={handleClick}
>
{renderRound(isReady)}
<View className={styles.roundName}>{stage.name}</View>
<View className={styles.roundName}>{!isProduction ? `${stage.id}.` : ''}{stage.name}</View>
</View>
)
}
......
import { useState, useCallback, useEffect } from 'react'
import { getAreaAndGrades, type AreaAndGrades } from '@/api'
import { useState, useCallback, useEffect, useRef } from 'react'
import { getAreaAndGrades, type AreaAndGrades, StageStatus } from '@/api'
import { useStoreState, useStoreActions } from '@/store/hooks'
import { useFocus } from '@/hooks'
import ModalArea from './modal-area'
......@@ -22,11 +22,13 @@ const Tutorial = () => {
const groupGuideActive = useStoreState(state => state.guideModel.groupGuideActive)
const groupGuideStep = useStoreState(state => state.guideModel.groupGuideStep)
const isGroupGuideComplete = useStoreState(state => state.guideModel.isGroupGuideComplete)
const stageList = useStoreState(state => state.mainModel.stageList)
const nextGroupGuide = useStoreActions(actions => actions.guideModel.nextGroupGuide)
const [step, setStep] = useState(0)
const [selected, setSelected] = useState({ area: '', grade: '' })
const [enable, setEnable] = useState(false)
const isLoadRef = useRef(false)
const isFocus = useFocus()
useEffect(() => {
......@@ -47,10 +49,11 @@ const Tutorial = () => {
const handleConfirm = useCallback(() => {
setStep(0)
if (!isMainGuideComplete) {
const index = stageList.findIndex(c => c.status === StageStatus.CURRENT)
if (!isMainGuideComplete && index === 0) {
updateGuideActive(true)
}
}, [updateGuideActive, isMainGuideComplete])
}, [updateGuideActive, isMainGuideComplete, stageList])
const loadData = useCallback(() => {
return getAreaAndGrades()
......@@ -86,6 +89,10 @@ const Tutorial = () => {
if (!data.areas.length) {
loadData()
}
if (isLoadRef.current) {
return
}
isLoadRef.current = true
// 没选择城市
if (!userInfo.city) {
setStep(1)
......@@ -93,12 +100,14 @@ const Tutorial = () => {
setStep(2)
} else {
setStep(0)
if (!isMainGuideComplete) {
// 只有第一关才有
const index = stageList.findIndex(c => c.status === StageStatus.CURRENT)
if (!isMainGuideComplete && index === 0) {
updateGuideActive(true)
}
}
}
}, [isFocus, data.areas, isMainGuideComplete, updateGuideActive, loadData, userInfo.city, userInfo.grade])
}, [isFocus, data.areas, isMainGuideComplete, updateGuideActive, loadData, userInfo.city, userInfo.grade, stageList])
if (!enable) {
return null
......@@ -109,7 +118,7 @@ const Tutorial = () => {
{step === 1 && <ModalArea options={data.areas} onConfirm={handleConfirmArea} loading={updating} />}
{step === 2 && !userInfo.grade && <ModalGrade options={data.grades} onConfirm={handleConfirmGrade} loading={updating} />}
{step === 3 && <ModalResult grade={selected.grade} onConfirm={handleConfirm} />}
{groupGuideActive && !isGroupGuideComplete && groupGuideStep === 0 && <ModalGroupGuide onConfirm={nextGroupGuide} />}
{step === 0 && groupGuideActive && !isGroupGuideComplete && groupGuideStep === 0 && <ModalGroupGuide onConfirm={nextGroupGuide} />}
</>
)
}
......
......@@ -16,13 +16,13 @@ const ModalGroupGuide = (props: ModalGroupGuideProps) => {
<View className={styles.result_wrap} catchMove>
<Image src={tutorialAssets['cat.png'].u} className={styles.result_cat} />
<View className={styles.result_main}>
<View className={classNames(styles.dialog)}>
<View className={classNames(styles.dialog)} onClick={() => onConfirm()}>
<View>
阿喵老师很高兴看到你在不断进步,接下来我要传授你一个
<Text className={styles.em}>得到大量水晶的好方法</Text>。
</View>
<View className={styles.continue}>
<View className={styles.continue_btn} onClick={() => onConfirm()}>
<View className={styles.continue_btn}>
继续<Image src={tutorialAssets['continue-arrow.png'].u} className={styles.continue_icon} />
</View>
</View>
......
......@@ -22,7 +22,7 @@ const ModalResult = (props: ModalResultProps) => {
<View className={styles.result_wrap} catchMove>
<Image src={tutorialAssets['cat.png'].u} className={styles.result_cat} />
<View className={styles.result_main}>
<View className={classNames(styles.dialog, isLevel1 && styles.is_lower)}>
<View className={classNames(styles.dialog, isLevel1 && styles.is_lower)} onClick={() => onConfirm()}>
{isLevel1
? (
<View>
......@@ -39,7 +39,7 @@ const ModalResult = (props: ModalResultProps) => {
</View>
)}
<View className={styles.continue}>
<View className={styles.continue_btn} onClick={() => onConfirm()}>
<View className={styles.continue_btn}>
继续<Image src={tutorialAssets['continue-arrow.png'].u} className={styles.continue_icon} />
</View>
</View>
......
......@@ -36,17 +36,19 @@ const ExchangeItem = (props: ExchangeItemProps) => {
}, [val])
useEffect(() => {
if (!visible) {
setTimeout(() => {
if (visible) {
if (maxValue > stepValue) {
setVal(1)
}, 1000)
} else {
setVal(0)
}
}
}, [visible])
}, [visible, stepValue, maxValue])
const handleAdd = useCallback(() => {
const next = val + 1
if (next * stepValue > maxValue) {
return showToast({ title: '学分不足~', icon: 'none' })
return showToast({ title: '水晶不足~', icon: 'none' })
}
setVal(next)
}, [val, stepValue, maxValue])
......@@ -69,6 +71,8 @@ const ExchangeItem = (props: ExchangeItemProps) => {
}).then(() => {
if (isGuideActive) {
nextStoreGuide(val)
} else {
showToast({ title: '兑换成功', icon: 'success' })
}
onCancel && onCancel()
}).catch(() => {
......
import { View, Text, Button, Input } from '@tarojs/components'
import Modal from '@/components/Modal'
import { useBoolean } from '@/hooks/use-boolean'
import CardMain from './card-main'
const MysteryBox = () => {
const [isVisible, { toggle }] = useBoolean(false)
const onClick = () => {
toggle()
}
return (
<View className="card-body">
<CardMain
title="神秘大礼"
subtitle="兑换神秘大礼,线下领取超级大礼"
extra={<Text className="card-stock">本月库存10</Text>}
onClick={toggle}
/>
<Modal isVisible={isVisible} onClose={toggle}>
<View>
<Input type="number" />
<Text>兑换礼物</Text>
<Button size="mini" onClick={onClick}>兑换</Button>
</View>
</Modal>
</View>
)
}
export default MysteryBox
......@@ -21,6 +21,7 @@ import styles from './index.module.scss'
type ExchangeGoods = {
title?: string;
subTitle: string;
isUpComing?: boolean;
description: string;
price: number;
isGuideCard?: boolean;
......@@ -36,6 +37,7 @@ const itemList: ExchangeGoods[] = [
price: 600,
isGuideCard: true,
stock: null,
isUpComing: true,
img: assets['item-1.png'].u,
},
{
......@@ -43,6 +45,7 @@ const itemList: ExchangeGoods[] = [
description: '让元气满满的向日葵,陪伴你一起向阳而生吧。',
price: 600,
stock: null,
isUpComing: true,
img: assets['item-2.png'].u,
},
{
......@@ -50,6 +53,7 @@ const itemList: ExchangeGoods[] = [
description: '播下种子,浇水施肥,收获属于你的酸甜小小西红柿。',
price: 600,
stock: null,
isUpComing: true,
img: assets['item-3.png'].u,
},
{
......@@ -57,6 +61,7 @@ const itemList: ExchangeGoods[] = [
description: '用心拼一朵玫瑰,送给为你辛苦的妈妈。',
price: 700,
stock: null,
isUpComing: true,
img: assets['item-4.png'].u,
},
{
......@@ -64,6 +69,7 @@ const itemList: ExchangeGoods[] = [
description: '自带颜料的创意绘画本,让你随地作画,随时随地开启小画家模式。',
price: 700,
stock: null,
isUpComing: true,
img: assets['item-5.png'].u,
},
]
......@@ -137,7 +143,7 @@ const StudyMarket = () => {
const pric = item.price
let disabledText = '积分不足'
let disabled = point < pric || (item.stock !== null && item.stock < 1)
if (item.subTitle === '神秘大礼') {
if (item.isUpComing) {
disabled = true
if (point >= pric) {
disabledText = '敬请期待'
......@@ -151,13 +157,13 @@ const StudyMarket = () => {
<View className={styles.guide_content}>
<Image src={tutorialAssets['cat-2.png'].u} className={styles.guide_cat} />
<View className={styles.guide_main}>
<View className={classNames(styles.dialog)}>
<View className={classNames(styles.dialog)} onClick={() => nextStoreGuide()}>
<View>
在这里,可以兑换闯关消耗的<Text className={styles.em}>答题卡</Text>,以及
<Text className={styles.em}>成长奖励</Text>哦~
</View>
<View className={styles.continue}>
<View className={styles.continue_btn} onClick={() => nextStoreGuide()}>
<View className={styles.continue_btn}>
继续<Image src={tutorialAssets['continue-arrow.png'].u} className={styles.continue_icon} />
</View>
</View>
......@@ -171,7 +177,7 @@ const StudyMarket = () => {
cover={item.img}
stock={item.stock}
price={pric}
disabled={disabled}
disabled={(!(item.isGuideCard && isStep1Active)) && disabled}
subtitle={item.description}
disabledText={disabledText}
isGuideActive={isMaskActive && storeGuideStep === 2 && index === 0}
......
......@@ -29,6 +29,7 @@ export const Scene = ({ children, onClickConent }: { onClickConent: () => void,
className={classNames(wrapStyles.score, showMask ? styles.bordered : null)}
isActive={showMask}
onClickConent={handleCompleteGuide}
onClick={onClickConent}
guideContent={(
<View className={styles.guide}>
<Image className={styles.guideCat} src={tutorialAssets['cat-3.png'].u} />
......
......@@ -121,7 +121,6 @@ const userModel: UserModel = {
const point = list?.find(c => c.accountType === 'POINT')?.amount ?? 0
actions.updateState({ cardNum, point })
hideLoading()
showToast({ title: '兑换成功', icon: 'success' })
} catch (err) {
hideLoading()
showModal({
......@@ -129,6 +128,7 @@ const userModel: UserModel = {
content: err.message,
showCancel: false
})
throw err
}
}),
......
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