diff --git a/src/pages/manage/meetings/list.tsx b/src/pages/manage/meetings/list.tsx new file mode 100644 index 0000000..06e9a3c --- /dev/null +++ b/src/pages/manage/meetings/list.tsx @@ -0,0 +1,89 @@ +import {FC, useState} from "react"; +import {Image, View} from "@tarojs/components"; +import {Meeting, meetingAPi} from "@/api"; +import Taro from "@tarojs/taro"; +import styles from "@/pages/manage/meetings/list.module.scss"; +import {formatDate} from "@/utils/time"; +import Empty from "@/components/empty/empty"; +import MyButton from "@/components/button/MyButton"; +import Icon from "@/components/icon"; +import meetingBefore from "@/static/img/beforeMeeting.png" +import meet from "@/static/img/meeting.png" +import usePubsub from "@/hooks/pubsub"; +import Spin from "@/components/spinner"; + +const MeetingsList: FC = () => { + const [meeting, setMeeting] = useState([]) + const {sub} = usePubsub() + const [enable ,setEnable] = useState(true) + + const getData = async () => { + try { + const data = await meetingAPi.unstopsList() + setMeeting(data) + setEnable(false) + } catch (e) { + } + } + + function jumpInfo(item: Meeting) { + Taro.navigateTo({url: `/pages/manage/spotMeeting/spotMeeting?id=${item.id}`}) + } + + Taro.useLoad(() => { + getData() + sub('deleteMeeting', (id) => { + setMeeting((data) => { + return data.filter(d => d.id === id) + }) + }) + sub('updateMeetingList', getData) + sub('updateMeetingList', () => { + console.log('二次更新') + }) + }) + + return ( + + + { + meeting.length ? + meeting.map((d) => jumpInfo(d)} className={styles.meeting} key={d.id}> + + { + d.status === 0 + ? + : + } + + + {d.name} + {formatDate(new Date(d.estimate_start_time), "MM-dd hh:mm")} 至 {formatDate(new Date(d.estimate_end_time), "MM-dd hh:mm")} + + ) + : + } + + { + Taro.navigateTo({ + url: '/pages/manage/meetings/form/form' + }) + }} + loading={false}>新建现场会 + Taro.navigateTo({url: '/pages/manage/meetings/meetings'})}> + 历史列表 + + + + + ) +} +export default MeetingsList diff --git a/src/pages/preview/collect/collect.tsx b/src/pages/preview/collect/collect.tsx index b81243f..e2206cd 100644 --- a/src/pages/preview/collect/collect.tsx +++ b/src/pages/preview/collect/collect.tsx @@ -1,6 +1,6 @@ import {Image, ScrollView, Swiper, SwiperItem, View} from "@tarojs/components"; import {userApi} from "@/api"; -import {useCallback, useEffect, useState} from "react"; +import {useEffect, useState} from "react"; import Tabs, {OnChangOpt, TabList} from "@/components/tabs/tabs"; import Empty from "@/components/empty/empty"; import Taro from "@tarojs/taro"; @@ -23,6 +23,7 @@ const Profession = () => { const [data, setData] = useState>(new Map) const [enable, setEnable] = useState(true) + console.log('Profession组件重新渲染') /** * more 开启加载更多 @@ -65,7 +66,6 @@ const Profession = () => { useEffect(() => { - console.log(categoryId,'categoryId') categoryId && getData() }, [categoryId]) diff --git a/src/pages/preview/search/search/index.tsx b/src/pages/preview/search/search/index.tsx index b6e87bd..a40b657 100644 --- a/src/pages/preview/search/search/index.tsx +++ b/src/pages/preview/search/search/index.tsx @@ -1,151 +1,206 @@ -import {Input, View, Text, PageContainer, Image} from "@tarojs/components"; -import {FC, useEffect, useMemo, useState} from "react"; -import styles from './index.module.scss' -import Taro from "@tarojs/taro"; -import {useDidShow} from '@tarojs/taro' -import SearchList from './components/list' -import NavigationBar from "@/components/navigationBar/navigationBar"; -import search from '@/static/img/search.png' -import del from '@/static/img/del.png' - - -const Search: FC = () => { - const [value, setValue] = useState('') - const [recentSearch, setRecentSearch] = useState([]) - const [hotSearch] = useState([]) - const [show, setShow] = useState(false) - const [focus, setFocus] = useState(false) - - - useDidShow(getRecentSearch) - - useEffect(() => { - !show && getRecentSearch() - }, [show]) - - function inpFn(e) { - setValue(e.detail.value) - } - - function clearSearch() { - Taro.removeStorageSync('recentSearch') - getRecentSearch() - Taro.showToast({title: '删除成功'}) - } - - function getRecentSearch() { - setRecentSearch(Taro.getStorageSync('recentSearch')) - } - - function getSearchItem(value) { - setValue(value) - setShow(true) - } - - function searchInput() { - if (value === "") return; - getSearchItem(value) - //记录最近搜索 - let recentSearch = Taro.getStorageSync('recentSearch') || []; - recentSearch.unshift(value); - Taro.setStorageSync('recentSearch', [...new Set(recentSearch)]) - } - - function cancelSearch(){ - setValue('') - setShow(false) - setFocus(false) - Taro.navigateBack() - } - - - const searchStyles = useMemo((): React.CSSProperties | undefined => { - if (focus || show) { - return { - // transform: "translateY(-43px)", - // width: "100%", - } - } - }, [focus, show]) - - +// import {Input, View, Text, PageContainer, Image} from "@tarojs/components"; +// import {FC, useEffect, useMemo, useState} from "react"; +// import styles from './index.module.scss' +// import Taro from "@tarojs/taro"; +// import {useDidShow} from '@tarojs/taro' +// import SearchList from './components/list' +// import NavigationBar from "@/components/navigationBar/navigationBar"; +// import search from '@/static/img/search.png' +// import del from '@/static/img/del.png' +// +// +// const Search: FC = () => { +// const [value, setValue] = useState('') +// const [recentSearch, setRecentSearch] = useState([]) +// const [hotSearch] = useState([]) +// const [show, setShow] = useState(false) +// const [focus, setFocus] = useState(false) +// +// +// useDidShow(getRecentSearch) +// +// useEffect(() => { +// !show && getRecentSearch() +// }, [show]) +// +// function inpFn(e) { +// setValue(e.detail.value) +// } +// +// function clearSearch() { +// Taro.removeStorageSync('recentSearch') +// getRecentSearch() +// Taro.showToast({title: '删除成功'}) +// } +// +// function getRecentSearch() { +// setRecentSearch(Taro.getStorageSync('recentSearch')) +// } +// +// function getSearchItem(value) { +// setValue(value) +// setShow(true) +// } +// +// function searchInput() { +// if (value === "") return; +// getSearchItem(value) +// //记录最近搜索 +// let recentSearch = Taro.getStorageSync('recentSearch') || []; +// recentSearch.unshift(value); +// Taro.setStorageSync('recentSearch', [...new Set(recentSearch)]) +// } +// +// function cancelSearch(){ +// setValue('') +// setShow(false) +// setFocus(false) +// Taro.navigateBack() +// } +// +// +// const searchStyles = useMemo((): React.CSSProperties | undefined => { +// if (focus || show) { +// return { +// // transform: "translateY(-43px)", +// // width: "100%", +// } +// } +// }, [focus, show]) +// +// +// return ( +// +// +// +// +// +// setFocus(true)} +// onBlur={() => setFocus(false)} +// className={styles.input} +// placeholder={(focus || show) ? '' : "输入关键字搜索"} +// type='text' +// value={value} +// confirmType='search' +// onInput={inpFn} +// onConfirm={searchInput}/> +// +// +// 取消 +// {/*{focus || show ? 取消 : null}*/} +// +// +// +// { +// recentSearch.length >= 1 && !show && +// +// +// 最近搜索 +// +// +// +// { +// recentSearch.length > 0 && +// recentSearch?.map(d => +// +// getSearchItem(d)} className="font-28">{d} +// ) +// } +// +// +// } +// { +// hotSearch.length >= 1 && !show && +// <> +// +// +// 热门搜索 +// +// +// +// { +// hotSearch.length && +// hotSearch.map(d => +// +// { +// getSearchItem(d) +// }} className="font-28">{d} +// ) +// } +// +// +// +// } +// +// +// {show && } +// +// +// ) +// } +// export default Search + +import {FC, useState, useMemo, memo, useCallback} from "react"; +import {Button, Text, View} from "@tarojs/components"; + + +type Props = { + items: number[] +} +const Inner:FC = memo(({items}) => +{ + console.log('子组件渲染') return ( - - - - - - setFocus(true)} - onBlur={() => setFocus(false)} - className={styles.input} - placeholder={(focus || show) ? '' : "输入关键字搜索"} - type='text' - value={value} - confirmType='search' - onInput={inpFn} - onConfirm={searchInput}/> - - - 取消 - {/*{focus || show ? 取消 : null}*/} - - - - { - recentSearch.length >= 1 && !show && - - - 最近搜索 - - - - { - recentSearch.length > 0 && - recentSearch?.map(d => - - getSearchItem(d)} className="font-28">{d} - ) - } - - + + { items.length && + items.map(d => {d}) } - { - hotSearch.length >= 1 && !show && - <> - + + ) +}) - 热门搜索 - - - - { - hotSearch.length && - hotSearch.map(d => - - { - getSearchItem(d) - }} className="font-28">{d} - ) - } - - - - } +type Props1 = { + change:(e) => void +} +const NewInner:FC = memo(({change}) => { + console.log('子组件渲染') + return ( + + ) +}) - - {show && } - +const Search: FC = () => { + const [b,setB]=useState(1) + const [todos]=useState([1,2,3,4,5]) + const [tab,setTab] = useState(1) + console.log('父组件渲染') + const mNum = useMemo(() => todos.filter(d => d !== tab),[todos,tab]) + + const change = useCallback((e:any) => { + console.log(e) + console.log(b,'b') + setB( b + 1) + },[b]) + return ( + + {b} + {/**/} + {/**/} + {/**/} + {/**/} + {/**/} + ) }