Commit fb7f17e8 authored by m's avatar m

feat: update

parent a97f761d
......@@ -7,10 +7,11 @@
export default {
pages: [
'pages/main/main',
'pages/group/index',
'pages/prepare/index',
'pages/study-market/index',
'pages/group/index',
'pages/game/play/index',
'pages/summary/index',
],
subPackages: {{packages}},
resizable: true,
......
......@@ -13,7 +13,7 @@ interface ModalProps {
onClose?: () => void;
}
const Modal: React.FC<ModalProps> = ({
const Modal = ({
isVisible,
onClose,
children,
......@@ -21,7 +21,7 @@ const Modal: React.FC<ModalProps> = ({
bodyClassName,
coverNavigateBar = true, // z-index 层级高于原生的bar
maskClosable = true
}) => {
}: ModalProps) => {
const wrapClass = classNames(styles.wrapper, wrapClassName, {
[styles.visible]: isVisible
})
......
......@@ -7,11 +7,11 @@ export interface SkeletonAvatarProps {
size?: number;
}
const SkeletonAvatar: React.FC<SkeletonAvatarProps> = ({
const SkeletonAvatar = ({
animate = true,
shape = 'circle',
size = 48,
}) => {
}: SkeletonAvatarProps) => {
const avatarClass = classNames(
'skeleton-avatar',
animate ? 'skeleton-loading' : null,
......
......@@ -9,13 +9,13 @@ export interface SkeletonParagraphProps {
width?: string | number | (string | number)[];
}
const SkeletonParagraph: React.FC<SkeletonParagraphProps> = ({
const SkeletonParagraph = ({
animate = true,
rows = 3,
gap = 8,
height = 16,
width = '100%',
}) => {
}: SkeletonParagraphProps) => {
const paragraphRows = Array.from({ length: rows }, (_, i) => {
const rowWidth = Array.isArray(width)
? width[i] ?? width[width.length - 1]
......
......@@ -7,11 +7,11 @@ export interface SkeletonTitleProps {
width?: string | number;
}
const SkeletonTitle: React.FC<SkeletonTitleProps> = ({
const SkeletonTitle = ({
animate = true,
height = 16,
width = '30%',
}) => {
}: SkeletonTitleProps) => {
return (
<View
className={classNames('skeleton-title', animate ? 'skeleton-loading' : null)}
......
......@@ -20,14 +20,14 @@ interface TabsProps {
onChange?: (index: number) => void;
}
const Tabs: React.FC<TabsProps> = ({
const Tabs = ({
items,
initialIndex = 0,
tabBarGutter = 16,
tabBarStyle,
tabPanesStyle,
onChange,
}) => {
}: TabsProps) => {
const [activeIndex, setActiveIndex] = useState(initialIndex)
useEffect(() => {
......
......@@ -2,35 +2,18 @@
.container {
@include flexLayout(column);
.header {
padding: 16px;
.title {
font-size: 64px;
font-weight: 500;
}
.sign_in {
@include flexLayout();
gap: 16px;
border: 1px solid red;
padding: 12px 24px;
&_today, &_invite {
padding: 8px 12px;
border: 1px solid red;
border-radius: 12px;
}
}
}
.invite_members {
position: absolute;
width: 100%;
left: 0;
bottom: 150px;
padding-bottom: 56PX;
@include flexLayout(column, center, center);
gap: 16px;
&_btn {
width: 80%;
......@@ -39,5 +22,11 @@
padding: 8px 16px;
border-radius: 4px;
}
&_info {
margin-top: 8PX;
gap: 2PX;
@include flexLayout(column);
}
}
}
\ No newline at end of file
import { useMemo, useState, useEffect } from 'react'
import { getSystemInfoSync, createSelectorQuery } from '@tarojs/taro'
import { View, Button, Text, ScrollView } from '@tarojs/components'
import classNames from 'classnames'
import { useBoolean } from '@/hooks/use-boolean'
import SignIn from './sign-in'
import styles from './members.module.scss'
const screenHeight = getSystemInfoSync().windowHeight
const membersCls = '_members_const_'
const Members = ({ tabBarHeight }: { tabBarHeight: number }) => {
const [isRefresh, { setTrue, setFalse }] = useBoolean(false)
const [height, setHeight] = useState(0)
console.log('-tabBarHeight', tabBarHeight)
const onRefresh = () => {
setTrue()
......@@ -21,29 +16,11 @@ const Members = ({ tabBarHeight }: { tabBarHeight: number }) => {
}, 1000)
}
useEffect(() => {
const query = createSelectorQuery()
query.selectAll(`.${membersCls}`)
.boundingClientRect()
.exec((res) => {
if (res[0]) {
setHeight(res[0]?.[0].height + res[0]?.[1].height * 1.2)
}
})
}, [])
const scrollHeight = useMemo(() => {
return `${screenHeight - tabBarHeight - height - 60}px`
}, [screenHeight, tabBarHeight, height])
return (
<View className={styles.container}>
<View className={classNames(styles.header, membersCls)}>
<Text className={styles.title}>阳光学习帮</Text>
<View className={styles.sign_in}>
<Text className={styles.sign_in_today}>今日部落津贴 +2</Text>
<Text className={styles.sign_in_invite}>成功邀请1人 +100</Text>
</View>
<View className={styles.container} style={{ height: `calc(100vh - ${tabBarHeight}px)` }}>
<View className={styles.header}>
<Text className="title">阳光学习帮</Text>
<SignIn />
</View>
<ScrollView
......@@ -52,7 +29,7 @@ const Members = ({ tabBarHeight }: { tabBarHeight: number }) => {
refresherEnabled
refresherTriggered={isRefresh}
onRefresherRefresh={onRefresh}
style={{ height: scrollHeight }}
style={{ flexGrow: 1, height: 1 }} // 不知道为啥这里height: 1,就可以自适应高度了
>
<View>
<View>123</View>
......@@ -78,15 +55,52 @@ const Members = ({ tabBarHeight }: { tabBarHeight: number }) => {
<View>123</View>
<View>123</View>
<View>123</View>
<View>123</View>
<View>2123</View>
<View>3123</View>
<View>4123</View>
<View>5123</View>
<View>6123</View>
<View>123</View>
<View>123</View>
<View>123</View>
<View>123</View>
<View>123</View>
<View>123</View>
<View>123</View>
<View>123</View>
<View>123</View>
<View>123</View>
<View>123</View>
<View>123</View>
<View>123</View>
<View>123</View>
<View>123</View>
<View>123</View>
<View>123</View>
<View>123</View>
<View>123</View>
<View>123</View>
<View>123</View>
<View>123</View>
<View>123</View>
<View>123</View>
<View>2123</View>
<View>3123</View>
<View>4123</View>
<View>5123</View>
<View>6123</View>
</View>
</ScrollView>
<View className={classNames(styles.invite_members, membersCls)}>
<View className={styles.invite_members}>
<Button className={styles.invite_members_btn}>邀请人加入部落 +5答题卡</Button>
<View className={styles.invite_members_info}>
<Text>赠送朋友5张答题卡,一起来进击</Text>
<Text>好友进入小程序通关1关+5</Text>
</View>
</View>
</View>
)
}
......
@import '@/styles/mixins.scss';
.sign_in {
@include flexLayout();
gap: 16px;
border: 1px solid red;
padding: 12px 24px;
&_today, &_invite {
position: relative;
padding: 8px 12px;
border: 1px solid gray;
border-radius: 12px;
}
.success_message {
position: absolute;
right: 0;
bottom: 0;
opacity: 0;
transform: translateY(0);
animation: fadeInUp 0.6s ease_out;
}
}
@keyframes fadeInUp {
0% {
opacity: 0;
transform: translateY(0);
}
100% {
opacity: 1;
transform: translateY(_30px);
}
}
\ No newline at end of file
import { View, Text, Button } from '@tarojs/components'
import { useBoolean } from '@/hooks/use-boolean'
import styles from './sign-in.module.scss'
export default () => {
const [showMessage, { setTrue, setFalse }] = useBoolean(false)
const handleClick = () => {
setTrue()
setTimeout(() => {
setFalse()
}, 800)
}
return (
<View className={styles.sign_in}>
<View className={styles.sign_in_today}>
<Button onClick={handleClick}>今日部落津贴 +2</Button>
{showMessage && <Text className={styles.success_message}>领取成功</Text>}
</View>
<Text className={styles.sign_in_invite}>成功邀请1人 +100</Text>
</View>
)
}
......@@ -12,7 +12,7 @@ import Members from './components/members'
import styles from './index.module.scss'
const Group = () => {
const page = useMemo(() => getCurrentInstance().page, [])
const page = getCurrentInstance().page
const [nav] = useState(getMenuButtonBoundingClientRect())
const [isVisible, { toggle }] = useBoolean(false)
const [value, setValue] = useState<string>()
......@@ -23,7 +23,7 @@ const Group = () => {
}, [nav])
useDidShow(() => {
const tabbar = getTabBar(page) as any
const tabbar = getTabBar(page) as { setSelected: (index: number) => void }
tabbar?.setSelected(1)
})
......
......@@ -11,7 +11,7 @@ import { User } from '../../types'
import styles from './index.module.scss'
const ScrollRankList: React.FC<{ users: User[] }> = ({ users }) => {
const ScrollRankList = ({ users }: { users: User[]}) => {
const [showAll, toggleShowAll] = useToggle()
const { currentUser, currentUserInTopThree, topThreeUsers } = useStoreState((state) => state.prepareModel)
......
import React from 'react'
import { View, Text } from '@tarojs/components'
import { TimingProps } from '../../types'
// import { formatTime } from '../../utils'
import styles from './index.module.scss'
const Timing: React.FC<TimingProps> = ({ time = 0 }) => {
const Timing = ({ time = 0 }: TimingProps) => {
return (
<View className={styles.timing}>
<Text>34.23秒</Text>
......
import React from 'react'
import { View, Text } from '@tarojs/components'
import { UserInfoProps } from '../../types'
import styles from './index.module.scss'
const UserInfo: React.FC<UserInfoProps> = ({ avatar, nickname, schoolName }) => {
const UserInfo = ({ avatar, nickname, schoolName }: UserInfoProps) => {
return (
<View className={styles.userInfo}>
<View className={styles.avatar} />
......
......@@ -4,7 +4,7 @@ import ScrollRankList from './rank-list/index'
import { User } from '../types'
const StudyLeagueRank: React.FC<{ users: User[] }> = ({ users }) => {
const StudyLeagueRank = ({ users }: { users: User[] }) => {
return (
<View>
<ScrollRankList users={users} />
......
import { PropsWithChildren } from 'react'
import { View } from '@tarojs/components'
import classNames from 'classnames'
import Skeleton from '@/components/Skeleton'
......@@ -12,10 +13,9 @@ interface CardProps {
hoverable?: boolean;
extra?: React.ReactNode;
bodyStyle?: React.CSSProperties;
children?: React.ReactNode;
}
const Card: React.FC<CardProps> = ({
const Card = ({
title,
extra,
loading,
......@@ -23,8 +23,8 @@ const Card: React.FC<CardProps> = ({
hoverable,
headStyle,
bodyStyle,
children,
}) => {
children
}: PropsWithChildren<CardProps>) => {
const cardClass = classNames(styles.card, {
[styles.bordered]: bordered,
})
......
import { View, Text } from '@tarojs/components'
import ScoreStats from './score-stats'
const ChallengeFailed = () => {
return (
<View>
<Text>挑战失败</Text>
<ScoreStats />
</View>
)
}
export default ChallengeFailed
import { View, Text } from '@tarojs/components'
import ScoreStats from './score-stats'
const ChallengeFailed = () => {
return (
<View>
<Text>挑战成功</Text>
<ScoreStats />
</View>
)
}
export default ChallengeFailed
.glorys {
display: flex;
flex-direction: column;
.glory {
background-color: aqua;
transform: scaleX(0);
transform-origin: left;
opacity: 0;
transition: transform 2s, opacity 4s;
&.expanded {
transform: scaleX(1);
opacity: 1;
&:nth-child(1) {
transition-delay: 0.3s;
}
&:nth-child(2) {
transition-delay: 0.6s;
}
&:nth-child(3) {
transition-delay: 0.9s;
}
&:nth-child(4) {
transition-delay: 1.2s;
}
&:nth-child(5) {
transition-delay: 1.5s;
}
}
}
}
import { useState, useEffect } from 'react'
import { View, Text } from '@tarojs/components'
import classNames from 'classnames'
import styles from './glorys.module.scss'
const Glorys = () => {
const [activated, setActivated] = useState(false)
useEffect(() => {
const triggerAnimation = requestAnimationFrame(() => {
setActivated(true)
})
return () => {
cancelAnimationFrame(triggerAnimation)
}
}, [])
const cls = classNames(styles.glory, activated ? styles.expanded : '')
const result = {
score: 1,
ranking: 1,
isFirstTime: 1,
promoted: 1,
bonusPoints: 1,
selfRank: 1,
allRanks: 1,
}
return (
<View className={styles.glorys} >
<Text className={cls}>
成绩首次达成:{result.score}
</Text>
<Text className={cls}>
排名首次达成:{result.ranking}
</Text>
{result.isFirstTime
? (
<Text className={cls}>排名再次达成:{result.ranking}</Text>)
: (
<Text className={cls}>排名再次达成:{result.ranking}</Text>
)}
{result.promoted && <Text className={cls}>升档成功:{result.bonusPoints}积分</Text>}
{result.selfRank > 0 && (
<Text className={cls}>
排名:{result.selfRank}/{result.allRanks}
</Text>
)}
</View>
)
}
export default Glorys
@import '@/styles/mixins.scss';
.score_result {
position: relative;
}
.score {
position: absolute;
overflow: hidden;
}
.shrink {
animation: shrink 1s forwards;
}
.expand {
width: 0;
animation: expand 1s forwards;
}
@keyframes shrink {
0% {
width: 100%;
}
100% {
width: 0;
}
}
@keyframes expand {
0% {
width: 0;
}
100% {
width: 100%;
}
}
import { useState, useEffect } from 'react'
import { View, Text } from '@tarojs/components'
import classNames from 'classnames'
import styles from './score-result.module.scss'
interface ScoreResultProps {
score: string
}
const ScoreResult = ({ score }: ScoreResultProps) => {
const [prevScore, setPrevScore] = useState(score)
const [isAnimating, setIsAnimating] = useState(false)
useEffect(() => {
if (prevScore !== score) {
setIsAnimating(true)
setTimeout(() => {
setPrevScore(score)
setIsAnimating(false)
}, 1000)
}
}, [score])
return (
<View className={styles.score_result}>
<Text className={classNames(styles.score, isAnimating ? styles.shrink : '')}>{prevScore}</Text>
<Text className={classNames(styles.score, isAnimating ? styles.expand : '')}>{score}</Text>
</View>
)
}
export default ScoreResult
import { View, Text, Button } from '@tarojs/components'
const ScoreStats = ({ correctRate = 1, timeSpent = 2 }) => {
return (
<View className="score-stats">
<Text>正确率:{correctRate}%</Text>
<Text>耗时:{timeSpent}秒</Text>
</View>
)
}
export default ScoreStats
......@@ -2,36 +2,33 @@
display: flex;
flex-direction: column;
justify-content: space-between;
height: 100%;
.score {
font-size: 3rem;
font-weight: bold;
text-align: center;
&.zoom-in-animate {
animation: fade-zoom-in 1s ease-in-out;
}
}
.stats {
display: flex;
justify-content: space-between;
padding: 0 1rem;
}
.glorys {
display: flex;
flex-direction: column;
gap: 0.5rem;
padding: 0 1rem;
}
.continue-btn {
// height: 100%;
// position: relative;
// .score {
// font-size: 3rem;
// font-weight: bold;
// text-align: center;
// &.zoom-in-animate {
// animation: fade-zoom-in 1s ease-in-out;
// }
// }
// .stats {
// display: flex;
// justify-content: space-between;
// padding: 0 1rem;
// }
.continue_btn {
display: flex;
justify-content:
center;
justify-content: center;
padding-bottom: 1rem;
position: absolute;
bottom: 10%;
left: 0;
width: 100%;
}
}
......
......@@ -2,7 +2,13 @@ import React, { useState, useEffect } from 'react'
import { View, Text, Button } from '@tarojs/components'
import classNames from 'classnames'
import './index.scss'
import ChallengeFailed from './components/challenge-failed'
import ChallengeSuccess from './components/challenge-success'
import ScoreResult from './components/score-result'
import ScoreStats from './components/score-stats'
import Glorys from './components/glorys'
import styles from './index.module.scss'
interface ResultProps {
score: 'S' | 'A' | 'B';
......@@ -14,7 +20,7 @@ interface ResultProps {
onContinue: () => void;
}
const SummaryResult: React.FC<ResultProps> = ({
const SummaryResult = ({
score = 'B',
correctRate = '全队',
timeSpent = 30,
......@@ -22,52 +28,38 @@ const SummaryResult: React.FC<ResultProps> = ({
ranking,
promoted,
onContinue,
}) => {
const [result, setResult] = useState({ score, isFirstTime, ranking })
const [animateScore, setAnimateScore] = useState(false)
}: ResultProps) => {
const [result, setResult] = useState<any>({ score, isFirstTime, ranking })
const bonusPoints = 100
const selfRank = 100
const allRanks = 1000
useEffect(() => {
setAnimateScore(true)
setResult({ score, isFirstTime, ranking })
// setAnimateScore(true)
const timer = setTimeout(() => {
setAnimateScore(false)
}, 500)
// setResult({ score, isFirstTime, ranking })
return () => {
clearTimeout(timer)
}
}, [score, isFirstTime, ranking])
setTimeout(() => {
setResult({ score: 'A' })
}, 1000)
}, [])
return (
<View className="container">
<View className={classNames('score', { 'zoom-in-animate': animateScore })}>
<Text>{result.score}</Text>
</View>
<View className="stats">
<Text>正确率:{correctRate}%</Text>
<Text>耗时:{timeSpent}秒</Text>
</View>
<View className="glorys">
<Text>成绩首次达成:{result.score}</Text>
{result.isFirstTime
? (
<Text>排名首次达成:{result.ranking}</Text>
)
: (
<Text>排名再次达成:{result.ranking}</Text>
)}
{promoted && <Text>升档成功:{bonusPoints}积分</Text>}
{selfRank > 0 && (
<Text>
排名:{selfRank}/{allRanks}
</Text>
)}
</View>
<View className="continue-btn">
<View className={styles.container}>
{/* <ChallengeFailed>
<ChallengeSuccess>
<ScoreStats />
</ChallengeSuccess> */}
{/* <View className="score">
<ScoreResult score={result.score} />
</View> */}
{/* <ScoreStats /> */}
{/* <Glorys /> */}
<Text>!</Text>
<View className={styles.continue_btn}>
<Button onClick={onContinue}>继续</Button>
</View>
</View>
......
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