Commit eb2af188 authored by m's avatar m

feat: update

parent 104617a2
......@@ -7,8 +7,8 @@
export default {
pages: [
'pages/main/main',
'pages/group/index',
'pages/prepare/index',
'pages/group/index',
'pages/market/index',
'pages/game/play/index',
'pages/game/complete/index',
......
......@@ -45,6 +45,7 @@
&.right {
left: -48px;
}
}
......@@ -54,3 +55,19 @@
position: relative;
z-index: 2;
}
.right .icon {
&.hasPoint {
position: relative;
&::after {
position: absolute;
content: "";
top: 6PX;
right: 0;
width: 12PX;
height: 12PX;
border-radius: 24PX;
background-color: #ff4d4f;
}
}
}
import { useState, useImperativeHandle, forwardRef, useCallback, type ForwardRefRenderFunction } from 'react'
import { View, Image } from '@tarojs/components'
import { switchTab } from '@tarojs/taro'
import { useStoreState } from '@/store/hooks'
import classNames from 'classnames'
import styles from './index.module.scss'
......@@ -11,6 +12,7 @@ type TabbarRef = {
const Tabbar: ForwardRefRenderFunction<TabbarRef, {}> = (_, ref) => {
const [selected, setSelected] = useState(0)
const hasPoint = useStoreState(state => state.groupModel.hasPoint)
const _switchTab = useCallback((index: number, url: string) => {
setSelected(index)
......@@ -37,7 +39,7 @@ const Tabbar: ForwardRefRenderFunction<TabbarRef, {}> = (_, ref) => {
{selected === 1 && (
<Image src="/assets/tabbar/group-bg.png" className={classNames(styles.bg, styles.right)}></Image>
)}
<Image src="/assets/tabbar/group-on.png" className={styles.icon} />
<Image src="/assets/tabbar/group-on.png" className={classNames(styles.icon, { [styles.hasPoint]: hasPoint })} />
</View>
</View>
</View>
......
[
"快乐学堂",
"小天才俱乐部",
"阳光小学霸",
"知识小勇士",
"童话学习园",
"学习小精灵",
"天才小书虫",
"梦想学习园",
"童心书屋",
"快乐成长树",
"学习的小蜜蜂",
"小小探险家",
"彩虹学习园",
"知识小花园",
"童趣学习宝",
"笑脸学习站",
"阳光小学堂",
"学习宝贝岛",
"智慧小博士",
"成长快车道",
"快乐学习团",
"童年学习梦",
"稚趣学园",
"学习小蜗牛",
"智力小超人",
"小小地球村",
"学习乐园",
"梦想小舞台",
"小小数学家",
"知识小火车",
"爱心学习站",
"快乐学习家",
"学习小翅膀",
"童年智慧树",
"快乐小天使",
"学习的小精灵",
"阳光学习园",
"快乐读书房",
"童梦学习园",
"智慧的种子",
"爱学习的小熊",
"学习小动力",
"彩虹小学者",
"幸福学习屋",
"快乐小导航",
"学习的小苹果",
"知识小宇宙",
"笑声学习岛",
"学习小奇迹",
"学习小小鸟",
"勇敢学习者",
"童话小学者",
"智慧小花朵",
"快乐成长班",
"快乐学习派",
"快乐学习小组",
"成长的脚印",
"智慧之光",
"勤学好问团",
"阳光小伙伴",
"小小智者",
"知识宝石",
"快乐成长园",
"智慧小鸟",
"梦想之船",
"学习天地",
"小状元家",
"知识小宝藏",
"快乐蜜蜂",
"智慧小农场",
"学海探险队",
"快乐小学堂",
"奇思妙想团",
"成长快乐屋",
"智慧星空",
"宝贝学习站",
"知识探险家",
"勇敢小学霸",
"快乐学习岛",
"成长奇迹",
"智慧之星",
"快乐小蜜蜂",
"宝贝学习园",
"学习小导航",
"智慧之树",
"学习小战士",
"知识小天地",
"快乐探索家",
"智慧之路",
"学习快车",
"成长幸福园",
"快乐小学者",
"知识小宇宙",
"学习之旅",
"发现之星",
"梦想成真",
"学习小天地",
"知识小导航",
"学习之星",
"勤奋小蜗牛",
"智慧小花园",
"成长之梦",
"快乐学习舞台",
"知识小岛",
"学习之路",
"勇敢的小学者",
"快乐小王子",
"知识宝库",
"智慧之源",
"成长快乐站",
"快乐学习宝",
"知识小精灵",
"学习小天使",
"智慧小神童",
"成长快乐家",
"快乐学习园",
"知识小飞侠",
"学习小助手",
"智慧小导航",
"成长快乐岛",
"快乐学习派",
"学习小能手",
"智慧小熊",
"成长的天空",
"快乐小书虫",
"知识小助手",
"学习小飞侠",
"智慧小花朵",
"成长的舞台",
"快乐学习星",
"知识小导航",
"学习小蜜蜂",
"智慧小太阳",
"成长的翅膀",
"快乐小学习",
"知识小天才",
"学习小超人",
"智慧小奇迹",
"成长的日记",
"知识小状元",
"学习小梦想",
"智慧小神童",
"成长的足迹",
"快乐小状元",
"知识小舞台",
"学习小宝贝",
"智慧小蜜蜂",
"成长的歌声",
"快乐学习园",
"知识小能手",
"学习小快乐",
"智慧小天空",
"成长的种子",
"快乐小智者",
"知识小战士",
"学习小发现",
"智慧小冒险家",
"成长的航道",
"快乐小发现",
"知识小探险家",
"学习小太阳",
"智慧小星星",
"成长的瞬间",
"快乐小小熊",
"知识小英雄",
"学习小快车",
"智慧小脚印",
"成长的花园",
"快乐小奇迹"
]
\ No newline at end of file
......@@ -23,6 +23,13 @@
height: 30PX;
}
&_description {
font-size: 13PX;
color: #9999;
position: relative;
left: 20PX;
}
&_footer {
margin-top: 64px;
display: flex;
......
import { View, Image, Input, ScrollView } from '@tarojs/components'
import { View, Image, Input, ScrollView, Text } from '@tarojs/components'
import { useDidShow, getCurrentInstance, getTabBar, getMenuButtonBoundingClientRect, showModal, useShareAppMessage } from '@tarojs/taro'
import { useMemo, useState } from 'react'
......@@ -20,11 +20,14 @@ import ShareButton from './components/share-button'
import styles from './index.module.scss'
import memberStyles from './components/members.module.scss'
import groupNames from './data.json'
const Group = () => {
const randomIndex = Math.floor(Math.random() * groupNames.length)
const page = useMemo(() => getCurrentInstance().page, [])
const [nav] = useState(getMenuButtonBoundingClientRect())
const [isVisible, { setTrue, setFalse }] = useBoolean(false)
const [groupNo, setGroupNo] = useState<string>('')
const [groupNo, setGroupNo] = useState<string>(groupNames[randomIndex])
const [refresher, { toggle }] = useBoolean(false)
const userInfo = useStoreState(state => state.userModel.userInfo)
......@@ -87,7 +90,7 @@ const Group = () => {
<MainHeader groupNo={tribeInfo?.groupNo!} />
<View>
{!tribeInfo?.id ? <Creator onClick={setTrue} /> : <Members />}
{tribeInfo?.id ? <Members /> : <Creator onClick={setTrue} />}
</View>
</ScrollView>
......@@ -98,9 +101,17 @@ const Group = () => {
<Modal isVisible={isVisible} tilte="学习部落名" onClose={setFalse}>
<View className={styles.modal}>
<View className={styles.modal_body}>
<Input className={styles.modal_input} value={groupNo} placeholder="请输入" placeholderStyle="color: #9999;" onInput={(e) => setGroupNo(e.detail.value)} />
<Image className={styles.modal_refresh} mode="widthFix" src={assets['refresh.png'].u} />
<Input className={styles.modal_input} disabled value={groupNo} />
<Image
className={styles.modal_refresh}
mode="widthFix"
src={assets['refresh.png'].u}
onClick={() => setGroupNo(groupNames[randomIndex])}
/>
</View>
<Text className={styles.modal_description}>
* 可点击右侧按钮随机生成名字
</Text>
<View className={styles.modal_footer}>
<Button onClick={setFalse} type="default">取消</Button>
<Button onClick={onConfirm} loading={spining}>确定</Button>
......
......@@ -9,6 +9,7 @@ export interface GroupModel {
points: PointType[],
tribeInfo: TribeInfo | null;
groupMembers: Computed<GroupModel, MemberItem[]>;
hasPoint: Computed<GroupModel, boolean>;
isEmpty: Computed<GroupModel, boolean>;
updateState: Action<GroupModel, Partial<State<GroupModel>>>;
fetchTribeInfo: Thunk<GroupModel, { memberId?: number } | undefined, void, AppStoreModel, Promise<TribeInfo>>;
......@@ -20,6 +21,7 @@ const groupModel: GroupModel = {
points: [],
groupMembers: computed((state) => state.tribeInfo?.groupMembers || []),
isEmpty: computed((state) => state.groupMembers.length < 1),
hasPoint: computed((state) => state.points.some(item => item.point)),
updateState: action((state, payload) => {
for (const key in payload) {
......
......@@ -13,6 +13,7 @@
font-size: 52px;
font-weight: 600;
color: #FFFFFF;
animation: scale3d 1s ease-in-out forwards;
}
.labels {
......@@ -20,15 +21,40 @@
gap: 20px;
margin-bottom: 48px;
@keyframes fadeInScale {
0% {
opacity: 0;
transform: scale(0.3) translateX(-50px);
}
50% {
transform: scale(1.1) translateX(0);
}
100% {
opacity: 1;
transform: scale(1) translateX(0);
}
}
.label {
@include flexLayout(row, center);
font-size: 12PX;
font-weight: 400;
color: #FFFFFF;
padding: 8PX;
background: rgba(226,233,255,0.2);
border-radius: 6PX;
@include flexLayout(row, center);
gap: 3PX;
animation: fadeInScale 1s cubic-bezier(0.215, 0.610, 0.355, 1.000) backwards;
&:nth-child(1) {
animation-delay: 0.3s;
}
&:nth-child(2) {
animation-delay: 0.6s;
}
&:nth-child(3) {
animation-delay: 0.9s;
}
.icon {
width: 16PX;
......@@ -37,6 +63,66 @@
}
}
.replay {
background: rgba(226,233,255,0.2);
border-radius: 30px;
border: 1px solid #FFFFFF;
@include flexLayout(row, center);
font-size: 15PX;
font-weight: 500;
color: #FFFFFF;
padding: 32px 0;
position: relative;
margin-bottom: 48px;
&::before {
content: '';
position: absolute;
width: 1px;
transform: scaleY(0.5);
background-color: rgba(255,255,255,0.4);
right: 50%;
top: 0;
bottom: 0;
}
.performance {
width: 50%;
animation: fadeInLeft 1s ease-in-out forwards;
.details {
@include flexLayout(row, center, center);
gap: 6PX;
margin-top: 12PX;
.logo {
width: 24PX;
height: 24PX;
}
.consume {
font-size: 20PX;
}
}
}
.achievement {
width: 50%;
animation: fadeInRight 1s ease-in-out forwards;
.details {
margin-top: 12PX;
@include flexLayout(row, center, center);
gap: 20px;
.logo {
width: 32PX;
height: 32PX;
}
}
}
}
.requirement {
@include flexLayout(column);
......@@ -77,11 +163,24 @@
gap: 12PX;
.detail {
@include flexLayout(row, center, space-between);
animation: fadeInLeft 1s ease-in-out backwards;
background: rgba(226,233,255,0.3);
border-radius: 12PX;
@include flexLayout(row, center, space-between);
color: #fff;
&:nth-child(1) {
animation-delay: 0.3s;
}
&:nth-child(2) {
animation-delay: 0.6s;
}
&:nth-child(3) {
animation-delay: 0.9s;
}
.content {
@include flexLayout(row, center);
......@@ -123,62 +222,48 @@
}
}
}
}
.replay {
background: rgba(226,233,255,0.2);
border-radius: 30px;
border: 1px solid #FFFFFF;
@include flexLayout(row, center);
font-size: 15PX;
font-weight: 500;
color: #FFFFFF;
padding: 32px 0;
position: relative;
margin-bottom: 48px;
&::before {
content: '';
position: absolute;
width: 1px;
transform: scaleY(0.5);
background-color: rgba(255,255,255,0.4);
right: 50%;
top: 0;
bottom: 0;
@keyframes fadeInRight {
0% {
opacity: 0;
transform: translateX(30px);
}
.performance {
width: 50%;
.details {
@include flexLayout(row, center, center);
gap: 6PX;
margin-top: 12PX;
.logo {
width: 24PX;
height: 24PX;
100% {
opacity: 1;
transform: translateX(0);
}
}
.consume {
font-size: 20PX;
}
@keyframes fadeInLeft {
0% {
opacity: 0;
transform: translateX(-30px);
}
100% {
opacity: 1;
transform: translateX(0);
}
}
.achievement {
width: 50%;
.details {
margin-top: 12PX;
@include flexLayout(row, center, center);
gap: 20px;
.logo {
width: 32PX;
height: 32PX;
@keyframes fadeInDown {
0% {
opacity: 0;
transform: translateY(-30px);
}
100% {
opacity: 1;
transform: translateY(0);
}
}
@keyframes scale3d {
0% {
opacity: 0;
transform: scale3d(1.5, 1.5, 1);
}
100% {
opacity: 1;
transform: scale3d(1, 1, 1)
}
}
\ No newline at end of file
......@@ -4,6 +4,7 @@ import { useCallback, useMemo } from 'react'
import { useStoreState } from '@/store/hooks'
import { StageType, StageLevel, type StageDetail, type NextStep } from '@/api'
import assets from '@/assets/oss/assets-prepare'
import styles from './main-header.module.scss'
const MainHeader = () => {
......@@ -112,7 +113,7 @@ const MainHeader = () => {
const renderAgain = () => (
<View className={styles.details}>
{stageDetail.nextSteps?.map((item) => (
<RequireItem u={renderNextStep(item)} v={item.nextStepReward} t={item.nextStepTime} />
<RequireItem key={item.nextStep} u={renderNextStep(item)} v={item.nextStepReward} t={item.nextStepTime} />
))}
</View>
)
......
......@@ -7,6 +7,15 @@
overflow: visible;
}
.mask {
position: absolute;
background-color: #fff;
top: 48PX;
bottom: 0;
left: 0;
right: 0;
}
.tabBar {
display: flex;
height: 88PX;
......
......@@ -67,6 +67,7 @@ const Tabs = ({
})
const tabPaneStyle = {
height: isActive ? 'auto' : 0,
transform: `translateX(${(index - activeIndex) * 100}%)`,
transition: 'transform 0.3s ease-in-out',
}
......@@ -81,6 +82,7 @@ const Tabs = ({
return (
<View className={styles.tabs}>
<View className={styles.mask} />
<View className={classNames(styles.tabBar, activeIndex === 0 ? styles.active_1 : styles.active_2)}>
{renderTabs()}
</View>
......
......@@ -49,7 +49,7 @@
.empty {
color: #9999;
font-size: 14PX;
margin-top: 12PX;
margin: 24PX 0;
text-align: center;
}
......
import { View, Text, Image } from '@tarojs/components'
import { useMemo, useState, useEffect, useCallback } from 'react'
import { useRouter, redirectTo, useDidShow, getMenuButtonBoundingClientRect, useShareAppMessage, navigateTo } from '@tarojs/taro'
import { useRouter, redirectTo, useDidShow, getMenuButtonBoundingClientRect, useShareAppMessage, navigateTo, showLoading, hideLoading } from '@tarojs/taro'
import classNames from 'classnames'
import Button from '@/components/Button'
......@@ -24,6 +24,7 @@ const Prepare = () => {
const nav = useMemo(getMenuButtonBoundingClientRect, [])
const router = useRouter<{ id: string }>()
const [currentTab, setCurrentTab] = useState(0)
const [loading, setLoading] = useState(false)
const [isVisible, { setTrue, setFalse }] = useBoolean(false)
const stageDetail = useStoreState(state => state.gameModel.stageDetail)
......@@ -54,18 +55,6 @@ const Prepare = () => {
}
]
const { run: exchange, loading } = useRequest(pointToCard, {
immediate: false,
onSuccess: () => {
setFalse()
getQuestionList(+router.params.id || 1).then(() => {
navigateTo({
url: `/pages/game/play/index?id=${router.params.id}`
})
})
}
})
const innerStyle = useMemo(() => {
const h = nav.height + nav.top + 5
return {
......@@ -73,15 +62,21 @@ const Prepare = () => {
}
}, [nav.height, nav.top])
useDidShow(async () => {
setLoading(true)
await getStageDetail(+router.params.id || 1)
setLoading(false)
})
useEffect(() => {
if (cardNum < 1) {
getSetting()
}
}, [cardNum, getSetting])
useDidShow(() => {
getStageDetail(+router.params.id || 1)
})
useEffect(() => {
!loading && hideLoading()
}, [loading])
useShareAppMessage(() => {
return {
......@@ -91,6 +86,18 @@ const Prepare = () => {
}
})
const { run: exchange, loading: spinning } = useRequest(pointToCard, {
immediate: false,
onSuccess: () => {
setFalse()
getQuestionList(+router.params.id || 1).then(() => {
navigateTo({
url: `/pages/game/play/index?id=${router.params.id}`
})
})
}
})
const handleClick = () => {
if (cardNum < 1 && !stageDetail?.firstTime) {
setTrue()
......@@ -103,19 +110,6 @@ const Prepare = () => {
}
}
const isLast = useMemo(() => {
return stageList.length - 1 === stageList.findIndex(c => c.id === stageDetail?.id)
}, [stageList, stageDetail])
const onNext = useCallback(() => {
const index = stageList.findIndex(item => item.id === stageDetail?.id)
const id = stageList[index + 1]?.id
if (id) {
redirectTo({ url: `/pages/prepare/index?id=${id}` })
updateState({ isSubmit: false })
}
}, [stageList, stageDetail?.id, updateState])
const renderFisrtActions = () => (
<View className={styles.challenge}>
<Button size="large" onClick={handleClick} image={styles.image} hoverImage={styles.hover_image}>
......@@ -131,6 +125,19 @@ const Prepare = () => {
</View>
)
const isLast = useMemo(() => {
return stageList.length - 1 === stageList.findIndex(c => c.id === stageDetail?.id)
}, [stageList, stageDetail])
const onNext = useCallback(() => {
const index = stageList.findIndex(item => item.id === stageDetail?.id)
const id = stageList[index + 1]?.id
if (id) {
redirectTo({ url: `/pages/prepare/index?id=${id}` })
updateState({ isSubmit: false })
}
}, [stageList, stageDetail?.id, updateState])
const hasNextBtn = useMemo(() => {
return stageDetail?.level && isSubmit && !isLast
}, [stageDetail, isSubmit, isLast])
......@@ -157,9 +164,14 @@ const Prepare = () => {
</View>
)
if (loading) {
return showLoading()
}
return (
<View className={styles.wrapper}>
<TopBar />
<View className={styles.inner} style={innerStyle}>
<MainHeader />
<Tabs initialIndex={currentTab} items={tabs} onChange={setCurrentTab} />
......@@ -180,11 +192,11 @@ const Prepare = () => {
<View
className={classNames(styles.buy_card, {
[styles.buy_card_disabled]: point < setting.pointToCard,
[styles.buy_card_loading]: loading,
[styles.buy_card_loading]: spinning,
})}
onClick={() => !loading && point >= setting.pointToCard && exchange({ num: 1 })}
onClick={() => !spinning && point >= setting.pointToCard && exchange({ num: 1 })}
>
<Loading size="small" className={styles.buy_card_spin} spinning={loading} />
<Loading size="small" className={styles.buy_card_spin} spinning={spinning} />
<View className={styles.inner}>
<Image className={styles.logo} src={point >= setting.pointToCard ? assets['diamond.png'].u : assets['diamond-un.png'].u} mode="widthFix" />
<Text>-{setting.pointToCard}</Text>
......
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