Commit 0f55888f authored by 666's avatar 666

feat: update

parent 16e32661
...@@ -20,9 +20,9 @@ ...@@ -20,9 +20,9 @@
pointer-events: auto; pointer-events: auto;
} }
.inner { .body {
background-color: #ffffff; background-color: #ffffff;
padding: 16px; padding: 16px;
border-radius: 4px; border-radius: 8PX;
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1); 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' ...@@ -4,10 +4,12 @@ import classNames from 'classnames'
import styles from './index.module.scss' import styles from './index.module.scss'
interface ModalProps { interface ModalProps {
isVisible: unknown; isVisible: boolean;
wrapClassName?: string; wrapClassName?: string;
bodyClassName?: string;
children: React.ReactNode; children: React.ReactNode;
maskClosable?: boolean; maskClosable?: boolean;
coverNavigateBar?: boolean;
onClose?: () => void; onClose?: () => void;
} }
...@@ -16,6 +18,8 @@ const Modal: React.FC<ModalProps> = ({ ...@@ -16,6 +18,8 @@ const Modal: React.FC<ModalProps> = ({
onClose, onClose,
children, children,
wrapClassName, wrapClassName,
bodyClassName,
coverNavigateBar = true, // z-index 层级高于原生的bar
maskClosable = true maskClosable = true
}) => { }) => {
const wrapClass = classNames(styles.wrapper, wrapClassName, { const wrapClass = classNames(styles.wrapper, wrapClassName, {
...@@ -23,8 +27,12 @@ const Modal: React.FC<ModalProps> = ({ ...@@ -23,8 +27,12 @@ const Modal: React.FC<ModalProps> = ({
}) })
return ( return (
<View className={wrapClass} onClick={() => maskClosable && onClose?.()}> <View
<View className={classNames(styles.inner)} onClick={(e) => e.stopPropagation()}> className={wrapClass}
style={{ zIndex: coverNavigateBar ? 10001 : 100 }}
onClick={() => maskClosable && onClose?.()}
>
<View className={classNames(styles.body, bodyClassName)} onClick={(e) => e.stopPropagation()}>
{children} {children}
</View> </View>
</View> </View>
......
...@@ -26,7 +26,7 @@ interface Result<T, P> { ...@@ -26,7 +26,7 @@ interface Result<T, P> {
updateData: (newData: T) => void; updateData: (newData: T) => void;
} }
export default function useRequest<T = unknown, P = unknown> ( export function useRequest<T = unknown, P = unknown> (
service: (params?: P) => Promise<T>, service: (params?: P) => Promise<T>,
options: Options<T, P> options: Options<T, P>
): Result<T, P> { ): Result<T, P> {
......
...@@ -5,7 +5,7 @@ interface UseToggleOptions { ...@@ -5,7 +5,7 @@ interface UseToggleOptions {
initialValue?: ToggleValue; initialValue?: ToggleValue;
reverseValue?: ToggleValue; reverseValue?: ToggleValue;
} }
export default function useToggle ({ export function useToggle ({
initialValue = false, initialValue = false,
reverseValue = !initialValue, reverseValue = !initialValue,
}: UseToggleOptions = {}) { }: 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 { useBoolean } from '@/hooks/use-boolean'
import styles from './members.module.scss'
const screenHeight = getSystemInfoSync().windowHeight
const id = '_members_header_'
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.select(`#${id}`)
.boundingClientRect()
.exec((res) => {
if (res[0]) {
setHeight(res[0].height)
}
})
}, [])
const scrollHeight = useMemo(() => {
return `${screenHeight - tabBarHeight - height - 200}px`
}, [screenHeight, tabBarHeight, height])
return (
<View className={styles.container}>
<View className={styles.header} id={id}>
<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={styles.invite_members}>
<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 { View, Text, Input } from '@tarojs/components'
import { useDidShow, getCurrentInstance, getTabBar } from '@tarojs/taro' import { useDidShow, getCurrentInstance, getTabBar, getMenuButtonBoundingClientRect } from '@tarojs/taro'
import { useMemo } from 'react' 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 Group = () => {
const page = useMemo(() => getCurrentInstance().page, []) 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(() => { useDidShow(() => {
const tabbar = getTabBar(page) as any const tabbar = getTabBar(page) as any
tabbar?.setSelected(1) tabbar?.setSelected(1)
}) })
return ( 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 { memo } from 'react'
import { View, Text } from '@tarojs/components' import { View, Text } from '@tarojs/components'
import Taro from '@tarojs/taro' import Taro from '@tarojs/taro'
import useRequest from '@/hooks/use-request' import { useRequest } from '@/hooks/use-request'
import TopLeftInfo from './top-left-info' import TopLeftInfo from './top-left-info'
import LaunchQuest from './launch-quest' import LaunchQuest from './launch-quest'
......
...@@ -2,7 +2,7 @@ import React from 'react' ...@@ -2,7 +2,7 @@ import React from 'react'
import { View, Text, Button } from '@tarojs/components' import { View, Text, Button } from '@tarojs/components'
// import Taro from '@tarojs/taro' // import Taro from '@tarojs/taro'
import Modal from '@/components/Modal' import Modal from '@/components/Modal'
import useToggle from '@/hooks/use-toggle' import { useToggle } from '@/hooks/use-toggle'
import styles from './index.module.scss' import styles from './index.module.scss'
......
...@@ -2,7 +2,7 @@ import { View, Button, Text, ScrollView } from '@tarojs/components' ...@@ -2,7 +2,7 @@ import { View, Button, Text, ScrollView } from '@tarojs/components'
import { memo } 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/use-toggle' import { useToggle } from '@/hooks/use-toggle'
import UserInfo from './user-info' import UserInfo from './user-info'
import Timing from './timing' import Timing from './timing'
......
import { View, Text, Button } from '@tarojs/components' import { View, Text, Button } from '@tarojs/components'
import Modal from '@/components/Modal' import Modal from '@/components/Modal'
import useToggle from '@/hooks/use-toggle' import { useBoolean } from '@/hooks/use-boolean'
import CardMain from './card-main' import CardMain from './card-main'
const AnswerSheet: React.FC = () => { const AnswerSheet: React.FC = () => {
const [isVisible, toggleModal] = useToggle() const [isVisible, { toggle }] = useBoolean(false)
const onClick = () => { const onClick = () => {
toggleModal(false) toggle()
} }
return ( return (
...@@ -17,9 +17,9 @@ const AnswerSheet: React.FC = () => { ...@@ -17,9 +17,9 @@ const AnswerSheet: React.FC = () => {
title="答题卡" title="答题卡"
subtitle="答题卡是不断追求更高档位与排名的必备道具答题卡是不断追求更高档位与排名的必备道具" subtitle="答题卡是不断追求更高档位与排名的必备道具答题卡是不断追求更高档位与排名的必备道具"
extra={<Text className="card-stock">本月库存10</Text>} extra={<Text className="card-stock">本月库存10</Text>}
onClick={() => toggleModal(true)} onClick={toggle}
/> />
<Modal isVisible={isVisible} onClose={() => toggleModal(false)}> <Modal isVisible={isVisible} onClose={toggle}>
<View> <View>
<Text>兑换几张</Text> <Text>兑换几张</Text>
<Button size="mini" onClick={onClick}>兑换</Button> <Button size="mini" onClick={onClick}>兑换</Button>
......
import { View, Text, Button, Input } from '@tarojs/components' import { View, Text, Button, Input } from '@tarojs/components'
import Modal from '@/components/Modal' import Modal from '@/components/Modal'
import useToggle from '@/hooks/use-toggle' import { useBoolean } from '@/hooks/use-boolean'
import CardMain from './card-main' import CardMain from './card-main'
const MysteryBox = () => { const MysteryBox = () => {
const [isVisible, toggleModal] = useToggle() const [isVisible, { toggle }] = useBoolean(false)
const onClick = () => { const onClick = () => {
toggleModal(false) toggle()
} }
return ( return (
...@@ -17,9 +17,9 @@ const MysteryBox = () => { ...@@ -17,9 +17,9 @@ const MysteryBox = () => {
title="神秘大礼" title="神秘大礼"
subtitle="兑换神秘大礼,线下领取超级大礼" subtitle="兑换神秘大礼,线下领取超级大礼"
extra={<Text className="card-stock">本月库存10</Text>} extra={<Text className="card-stock">本月库存10</Text>}
onClick={() => toggleModal(true)} onClick={toggle}
/> />
<Modal isVisible={isVisible} onClose={() => toggleModal(false)}> <Modal isVisible={isVisible} onClose={toggle}>
<View> <View>
<Input type="number" /> <Input type="number" />
<Text>兑换礼物</Text> <Text>兑换礼物</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