From 4796a7ac0ee021f133a84f0579ccae8978536d85 Mon Sep 17 00:00:00 2001 From: yyy9608 Date: Wed, 10 Jan 2024 17:13:55 +0800 Subject: [PATCH] commit --- src/hooks/useNotify.ts | 3 +- src/index.tsx | 6 +-- src/pages/no-share/index.tsx | 8 ++-- src/pages/record/index.tsx | 82 +++++++++++++++++++++--------------- src/styles/personal.scss | 9 ++-- 5 files changed, 64 insertions(+), 44 deletions(-) diff --git a/src/hooks/useNotify.ts b/src/hooks/useNotify.ts index 83a7438..8cba032 100644 --- a/src/hooks/useNotify.ts +++ b/src/hooks/useNotify.ts @@ -5,7 +5,6 @@ import { MessageType } from "~/types/store"; import signGenerator from "~/utils/sign/sign"; const useNotify = (path: string, isNotity: boolean) => { - const baseUrl = `${process.env.REACT_APP_WS_URL}/api/v1/${path}`; const ws = useRef(null); const filterMessage = useRef([] as MessageType[]); @@ -30,6 +29,8 @@ const useNotify = (path: string, isNotity: boolean) => { event.origin === process.env.REACT_APP_WS_URL ) { let message = JSON.parse(event.data) as MessageType; + if (!message) return; + if (!message.id) return; let item = filterMessage.current.find((v) => v.id === message.id); if (item) return; filterMessage.current.unshift(message); diff --git a/src/index.tsx b/src/index.tsx index 525aa1f..66ac3e0 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -8,7 +8,7 @@ const root = ReactDOM.createRoot( ); root.render( - - - + // + + // ); \ No newline at end of file diff --git a/src/pages/no-share/index.tsx b/src/pages/no-share/index.tsx index 4d10fe3..443da3d 100644 --- a/src/pages/no-share/index.tsx +++ b/src/pages/no-share/index.tsx @@ -10,14 +10,14 @@ import { UserInfo } from '~/types/store' const NoShare = () => { - const { location } = useRouter() + const { push, location } = useRouter() const state = location.state const [userInfo, setUserInfo] = useState({} as UserInfo) const tabs = useMemo(() => ['我的NFT', '我喜歡的NFT'], []) const getLength = (index: number) => { - if(!userInfo.my_like || !userInfo.my_nft ) return 0 - if(index === 0) return userInfo.my_nft.length + if (!userInfo.my_like || !userInfo.my_nft) return 0 + if (index === 0) return userInfo.my_nft.length return userInfo.my_like.length } @@ -82,7 +82,7 @@ const NoShare = () => { { userInfo.my_like && userInfo.my_nft &&
{(index === 0 ? userInfo.my_nft : userInfo.my_like).map((item, index) => ( -
+
push("/detail", { id: item.id, type: item.type })}>
))} diff --git a/src/pages/record/index.tsx b/src/pages/record/index.tsx index ccacf5d..d056e4c 100644 --- a/src/pages/record/index.tsx +++ b/src/pages/record/index.tsx @@ -5,8 +5,7 @@ import store from "~/store"; import { observer } from "mobx-react"; import { useRouter } from "~/hooks/useRouter"; import BackBar from "~/components/BackBar"; -import { Cell, Empty, List, Tabs } from "react-vant"; -import { debounce } from 'lodash'; +import { Cell, Empty, List } from "react-vant"; import '~/styles/personal.scss'; import { history_record } from "~/api"; @@ -14,23 +13,25 @@ const Record = () => { const { token } = store.state; const { push, location } = useRouter() - - const recordTabs = useMemo(() => ['充值', '提現', '收益'], []); + + const recordTabs = useMemo(() => ['充值', '提現', '收益', '邀請收益'], []); const [recordIndex, setRecordIndex] = useState(location.state ? location.state.index : 0); const { copyVal } = useCopyLink(); const [query, setQuery] = useState([ { page: 1, page_size: 20 }, { page: 1, page_size: 20 }, { page: 1, page_size: 20 }, + { page: 1, page_size: 20 }, ]); const [finished, setFinished] = useState([true, true, true]); const [assetsRecord, setAssetsRecord] = useState([ [] as any[], [] as any[], [] as any[], + [] as any[], ]); - const getAssetsRecord = debounce(async () => { + const getAssetsRecord = async () => { let res: any = await history_record({ type: recordIndex + 1, ...query[recordIndex] }); if (res.code === 0) { @@ -56,13 +57,14 @@ const Record = () => { setAssetsRecord([...assetsRecord]); setQuery([...query]); }; - }, 200); + }; const renderItem = (index: number) => { let el = [ , , , + , ]; return el[index]; }; @@ -79,30 +81,21 @@ const Record = () => { - setRecordIndex(index)} - align="start" - className="tabs" - lazyRender - > - { - recordTabs.map((item, index) => ( - - {renderItem(index)} - - )) - } - +
+
+ { + recordTabs.map((tx, index) => ( +
setRecordIndex(index)}>{tx}
+ )) + } +
+
+
+ +
+ {renderItem(recordIndex)} +
+
) } @@ -121,7 +114,7 @@ const RechargeRecord = ( if (list.length <= 0 || Object.keys(list).length <= 0) return ; return ( - getData()} errorText="請求失敗,點擊重新加載" offset={10}> + = 20 && "已經到底了"} onLoad={() => getData()} errorText="請求失敗,點擊重新加載" offset={10}> { list.map((item) => ( @@ -157,7 +150,7 @@ const WithdrawRecord = ({ list, finished, getData, copy }: ChildProps) => { if (list.length <= 0 || Object.keys(list).length <= 0) return ; return ( - getData()} errorText="請求失敗,點擊重新加載" offset={10}> + = 20 && "已經到底了"} onLoad={() => getData()} errorText="請求失敗,點擊重新加載" offset={10}> { list.map((item, index) => ( @@ -193,7 +186,7 @@ const TransferRecord = ({ list, finished, getData }: ChildProps) => { if (list.length <= 0 || Object.keys(list).length <= 0) return ; return ( - getData()} errorText="請求失敗,點擊重新加載" offset={10}> + = 20 && "已經到底了"} onLoad={() => getData()} errorText="請求失敗,點擊重新加載" offset={10}> { list.map((item, index) => ( @@ -216,4 +209,27 @@ const TransferRecord = ({ list, finished, getData }: ChildProps) => { ) } +const InviteIncomeRecord = ({ list, finished, getData }: ChildProps) => { + + if (list.length <= 0 || Object.keys(list).length <= 0) return ; + + return ( + = 20 && "已經到底了"} onLoad={() => getData()} errorText="請求失敗,點擊重新加載" offset={10}> + { + list.map((item, index) => ( + +
+
+
{item.name}
+
{getTime(item.time * 1000)}
+
+
+{toThousands(item.amount)} {item.symbol}
+
+
+ )) + } +
+ ) +} + export default observer(Record); \ No newline at end of file diff --git a/src/styles/personal.scss b/src/styles/personal.scss index 7403414..e7137bd 100644 --- a/src/styles/personal.scss +++ b/src/styles/personal.scss @@ -46,6 +46,12 @@ } .record{ + .tabs-sticky{ + position: sticky; + top: 60px; + background-color: $page; + z-index: 1; + } .tabs{ padding: 10px 0px; .rv-tabs__nav--capsule .rv-tab.rv-tab--active .rv-tab__text { @@ -135,7 +141,4 @@ } } - .swiper-height{ - // height: 460px; - } } \ No newline at end of file