Commit f04517f1 authored by hewenhao's avatar hewenhao

Merge branch 'master' of dev.jiuaoedu.com:hewenhao/GeekLearnMathWeapp

parents b5ddd076 b5b7e712
...@@ -4,11 +4,11 @@ import classNames from 'classnames' ...@@ -4,11 +4,11 @@ import classNames from 'classnames'
import styles from './index.module.scss' import styles from './index.module.scss'
interface ModalProps { interface ModalProps {
isVisible: boolean; isVisible: unknown;
wrapClassName?: string; wrapClassName?: string;
children: React.ReactNode; children: React.ReactNode;
maskClosable?: boolean; maskClosable?: boolean;
onClose: () => void; onClose?: () => void;
} }
const Modal: React.FC<ModalProps> = ({ const Modal: React.FC<ModalProps> = ({
...@@ -18,13 +18,12 @@ const Modal: React.FC<ModalProps> = ({ ...@@ -18,13 +18,12 @@ const Modal: React.FC<ModalProps> = ({
wrapClassName, wrapClassName,
maskClosable = true maskClosable = true
}) => { }) => {
const wrapClass = classNames( const wrapClass = classNames(styles.wrapper, wrapClassName, {
styles.wrapper, [styles.visible]: isVisible
wrapClassName, })
isVisible ? styles.visible : ''
)
return ( return (
<View className={wrapClass} onClick={() => maskClosable && onClose()}> <View className={wrapClass} onClick={() => maskClosable && onClose?.()}>
<View className={classNames(styles.inner)} onClick={(e) => e.stopPropagation()}> <View className={classNames(styles.inner)} onClick={(e) => e.stopPropagation()}>
{children} {children}
</View> </View>
......
.skeleton { .skeleton {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
margin: 8px 16px;
gap: 16px; gap: 16px;
&-avatar { &-avatar {
......
...@@ -8,7 +8,7 @@ import SkeletonParagraph, { type SkeletonParagraphProps } from './components/par ...@@ -8,7 +8,7 @@ import SkeletonParagraph, { type SkeletonParagraphProps } from './components/par
import './index.scss' import './index.scss'
interface SkeletonProps { interface SkeletonProps {
loading: boolean; loading?: boolean;
animate?: boolean; animate?: boolean;
avatar?: SkeletonAvatarProps | boolean; avatar?: SkeletonAvatarProps | boolean;
title?: SkeletonTitleProps | boolean; title?: SkeletonTitleProps | boolean;
......
import { View, Button, Text, ScrollView } from '@tarojs/components' import { View, Button, Text, ScrollView } from '@tarojs/components'
import { memo, useMemo } from 'react' import { memo } from 'react'
import classNames from 'classnames' import classNames from 'classnames'
import { useStoreState } from '@/store/hooks' import { useStoreState } from '@/store/hooks'
import useToggle from '@/hooks/useToggle' import useToggle from '@/hooks/useToggle'
...@@ -28,12 +28,7 @@ const ScrollRankList: React.FC<{ users: User[] }> = ({ users }) => { ...@@ -28,12 +28,7 @@ const ScrollRankList: React.FC<{ users: User[] }> = ({ users }) => {
const hasNextPage = true const hasNextPage = true
const loading = false const loading = false
const computedUsers = useMemo(() => { const computedUsers = showAll ? users : topThreeUsers
if (showAll) {
return users
}
return topThreeUsers
}, [showAll, users, topThreeUsers])
const scrollStyle = { const scrollStyle = {
height: '400px', height: '400px',
......
// export default definePageConfig({
// navigationBarTitleText: 'pk-math',
// navigationStyle: 'custom'
// })
import { useEffect } from 'react' import { useEffect } from 'react'
import Tabs, { type TabItem } from '@/components/Tabs' import Tabs, { type TabItem } from '@/components/Tabs'
import Skeleton from '@/components/Skeleton'
import { useStoreState, useStoreActions } from '@/store/hooks' import { useStoreState, useStoreActions } from '@/store/hooks'
import Overview from './components/overview/index' import Overview from './components/overview/index'
......
import { View, Text, Button } from '@tarojs/components'
import Modal from '@/components/Modal'
import useToggle from '@/hooks/useToggle'
import CardMain from './card-main'
const AnswerSheet: React.FC = () => {
const [isVisible, toggleModal] = useToggle()
const onClick = () => {
toggleModal(false)
}
return (
<View className="card-body">
<CardMain
title="答题卡"
subtitle="答题卡是不断追求更高档位与排名的必备道具答题卡是不断追求更高档位与排名的必备道具"
extra={<Text className="card-stock">本月库存10</Text>}
onClick={() => toggleModal(true)}
/>
<Modal isVisible={isVisible} onClose={() => toggleModal(false)}>
<View>
<Text>兑换几张</Text>
<Button size="mini" onClick={onClick}>兑换</Button>
</View>
</Modal>
</View>
)
}
export default AnswerSheet
import { View, Image, Text, Button } from '@tarojs/components'
interface CardMainProps {
onClick: () => void;
cover?: string;
title: string;
subtitle: string;
extra?: React.ReactNode
}
export default ({
title,
cover = '',
extra,
subtitle,
onClick,
}: CardMainProps) => {
return (
<>
<View className="card-main">
<Image className="card-image" src={cover} defaultSource="https://cdn.jkwljy.com/pbb/6gkGHSsPmxc_coeGYahBkelo_2w_/96x96" />
{extra}
</View>
<View className="card-action">
<View className="card-description">
<Text className="card-title">{title}</Text>
<Text className="card-subtitle">{subtitle}</Text>
</View>
<View className="card-footer">
<View className="card-score">
<Image src={require('../../main/assets/score.png')} className="card-score-icon" />
<Text className="card-score-text">积分271</Text>
</View>
<Button className="card-exchange" onClick={onClick}>兑换</Button>
</View>
</View>
</>
)
}
.card {
position: relative;
background-color: #fff;
margin-bottom: 12PX;
padding: 12PX;
}
.bordered {
border: 1px solid #f0f0f0;
}
.hoverable {
&:hover {
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}
}
.head {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 8PX;
}
.title {
font-weight: 500;
}
import { View } from '@tarojs/components'
import classNames from 'classnames'
import Skeleton from '@/components/Skeleton'
import styles from './card.module.scss'
interface CardProps {
bordered?: boolean;
headStyle?: React.CSSProperties;
loading?: boolean;
title?: React.ReactNode;
hoverable?: boolean;
extra?: React.ReactNode;
bodyStyle?: React.CSSProperties;
children?: React.ReactNode;
}
const Card: React.FC<CardProps> = ({
title,
extra,
loading,
bordered,
hoverable,
headStyle,
bodyStyle,
children,
}) => {
const cardClass = classNames(styles.card, {
[styles.bordered]: bordered,
})
return (
<View className={cardClass} hoverClass={hoverable && styles.hoverable}>
{(title || extra) && (
<View className={styles.head} style={headStyle}>
{title && <View className={styles.title}>{title}</View>}
{extra && <View className={styles.extra}>{extra}</View>}
</View>
)}
<View className={styles.body} style={bodyStyle}>
<Skeleton loading={loading} avatar>
{children}
</Skeleton>
</View>
</View>
)
}
export default Card
import { View, Text, Button } from '@tarojs/components'
import Modal from '@/components/Modal'
import useToggle from '@/hooks/useToggle'
import CardMain from './card-main'
const MysteryBox = () => {
const [isVisible, toggleModal] = useToggle()
const onClick = () => {
toggleModal(false)
}
return (
<View className="card-body">
<CardMain
title="神秘大礼"
subtitle="兑换神秘大礼,线下领取超级大礼"
extra={<Text className="card-stock">本月库存10</Text>}
onClick={() => toggleModal(true)}
/>
<Modal isVisible={isVisible} onClose={() => toggleModal(false)}>
<View>
<Text>兑换礼物</Text>
<Button size="mini" onClick={onClick}>兑换</Button>
</View>
</Modal>
</View>
)
}
export default MysteryBox
@import '../../styles/mixins.scss';
.wrapper {
padding: 16px;
}
.card-body {
display: flex;
padding: 12PX;
position: relative;
border: 1px solid red;
.card-main {
@include flexLayout(column, _, space-between);
min-width: 160px;
margin-right: 12PX;
.card-image {
width: 100%;
height: 180px;
background-color: #000;
}
.card-stock {
color: #666;
font-size: 14PX;
text-align: center;
}
}
.card-action {
@include flexLayout(column, center, space-between);
flex-grow: 1;
.card-description {
flex-grow: 1;
@include flexLayout(column, _, space-between);
.card-title {
color: #333;
font-weight: 500;
margin-bottom: 8px;
}
.card-subtitle {
color: #666;
@include multi-ellipsis(2);
}
}
.card-footer {
width: 100%;
margin-top: 48px;
@include flexLayout(_, _, space-between);
.card-score {
@include flexLayout(_, center);
&-icon {
width: 32PX;
height: 32PX;
margin-right: 4px;
}
&-text {
color: #666;
margin-right: 8px;
}
}
.card-exchange {
@include btn();
}
}
}
}
\ No newline at end of file
import { useState, useEffect } from 'react' import { useState } from 'react'
import Taro, { getMenuButtonBoundingClientRect } from '@tarojs/taro' import { getMenuButtonBoundingClientRect } from '@tarojs/taro'
import { View } from '@tarojs/components' import { View } from '@tarojs/components'
import Skeleton from '@/components/Skeleton'
import MainHeader from '../main/components/header' import MainHeader from '../main/components/header'
import Card from './components/card'
import AnswerSheet from './components/answer-sheet'
import MysteryBox from './components/mystery-box'
import './index.scss'
const StudyMarket: React.FC = () => { const StudyMarket: React.FC = () => {
const [nav] = useState(getMenuButtonBoundingClientRect()) const [nav] = useState(getMenuButtonBoundingClientRect())
const paddingTop = `${nav.height + nav.top + 5}px`
Taro.showLoading({
title: '加载中',
mask: true
})
return ( return (
<View> <View className="wrapper">
<MainHeader /> <MainHeader />
<View style={{ paddingTop: `${nav.height + nav.top + 5}px` }}> <View style={{ paddingTop }}>
<Skeleton loading /> <Card hoverable loading title="答题卡">
<AnswerSheet />
</Card>
<Card hoverable title="月度神秘大礼">
<MysteryBox />
</Card>
</View> </View>
</View> </View>
) )
......
...@@ -57,8 +57,9 @@ ...@@ -57,8 +57,9 @@
text-overflow: ellipsis; text-overflow: ellipsis;
} }
@mixin flexLayout($direction: row, $align: stretch) { @mixin flexLayout($direction: row nowrap, $align: stretch, $justify: flex-start) {
display: flex; display: flex;
flex-flow: $direction; flex-flow: $direction;
align-items: $align; align-items: $align;
justify-content: $justify;
} }
\ No newline at end of file
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