Commit 7e292b95 authored by hewenhao's avatar hewenhao

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

parents a8d1dc29 a97f761d
......@@ -20,9 +20,9 @@
pointer-events: auto;
}
.inner {
.body {
background-color: #ffffff;
padding: 16px;
border-radius: 4px;
border-radius: 8PX;
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}
\ No newline at end of file
......@@ -4,10 +4,12 @@ import classNames from 'classnames'
import styles from './index.module.scss'
interface ModalProps {
isVisible: unknown;
isVisible: boolean;
wrapClassName?: string;
bodyClassName?: string;
children: React.ReactNode;
maskClosable?: boolean;
coverNavigateBar?: boolean;
onClose?: () => void;
}
......@@ -16,6 +18,8 @@ const Modal: React.FC<ModalProps> = ({
onClose,
children,
wrapClassName,
bodyClassName,
coverNavigateBar = true, // z-index 层级高于原生的bar
maskClosable = true
}) => {
const wrapClass = classNames(styles.wrapper, wrapClassName, {
......@@ -23,8 +27,12 @@ const Modal: React.FC<ModalProps> = ({
})
return (
<View className={wrapClass} onClick={() => maskClosable && onClose?.()}>
<View className={classNames(styles.inner)} onClick={(e) => e.stopPropagation()}>
<View
className={wrapClass}
style={{ zIndex: coverNavigateBar ? 10001 : 100 }}
onClick={() => maskClosable && onClose?.()}
>
<View className={classNames(styles.body, bodyClassName)} onClick={(e) => e.stopPropagation()}>
{children}
</View>
</View>
......
......@@ -26,7 +26,7 @@ interface Result<T, P> {
updateData: (newData: T) => void;
}
export default function useRequest<T = unknown, P = unknown> (
export function useRequest<T = unknown, P = unknown> (
service: (params?: P) => Promise<T>,
options: Options<T, P>
): Result<T, P> {
......
......@@ -5,7 +5,7 @@ interface UseToggleOptions {
initialValue?: ToggleValue;
reverseValue?: ToggleValue;
}
export default function useToggle ({
export function useToggle ({
initialValue = false,
reverseValue = !initialValue,
}: UseToggleOptions = {}) {
......
@import '@/styles/mixins.scss';
.container {
@include flexLayout(column);
.header {
flex-grow: 1;
@include flexLayout(column, center, center);
.logo {
width: 120px;
height: 120px;
}
.title {
font-weight: bold;
margin-top: 16px;
}
.subtitle {
margin-top: 8px;
}
}
.content {
flex-grow: 1;
@include flexLayout(column, center, center);
.promotion {
font-weight: bold;
margin-bottom: 16px;
}
.features {
@include flexLayout(_, _, space-between);
width: 100%;
.leader, .rewards, .members {
@include flexLayout(column, center);
width: 33%;
}
}
}
.more {
margin-bottom: 16px;
text-align: center;
}
.create {
position: absolute;
width: 100%;
left: 0;
bottom: 10%;
&_btn {
width: 80%;
background-color: #1976D2;
color: #ffffff;
padding: 8px 16px;
border-radius: 4px;
}
}
}
import { View, Button, Text, Image } from '@tarojs/components'
import styles from './creator.module.scss'
const Creator = ({ onClick }: { onClick: () => void }) => {
return (
<View className={styles.container}>
<View className={styles.header}>
<Image className={styles.logo} src="https://cdn.jkwljy.com/pbb/6gkGHSsPmxc_coeGYahBkelo_2w_/96x96" />
<Text className={styles.title}>学习部落</Text>
<Text className={styles.subtitle}>我的学习,我做主</Text>
</View>
<View className={styles.content}>
<Text className={styles.promotion}>组建你的部落,福利多多</Text>
<View className={styles.features}>
<View className={styles.leader}>
<Text>部落族长 与众不同</Text>
<Text>专属族长勋章与特权</Text>
</View>
<View className={styles.rewards}>
<Text>壮大部落 奖励多多</Text>
<Text>每邀请一人加入 +100 水晶</Text>
</View>
<View className={styles.members}>
<Text>部落有多少成员</Text>
<Text>每天就得多少颗</Text>
</View>
</View>
</View>
<Text className={styles.more}>还有更多福利等待解锁...</Text>
<View className={styles.create}>
<Button className={styles.create_btn} onClick={onClick}>
立即创建你的部落+20⭐
</Button>
</View>
</View>
)
}
export default Creator
@import '@/styles/mixins.scss';
.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;
@include flexLayout(column, center, center);
gap: 16px;
&_btn {
width: 80%;
background-color: #1976D2;
color: #ffffff;
padding: 8px 16px;
border-radius: 4px;
}
}
}
\ 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 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)
const onRefresh = () => {
setTrue()
setTimeout(() => {
setFalse()
}, 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>
<ScrollView
scrollY
scrollWithAnimation
refresherEnabled
refresherTriggered={isRefresh}
onRefresherRefresh={onRefresh}
style={{ height: scrollHeight }}
>
<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>
</ScrollView>
<View className={classNames(styles.invite_members, membersCls)}>
<Button className={styles.invite_members_btn}>邀请人加入部落 +5答题卡</Button>
<Text>赠送朋友5张答题卡,一起来进击</Text>
<Text>好友进入小程序通关1关+5</Text>
</View>
</View>
)
}
export default Members
export default definePageConfig({
navigationBarTitleText: 'pk-math',
navigationStyle: 'custom'
})
@import '@/styles/mixins.scss';
.modal {
padding: 12PX 24PX;
&_label {
color: #333;
margin-bottom: 8px;
}
&_input {
@include flexLayout(_, center, center);
padding: 8px;
border-radius: 4px;
gap: 12PX;
Input {
flex-grow: 1;
border: 1PX solid blue;
border-radius: 6PX;
text-align: center;
outline: none;
padding: 4PX 6PX;
width: 160px;
background-color: transparent;
}
Text {
color: #999;
}
}
}
import { View } from '@tarojs/components'
import { useDidShow, getCurrentInstance, getTabBar } from '@tarojs/taro'
import { useMemo } from 'react'
import { View, Text, Input } from '@tarojs/components'
import { useDidShow, getCurrentInstance, getTabBar, getMenuButtonBoundingClientRect } from '@tarojs/taro'
import { useMemo, useState } from 'react'
import Modal from '@/components/Modal'
import { useBoolean } from '@/hooks/use-boolean'
import MainHeader from '../main/components/header'
import Creator from './components/creator'
import Members from './components/members'
import styles from './index.module.scss'
const Group = () => {
const page = useMemo(() => getCurrentInstance().page, [])
const [nav] = useState(getMenuButtonBoundingClientRect())
const [isVisible, { toggle }] = useBoolean(false)
const [value, setValue] = useState<string>()
const isCreator = false
const tabBarHeight = useMemo(() => {
return nav.height + nav.top + 5
}, [nav])
useDidShow(() => {
const tabbar = getTabBar(page) as any
tabbar?.setSelected(1)
})
return (
<View>group</View>
<View>
<MainHeader />
<View style={{ paddingTop: `${tabBarHeight}px` }}>
{isCreator ? <Creator onClick={toggle} /> : <Members tabBarHeight={tabBarHeight} />}
</View>
<Modal isVisible={isVisible} onClose={toggle}>
<View className={styles.modal}>
<Text className={styles.modal_label}>学习部落名:</Text>
<View className={styles.modal_input}>
<Input value={value} placeholder="请输入" placeholderStyle="color: #999" onInput={(e) => setValue(e.detail.value)} />
<Text>学习帮</Text>
</View>
</View>
</Modal>
</View>
)
}
......
import { memo } from 'react'
import { View, Text } from '@tarojs/components'
import Taro from '@tarojs/taro'
import useRequest from '@/hooks/use-request'
import { useRequest } from '@/hooks/use-request'
import TopLeftInfo from './top-left-info'
import LaunchQuest from './launch-quest'
......
import React from 'react'
import { View, Text, Button } from '@tarojs/components'
// import Taro from '@tarojs/taro'
import Modal from '@/components/Modal'
import useToggle from '@/hooks/use-toggle'
import { useToggle } from '@/hooks/use-toggle'
import styles from './index.module.scss'
const LaunchQuest: React.FC = () => {
const [isVisible, toggleModal] = useToggle()
const navigateTo = () => {
toggleModal(false)
// Taro.navigateTo('/')
}
return (
<>
<View className={styles.launchQuest}>
<Button onClick={() => toggleModal(true)}>开始闯关</Button>
<Button onClick={navigateTo}>开始闯关</Button>
<Text className={styles.tip}>
首次免答题卡
{/* {hasFreePass ? '首次免答题卡' : '-1答题卡'} */}
......
......@@ -2,7 +2,7 @@ import { View, Button, Text, ScrollView } from '@tarojs/components'
import { memo } from 'react'
import classNames from 'classnames'
import { useStoreState } from '@/store/hooks'
import useToggle from '@/hooks/use-toggle'
import { useToggle } from '@/hooks/use-toggle'
import UserInfo from './user-info'
import Timing from './timing'
......
@import '@/styles/mixins.scss';
.breakthrough {
@include flexLayout(_, center, space-around);
}
\ No newline at end of file
import { Button, View } from '@tarojs/components'
import { useEffect } from 'react'
import Tabs, { type TabItem } from '@/components/Tabs'
import { useStoreState, useStoreActions } from '@/store/hooks'
......@@ -6,6 +7,8 @@ import Overview from './components/overview/index'
import ScrollRankList from './components/rank-list/index'
import StudyLeagueRank from './components/study-league-rank'
import styles from './index.module.scss'
const Prepare: React.FC = () => {
const { list: users } = useStoreState((state) => state.prepareModel)
const refresh = useStoreActions((actions) => actions.prepareModel.refresh)
......@@ -20,10 +23,14 @@ const Prepare: React.FC = () => {
]
return (
<>
<View>
<Overview />
<Tabs items={tabs} />
</>
<View className={styles.breakthrough}>
<Button>继续闯关</Button>
<Button>再次努力,变得更棒</Button>
</View>
</View>
)
}
......
import { View, Text, Button } from '@tarojs/components'
import Modal from '@/components/Modal'
import useToggle from '@/hooks/use-toggle'
import { useBoolean } from '@/hooks/use-boolean'
import CardMain from './card-main'
const AnswerSheet: React.FC = () => {
const [isVisible, toggleModal] = useToggle()
const [isVisible, { toggle }] = useBoolean(false)
const onClick = () => {
toggleModal(false)
toggle()
}
return (
......@@ -17,9 +17,9 @@ const AnswerSheet: React.FC = () => {
title="答题卡"
subtitle="答题卡是不断追求更高档位与排名的必备道具答题卡是不断追求更高档位与排名的必备道具"
extra={<Text className="card-stock">本月库存10</Text>}
onClick={() => toggleModal(true)}
onClick={toggle}
/>
<Modal isVisible={isVisible} onClose={() => toggleModal(false)}>
<Modal isVisible={isVisible} onClose={toggle}>
<View>
<Text>兑换几张</Text>
<Button size="mini" onClick={onClick}>兑换</Button>
......
import { View, Text, Button } from '@tarojs/components'
import { View, Text, Button, Input } from '@tarojs/components'
import Modal from '@/components/Modal'
import useToggle from '@/hooks/use-toggle'
import { useBoolean } from '@/hooks/use-boolean'
import CardMain from './card-main'
const MysteryBox = () => {
const [isVisible, toggleModal] = useToggle()
const [isVisible, { toggle }] = useBoolean(false)
const onClick = () => {
toggleModal(false)
toggle()
}
return (
......@@ -17,10 +17,11 @@ const MysteryBox = () => {
title="神秘大礼"
subtitle="兑换神秘大礼,线下领取超级大礼"
extra={<Text className="card-stock">本月库存10</Text>}
onClick={() => toggleModal(true)}
onClick={toggle}
/>
<Modal isVisible={isVisible} onClose={() => toggleModal(false)}>
<Modal isVisible={isVisible} onClose={toggle}>
<View>
<Input type="number" />
<Text>兑换礼物</Text>
<Button size="mini" onClick={onClick}>兑换</Button>
</View>
......
.container {
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 {
display: flex;
justify-content:
center;
padding-bottom: 1rem;
}
}
@keyframes fade-zoom-in {
0% {
transform: scale(1);
opacity: 1;
}
50% {
transform: scale(1.5);
opacity: 0.5;
}
100% {
transform: scale(1);
opacity: 1;
}
}
\ No newline at end of file
import React, { useState, useEffect } from 'react'
import { View, Text, Button } from '@tarojs/components'
import classNames from 'classnames'
import './index.scss'
interface ResultProps {
score: 'S' | 'A' | 'B';
correctRate: string;
timeSpent: number;
isFirstTime: boolean;
ranking: number;
promoted: boolean;
onContinue: () => void;
}
const SummaryResult: React.FC<ResultProps> = ({
score = 'B',
correctRate = '全队',
timeSpent = 30,
isFirstTime,
ranking,
promoted,
onContinue,
}) => {
const [result, setResult] = useState({ score, isFirstTime, ranking })
const [animateScore, setAnimateScore] = useState(false)
const bonusPoints = 100
const selfRank = 100
const allRanks = 1000
useEffect(() => {
setAnimateScore(true)
setResult({ score, isFirstTime, ranking })
const timer = setTimeout(() => {
setAnimateScore(false)
}, 500)
return () => {
clearTimeout(timer)
}
}, [score, isFirstTime, ranking])
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">
<Button onClick={onContinue}>继续</Button>
</View>
</View>
)
}
export default SummaryResult
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