diff --git a/.env.development b/.env.development index d28e5f8..ba50e11 100644 --- a/.env.development +++ b/.env.development @@ -20,3 +20,4 @@ REACT_APP_SNAPSHOT_VOTING_API = "https://xtjyd0liqe.execute-api.ap-northeast-1.a REACT_APP_REQUEST_URL = 'http://101.35.117.69:9090' +# REACT_APP_REQUEST_URL = 'http://192.168.2.210:8080' diff --git a/public/locales/zh-CN.json b/public/locales/zh-CN.json index 5592efc..f05b163 100644 --- a/public/locales/zh-CN.json +++ b/public/locales/zh-CN.json @@ -1118,5 +1118,7 @@ "purchase":"购买", "Enter a keyword search":"输入关键字搜索", "By using the invitation at the top right of the page, new users can be invited to enter and obtained after users purchase coins":"使用页面右上方的邀请,可邀请新用户进入,并在用户购买币后获得", - "The commission":"的提成!" + "The commission":"的提成!", + "market value":"市值", + "Loaded all":"已加载全部" } diff --git a/src/config/localization/translations.json b/src/config/localization/translations.json index 4373195..54a04f2 100644 --- a/src/config/localization/translations.json +++ b/src/config/localization/translations.json @@ -1245,5 +1245,7 @@ "purchase":"purchase", "Enter a keyword search":"Enter a keyword search", "By using the invitation at the top right of the page, new users can be invited to enter and obtained after users purchase coins":"By using the invitation at the top right of the page, new users can be invited to enter and obtained after users purchase coins", - "The commission":"The commission!" + "The commission":"The commission!", + "market value":"market value", + "Loaded all":"Loaded all" } diff --git a/src/services/user.ts b/src/services/user.ts index 380e5aa..bba1c7a 100644 --- a/src/services/user.ts +++ b/src/services/user.ts @@ -6,4 +6,10 @@ export const queryUserInfo = () => { method: 'get', }) } +export const uccnDetail = () => { + return request.request({ + url: '/high_city/app/api/user/uccn/detail', + method: 'get', + }) +} export default queryUserInfo diff --git a/src/utils/request.ts b/src/utils/request.ts index 74092f2..3134713 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -4,7 +4,7 @@ import { CACHE_TOKEN } from 'config/constants/cacheKey' // create an axios instance const request = axios.create({ baseURL: process.env.REACT_APP_REQUEST_URL, - timeout: 10000, // request timeout + timeout: 50000, // request timeout }) let hasInit = false export const initAxios = (clearUserInfo, toast) => { diff --git a/src/views/Announcement/index.tsx b/src/views/Announcement/index.tsx index 0bacc21..d3a69aa 100644 --- a/src/views/Announcement/index.tsx +++ b/src/views/Announcement/index.tsx @@ -112,22 +112,49 @@ const TextInfo = styled(Text)` color: #999999; margin-top: 30px; ` +const TextAll = styled(Text)` + text-align: center; + padding: 20px 0; + color: #999; +` const Announcement: React.FC = () => { const { t } = useTranslation() + const [pageNum, setPage] = useState(1) const loadMoreRef = useRef(null) - + const [searchTitle, setSearchTitle] = useState('') const [detailVisible, setDetailVisible] = useState(false) const [list, setList] = useState([]) + const [totalVisible, setTotalVisible] = useState(false) const [detailData, setDetailData] = useState({ title: '', publishTime: 0, content: '' }) - const getList = async (page: number, size: number) => { - const data = await getAnnouncementPage({ page, size }) - console.log(data.content) - setList(data.content) + const getList = async (page: number, size: number, title?: string) => { + if (totalVisible) return + const data = await getAnnouncementPage({ page, size, title }) + const dataList = [...list, ...data.content] + setList(dataList) + if (data.content.length === 0 || !data.content) { + setTotalVisible(true) + } + } + + const onScrollCapture = () => { + const innerHeight = window.innerHeight + const screenH = Math.ceil(innerHeight + window.scrollY) + const eleH = document.documentElement.offsetHeight + if (screenH >= eleH) { + setPage(pageNum + 1) + } } useEffect(() => { - getList(1, 10) - }, []) + if (!totalVisible) { + window.addEventListener('scroll', onScrollCapture) + getList(pageNum, 10, searchTitle) + } + + return () => { + window.removeEventListener('scroll', onScrollCapture) + } + }, [pageNum]) const lookDetail = async (id) => { const data = await getAnnouncementDetail(id) @@ -135,7 +162,8 @@ const Announcement: React.FC = () => { setDetailVisible(true) } const searchList = () => { - getList(1, 10) + setList([]) + getList(1, 10, searchTitle) } const close = () => { setDetailVisible(false) @@ -152,9 +180,13 @@ const Announcement: React.FC = () => { ) } - + const handleChange = (evt: React.ChangeEvent) => { + const { value: inputValue } = evt.target + setSearchTitle(inputValue) + console.log(searchTitle) + } return ( - + {detailVisible ? ( { - + @@ -174,7 +206,9 @@ const Announcement: React.FC = () => { {renderContent()} -
+ {totalVisible ? {t('Loaded all')} : ''} + + {/*
*/} {/* {list.map((item) => ( lookDetail(item.id)}> diff --git a/src/views/Home/components/FlexItemCom.tsx b/src/views/Home/components/FlexItemCom.tsx index 34126a3..9248b5d 100644 --- a/src/views/Home/components/FlexItemCom.tsx +++ b/src/views/Home/components/FlexItemCom.tsx @@ -1,10 +1,11 @@ import React from 'react' import styled from 'styled-components' +import Balance from 'components/Balance' import { Text } from '@pancakeswap/uikit' interface FlexProp { - name: string - value: string + name?: string | number + valueNum?: string | number } const ScoreItem = styled.div` @@ -21,10 +22,10 @@ const ItemSubText = styled(Text)` font-size: 20px; ` -const FlexItemCom: React.FC = ({ name, value }) => { +const FlexItemCom: React.FC = ({ name, valueNum }) => { return ( - {value} + {name} ) diff --git a/src/views/Home/components/FristCom.tsx b/src/views/Home/components/FristCom.tsx index 589d8fa..0d2ea98 100644 --- a/src/views/Home/components/FristCom.tsx +++ b/src/views/Home/components/FristCom.tsx @@ -1,6 +1,7 @@ -import React, { useState } from 'react' +import React, { useState, useEffect } from 'react' import styled from 'styled-components' -import { Flex, Heading, Text, Box, Button, Image } from '@pancakeswap/uikit' +import { uccnDetail } from 'services/user' +import { Flex, Heading, Text, Box, Button, Image, Link } from '@pancakeswap/uikit' import { useTranslation } from 'contexts/Localization' import FlexItemCom from './FlexItemCom' @@ -99,7 +100,12 @@ const WhiteBtn = styled(Button)` const BtnImage = styled(Image)` width: 34px; height: 34px; + border-radius: 50%; margin-right: 12px; + cursor: pointer; + & > img { + border-radius: 50%; + } ` const ScoreDiv = styled(Flex)` @@ -125,12 +131,23 @@ const InfoDiv = styled.div`` const FristCom: React.FC = () => { const { t } = useTranslation() - const [burned, BurnedState] = useState([ - { id: 1, name: 'Burned', value: '62.55%' }, - { id: 2, name: 'Burned', value: '62.55%' }, - { id: 3, name: 'Burned', value: '62.55%' }, - { id: 4, name: 'Burned', value: '62.55%' }, - ]) + // const [burned, BurnedState] = useState([ + // { id: 'userNumb', name: '持有人数量', value: '0' }, + // { id: 'tradingVolume', name: '交易量', value: '0' }, + // { id: 3, name: '市值', value: '62.55%' }, + // ]) + const [detail, setDetail] = useState({ userNumb: 0, tradingVolume: 0, outsideChainVos: [] }) + const getDetail = async () => { + const data = await uccnDetail() + setDetail(data) + } + + useEffect(() => { + getDetail() + }, []) + const openLink = (link) => { + window.open(link) + } return ( <> @@ -148,16 +165,31 @@ const FristCom: React.FC = () => { {t('Exchange')} {t('Bazaar')} - - + {detail.outsideChainVos.map((item) => { + return ( + openLink(item.link)} + /> + ) + })} + {/* + */} - {burned.map((item) => { + + + + {/* {burned.map((item) => { return - })} + })} */}