Commit 981cc69e authored by 666's avatar 666

feat: update

parent 14cd9484
......@@ -6,8 +6,8 @@
export default {
pages: [
'pages/prepare/index',
'pages/main/main',
'pages/prepare/index',
'pages/group/index',
'pages/study-market/index',
'pages/game/play/index',
......
@import '@/styles/mixins.scss';
.mask {
position: fixed;
left: 0;
top: 0;
bottom: 0;
right: 0;
background: rgba(0, 0, 0, 0.5);
z-index: 2000;
opacity: 0;
pointer-events: none;
transition: opacity .5s cubic-bezier(0.175,0.885,0.32,1.0);
&.visible {
opacity: 1;
pointer-events: all;
}
}
.modal {
position: fixed;
bottom: 0;
left: 0;
right: 0;
z-index: 2001;
background-color: #fff;
transform: translateY(100%);
transition: transform .5s cubic-bezier(0.175,0.885,0.32,1.0);
border-radius: 32px 32px 0px 0px;
text-align: center;
padding: 32PX 24PX;
&.visible {
transform: translateY(0);
}
.close {
position: absolute;
width: 20PX;
height: 20PX;
top: 12PX;
right: 24PX;
}
.title {
font-size: 24PX;
font-weight: 600;
color: #586170;
margin-bottom: 32px;
}
.tips {
font-size: 18PX;
font-weight: 400;
color: #586170;
margin-bottom: 24PX;
}
.footer {
@include flexLayout(column);
gap: 12PX;
.buy {
height: 56PX;
@include flexLayout(row, center, center);
background-size: 100% 100%;
background-image: url('../assets/btn-primary.png');
font-weight: 500;
}
.studyTribe {
@include flexLayout(row, center, center);
height: 56PX;
background-image: url('../assets/btn-border.png');
background-size: 100% 100%;
text-align: center;
font-size: 18PX;
font-weight: 500;
color: #1786F7;
}
}
}
import { PropsWithChildren } from 'react'
import { View, RootPortal, Image, Text } from '@tarojs/components'
import { switchTab } from '@tarojs/taro'
import classNames from 'classnames'
import styles from './answer-card-modal.module.scss'
type ModalProps = {
isVisible: boolean;
onClose: () => void;
}
const AnswerSheetModal = (props: PropsWithChildren<ModalProps>) => {
const { isVisible, children, onClose } = props
return (
<RootPortal>
<View className={classNames(styles.mask, isVisible && styles.visible)} onClick={onClose}>
</View>
<View className={classNames(styles.modal, isVisible && styles.visible)}>
<Image className={styles.close} onClick={onClose} src={require('../assets/close.png')} />
<View className={styles.title}>你的答题卡已经用完啦</View>
<View className={styles.tips}>可通过以下途径获得哦</View>
<View className={styles.footer}>
<View className={styles.buy}>{children}</View>
<View className={styles.studyTribe} onClick={() => switchTab({ url: '/pages/group/index' })}>
<Text>建设学习部落,得更多答题卡</Text>
</View>
</View>
</View>
</RootPortal>
)
}
export default AnswerSheetModal
import { View, Text } from '@tarojs/components'
export default () => {
return (
<View>
<View>
<Text>名次</Text>
<Text>用户名</Text>
<View>
<Text>首次</Text>
<Text>|</Text>
<Text>最佳</Text>
</View>
</View>
</View>
)
}
.wrapper {
display: flex;
flex-direction: column;
}
.head {
display: flex;
justify-content: flex-end;
&_text {
width: 160px;
text-align: center;
}
}
.timing {
min-width: 320px;
display: flex;
align-items: center;
Text {
flex: 1;
text-align: center;
}
}
.list {
min-height: 300px;
max-height: 400px;
overflow: hidden;
overflow-y: auto;
display: flex;
flex-direction: column;
row-gap: 24px;
}
.item {
padding: 16px 0;
display: flex;
justify-content: space-between;
}
.highlight {
background-color: yellow;
}
.noTopThree {
border: 1px solid red;
margin: 24px 0;
}
.userInfo {
display: flex;
column-gap: 16px;
}
.avatar {
width: 60px;
height: 60px;
border-radius: 50%;
background-color: pink;
}
.userDetails {
display: flex;
flex-direction: column;
row-gap: 16px;
line-height: 1;
}
\ No newline at end of file
import { View, Button, Text, ScrollView } from '@tarojs/components'
import classNames from 'classnames'
import { useStoreState } from '@/store/hooks'
import { useBoolean } from '@/hooks'
import { StageRank } from '@/api/game'
import styles from './index.module.scss'
interface ScrollListProps<T> {
users: T[]
}
const ScrollRankList = <T extends StageRank>({ users }: ScrollListProps<T>) => {
const [showAll, { toggle }] = useBoolean(false)
const currentUser = useStoreState((state) => state.userModel.userInfo)
const renderItem = (rank: T) => {
const isCurrentUser = currentUser.userId === rank.userId
const itemClass = classNames(styles.item, {
[styles.highlight]: isCurrentUser,
})
return (
<View key={rank.userId} className={itemClass}>
<View className={styles.userInfo}>
<View className={styles.avatar} />
{/* <Image className='avatar' src={avatar} /> */}
<View className={styles.userDetails}>
<Text className="nickname">{rank.nickName}</Text>
<Text className="school">{rank.secondName}</Text>
</View>
</View>
<View className={styles.timing}>
<Text>{rank.firstResultTime}秒</Text>
<Text>{rank.bestResultTime}秒</Text>
</View>
</View >
)
}
// const hasNextPage = true
// const loading = false
// const computedUsers = showAll ? users : topThreeUsers
const scrollStyle = {
height: '400px',
background: 'red'
}
const loadMore = () => {
console.log('loadMore')
}
return (
<View className={styles.wrapper}>
<View className={styles.header}>
<Text className={styles.header_text}>首次</Text>
<Text className={styles.header_text}>最佳</Text>
</View>
{currentUser.userId && renderItem(currentUser as T)}
<ScrollView
scrollY
enableFlex
scrollWithAnimation
style={scrollStyle}
onScrollToLower={loadMore}
>
<View style={{ height: '300px' }}>A</View>
<View style={{ height: '300px' }}>B</View>
<View style={{ height: '300px' }}>C</View>
{/* {hasNextPage && !loading && <Text>加载更多</Text>} */}
</ScrollView>
<View className={styles.list}>
{[].map(renderItem)}
</View>
{!showAll && (
<Button className={styles.loadMore} onClick={() => toggle()}>
查看更多
</Button>
)}
</View>
)
}
export default ScrollRankList
import { View, Text } from '@tarojs/components'
import { TimingProps } from '../../types'
// import { formatTime } from '../../utils'
import styles from './index.module.scss'
const Timing = ({ time = 0 }: TimingProps) => {
return (
<View className={styles.timing}>
<Text>34.23秒</Text>
<Text>21.23秒</Text>
</View>
)
}
export default Timing
import { View, Text } from '@tarojs/components'
import { UserInfoProps } from '../../types'
import styles from './index.module.scss'
const UserInfo = ({ avatar, nickname, schoolName }: UserInfoProps) => {
return (
<View className={styles.userInfo}>
<View className={styles.avatar} />
{/* <Image className='avatar' src={avatar} /> */}
<View className={styles.userDetails}>
<Text className="nickname">{nickname}</Text>
<Text className="school">{schoolName}</Text>
</View>
</View>
)
}
export default UserInfo
import { View, Text } from '@tarojs/components'
import { StageRank } from '@/api/game'
import ScrollRankList from './rank-list/index'
const StudyLeagueRank = <T extends StageRank>({ users }: { users: T[] }) => {
return (
<View>
<ScrollRankList<T> users={users} />
<Text>立即创建</Text>
</View>
)
}
export default StudyLeagueRank
......@@ -4,6 +4,7 @@
width: 100%;
flex-direction: column;
z-index: 999;
overflow: visible;
}
.tabBar {
......@@ -57,14 +58,13 @@
background-color: #fff;
position: relative;
top: -40PX;
height: 100%;
margin-bottom: -40PX;
.tabPane {
height: auto;
grid-row: 1;
grid-column: 1;
transition: transform 0.3s ease-in-out;
will-change: transform;
pointer-events: none;
&.active {
......
import { View, Image } from '@tarojs/components'
import { useMemo } from 'react'
import { getMenuButtonBoundingClientRect, getSystemInfoSync } from '@tarojs/taro'
import { getMenuButtonBoundingClientRect, navigateBack, getSystemInfoSync } from '@tarojs/taro'
import styles from './top-bar.module.scss'
......@@ -26,7 +26,7 @@ export default () => {
}}
>
<View className={styles.inner} style={innerStyle}>
<Image className={styles.back_icon} src={require('../assets/back.png')} mode="widthFix" />
<Image className={styles.back_icon} src={require('../assets/back.png')} mode="widthFix" onClick={() => navigateBack()} />
</View>
</View>
</View>
......
......@@ -14,6 +14,13 @@
}
}
.empty {
color: #9999;
font-size: 12PX;
margin-top: 12PX;
text-align: center;
}
.item {
display: flex;
padding: 28px 32px 26px;
......@@ -79,8 +86,62 @@
z-index: 999;
&_text {
font-size: 40px;
letter-spacing: 2PX;
letter-spacing: 1PX;
font-weight: 600;
}
.card {
@include flexLayout(row, center);
position: absolute;
right: 100px;
gap: 4PX;
&_icon {
width: 32PX;
height: 32PX
}
&_text {
font-size: 18PX;
font-weight: 500;
color: #FFFFFF;
}
}
.tip {
position: absolute;
top: -32PX;
right: -9PX;
padding: 8PX 13PX 12PX;
background-image: url('https://cdn.jkwljy.com/pk-math/4WgogFzhSYUSrvpmEE7JwoVg7SH5/122x42');
background-size: 100% 100%;
&_text {
font-size: 16PX;
font-weight: 500;
color: #FFFFFF;
}
}
}
}
.modal {
@include flexLayout(row, center, center);
font-size: 18PX;
font-weight: 500;
color: #FFFFFF;
& > {
.logo {
width: 32PX;
height: 32PX;
margin-right: 4PX;
}
.buy {
margin: 0 12PX;
}
.balance {
font-weight: 400;
font-size: 14PX;
}
}
}
import { View, Text, Image } from '@tarojs/components'
import { useEffect } from 'react'
import { useStoreState, useStoreActions } from '@/store/hooks'
import { useRouter, getMenuButtonBoundingClientRect } from '@tarojs/taro'
import { useStoreState, useStoreActions } from '@/store/hooks'
import { useBoolean } from '@/hooks'
import { type StageRank } from '@/api/game'
import Button from '@/components/Button'
import assets from '@/assets/oss/assets-prepare'
import Button from '@/components/Button'
import Tabs, { type TabItem } from './components/tabs'
import TopBar from './components/top-bar'
import MainHeader from './components/main-header'
import Thead from './components/thead'
import AnswerCardModal from './components/answer-card-modal'
import styles from './index.module.scss'
......@@ -37,6 +40,7 @@ const renderItem = (item: StageRank, index: number) => {
const Prepare = () => {
const nav = getMenuButtonBoundingClientRect()
const [isVisible, { setTrue, setFalse }] = useBoolean(false)
const stageDetail = useStoreState(state => state.gameModel.stageDetail)
const getStageDetail = useStoreActions(actions => actions.gameModel.getStageDetail)
......@@ -47,14 +51,22 @@ const Prepare = () => {
getStageDetail(+router.params.id || 1)
}, [router, getStageDetail])
const renderList = (list = []) => {
const isEmpty = list.length < 1
return (
<>
<Thead />
{list.map(renderItem)}
{isEmpty && <View className={styles.empty}>暂无数据</View>}
</>
)
}
const tabs: TabItem[] = [
{
label: '成都排行榜',
children: (
<>
<Thead />
{[].map(renderItem)}
</>
<>{renderList()}</>
)
},
{
......@@ -62,28 +74,45 @@ const Prepare = () => {
children: (
<View className={styles.tribe}>
<Text className={styles.tribe_title}>极客学霸俱乐部</Text>
<Thead />
{[].map(renderItem)}
{renderList()}
</View>
)
}
]
return (
<>
<View className={styles.wrapper}>
<TopBar />
<View style={{ paddingTop: `${nav.height + nav.top + 5}px` }}>
<View style={{ position: 'relative', paddingTop: `${nav.height + nav.top + 5}px` }}>
<MainHeader />
<Tabs initialIndex={1} items={tabs} />
<Tabs items={tabs} />
</View>
<View className={styles.challenge}>
<Button type="custom" size="large">
<Button type="custom" size="large" onClick={setTrue}>
<Text className={styles.challenge_text}>开始闯关</Text>
<View className={styles.card}>
<Image className={styles.card_icon} src={require('@/pages/main/assets/ph.png')} />
<Text className={styles.card_text}>-1</Text>
</View>
{false && <View className={styles.tip}>
<Text className={styles.tip_text}>首次免答题卡</Text>
</View>}
</Button>
</View>
</View>
<AnswerCardModal isVisible={isVisible} onClose={setFalse}>
<View className={styles.modal}>
<Image className={styles.logo} src={assets['diamond.png'].u} mode="widthFix" />
<Text>-30</Text>
<Text className={styles.buy}>购买</Text>
<Text className={styles.balance}>(当前剩余 120)</Text>
</View>
</AnswerCardModal>
</>
)
}
......
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