yyy
10 months ago
10 changed files with 416 additions and 26 deletions
-
1package.json
-
21src/package/SimpleTrade/api/index.ts
-
29src/package/SimpleTrade/pages/client/recharge/index.tsx
-
21src/package/SimpleTrade/pages/client/user/index.tsx
-
12src/package/SimpleTrade/pages/client/withdraw/index.tsx
-
38src/package/SimpleTrade/pages/home/index.css
-
47src/package/SimpleTrade/pages/home/index.less
-
266src/package/SimpleTrade/pages/home/index.tsx
-
BINsrc/package/SimpleTrade/pages/home/vector.png
-
5yarn.lock
@ -0,0 +1,38 @@ |
|||||
|
.home .box { |
||||
|
width: 100%; |
||||
|
margin-top: 20px; |
||||
|
border-radius: 10px; |
||||
|
padding: 20px; |
||||
|
box-sizing: border-box; |
||||
|
min-height: 280px; |
||||
|
} |
||||
|
.home .box .solid { |
||||
|
min-height: 200px; |
||||
|
width: 1px; |
||||
|
} |
||||
|
.home .box .img-box { |
||||
|
width: 60px; |
||||
|
height: 60px; |
||||
|
background-color: #44D600; |
||||
|
border-radius: 6px; |
||||
|
display: flex; |
||||
|
justify-content: center; |
||||
|
align-items: center; |
||||
|
} |
||||
|
.home .box .img-box img { |
||||
|
width: 30px; |
||||
|
height: 30px; |
||||
|
object-fit: cover; |
||||
|
} |
||||
|
.row { |
||||
|
display: flex; |
||||
|
} |
||||
|
.row-items { |
||||
|
display: flex; |
||||
|
align-items: center; |
||||
|
} |
||||
|
.row-between { |
||||
|
display: flex; |
||||
|
align-items: center; |
||||
|
justify-content: space-between; |
||||
|
} |
@ -0,0 +1,47 @@ |
|||||
|
.home { |
||||
|
|
||||
|
.box { |
||||
|
width: 100%; |
||||
|
margin-top: 20px; |
||||
|
border-radius: 10px; |
||||
|
padding: 20px; |
||||
|
box-sizing: border-box; |
||||
|
min-height: 280px; |
||||
|
|
||||
|
.solid{ |
||||
|
min-height: 200px; |
||||
|
width: 1px; |
||||
|
} |
||||
|
|
||||
|
.img-box{ |
||||
|
width: 60px; |
||||
|
height: 60px; |
||||
|
background-color: #44D600; |
||||
|
border-radius: 6px; |
||||
|
display: flex; |
||||
|
justify-content: center; |
||||
|
align-items: center; |
||||
|
|
||||
|
img{ |
||||
|
width: 30px; |
||||
|
height: 30px; |
||||
|
object-fit: cover; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
.row{ |
||||
|
display: flex; |
||||
|
} |
||||
|
|
||||
|
.row-items{ |
||||
|
display: flex; |
||||
|
align-items: center; |
||||
|
} |
||||
|
|
||||
|
.row-between{ |
||||
|
display: flex; |
||||
|
align-items: center; |
||||
|
justify-content: space-between; |
||||
|
} |
@ -1,18 +1,262 @@ |
|||||
import React, { FC } from 'react' |
|
||||
import { Col, Row } from 'antd' |
|
||||
|
import React, { FC, useEffect, useState } from 'react' |
||||
|
import './index.less' |
||||
|
import { useSelector } from 'react-redux' |
||||
|
import api from '@/package/SimpleTrade/api' |
||||
|
import { DatePicker } from 'antd'; |
||||
|
import dayjs from 'dayjs'; |
||||
|
import customParseFormat from 'dayjs/plugin/customParseFormat'; |
||||
|
import weekday from "dayjs/plugin/weekday" |
||||
|
import localeData from "dayjs/plugin/localeData" |
||||
|
dayjs.extend(customParseFormat); |
||||
|
dayjs.extend(weekday); |
||||
|
dayjs.extend(localeData); |
||||
|
const { RangePicker } = DatePicker; |
||||
|
const dateFormat = 'YYYY-MM-DD'; |
||||
|
|
||||
const Home: FC = () => { |
const Home: FC = () => { |
||||
return ( |
|
||||
<div style={{ height: '100vh', textAlign: 'center' }}> |
|
||||
<Row> |
|
||||
<Col span={12} flex={1}> |
|
||||
|
|
||||
</Col> |
|
||||
<Col span={12}> |
|
||||
|
const theme = useSelector((state: any) => state.storeData.theme) |
||||
|
|
||||
|
const [userTable, setUserTable] = useState([]) |
||||
|
const [newToDay, setNewToDay] = useState(0) //今日新增
|
||||
|
const [userTotal, setUserTotal] = useState(0) //用户统计
|
||||
|
const start_time = dayjs().subtract(7, 'days') |
||||
|
const end_time = dayjs() |
||||
|
|
||||
|
const [defaultValue, setDefaultValue] = useState([start_time, end_time] as any) |
||||
|
|
||||
|
const [toDayTx, setToDayTx] = useState([ |
||||
|
{ title: '今日订单金额', value: '0' }, |
||||
|
{ title: '今日订单数量', value: '0' }, |
||||
|
{ title: '盈利订单数量', value: '0', color: '#3BB900' }, |
||||
|
{ title: '亏损订单数量', value: '0', color: '#F4002C' }, |
||||
|
{ title: '盈利订单金额', value: '0', color: '#3BB900' }, |
||||
|
{ title: '亏损订单金额', value: '0', color: '#F4002C' }, |
||||
|
]) |
||||
|
|
||||
|
const [weekTx, setWeekTx] = useState([ |
||||
|
{ title: '订单总金额', value: '0' }, |
||||
|
{ title: '订单总数量', value: '0' }, |
||||
|
{ title: '盈利订单数量', value: '0', color: '#3BB900' }, |
||||
|
{ title: '亏损订单数量', value: '0', color: '#F4002C' }, |
||||
|
{ title: '盈利订单金额', value: '0', color: '#3BB900' }, |
||||
|
{ title: '亏损订单金额', value: '0', color: '#F4002C' }, |
||||
|
]) |
||||
|
|
||||
|
const [transaction, setTransaction] = useState([]) |
||||
|
|
||||
|
// 用户统计
|
||||
|
const getUserData = async () => { |
||||
|
const res: any = await api.user_statistics() |
||||
|
if (res.code === 0) { |
||||
|
setNewToDay(res.data.NewToday) |
||||
|
setUserTotal(res.data.total_amount) |
||||
|
setUserTable(res.data.AdminUserAmountList) |
||||
|
} |
||||
|
} |
||||
|
|
||||
</Col> |
|
||||
</Row> |
|
||||
</div> |
|
||||
|
// 周期合约交易订单统计
|
||||
|
const getWeekTxOrderStatic = async () => { |
||||
|
const start = Math.floor(defaultValue[0].valueOf() / 1000) |
||||
|
const end = Math.floor(defaultValue[1].valueOf() / 1000) |
||||
|
const res: any = await api.transaction_statistics({ |
||||
|
end_time: end, |
||||
|
start_time: start, |
||||
|
type: 2 |
||||
|
}) |
||||
|
if (res.code === 0) { |
||||
|
weekTx[0].value = res.data.product_amount |
||||
|
weekTx[1].value = res.data.product_num |
||||
|
weekTx[2].value = res.data.profit_num |
||||
|
weekTx[3].value = res.data.loss_num |
||||
|
weekTx[4].value = res.data.profit_amount |
||||
|
weekTx[5].value = res.data.loss_amount |
||||
|
setWeekTx([...weekTx]) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// 今日合约交易订单统计
|
||||
|
const getDayTxOrderStatic = async () => { |
||||
|
const res: any = await api.transaction_statistics({ |
||||
|
type: 1 |
||||
|
}) |
||||
|
console.log(res); |
||||
|
|
||||
|
if (res.code === 0) { |
||||
|
toDayTx[0].value = res.data.product_amount |
||||
|
toDayTx[1].value = res.data.product_num |
||||
|
toDayTx[2].value = res.data.profit_num |
||||
|
toDayTx[3].value = res.data.loss_num |
||||
|
toDayTx[4].value = res.data.profit_amount |
||||
|
toDayTx[5].value = res.data.loss_amount |
||||
|
setToDayTx([...toDayTx]) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// 充值提现统计
|
||||
|
const getRechargeAndWithdraw = async () => { |
||||
|
const res: any = await api.recharge_withdraw_statistics() |
||||
|
if (res.code === 0) { |
||||
|
setTransaction(res.data) |
||||
|
} |
||||
|
console.log(res); |
||||
|
} |
||||
|
|
||||
|
useEffect(() => { |
||||
|
getUserData() |
||||
|
getDayTxOrderStatic() |
||||
|
getRechargeAndWithdraw() |
||||
|
}, []) |
||||
|
|
||||
|
useEffect(() => { |
||||
|
getWeekTxOrderStatic() |
||||
|
}, [defaultValue]) |
||||
|
|
||||
|
return ( |
||||
|
<div className='home' style={{ minHeight: '80vh', backgroundColor: theme && '#fff' }}> |
||||
|
<h3>Hello, Randy!</h3> |
||||
|
<div>Today is a good day to start trading crypto assets!</div> |
||||
|
{/* */} |
||||
|
<div className='box' style={{ backgroundColor: theme ? '#f5f5f5' : '#333' }}> |
||||
|
<div style={{ fontWeight: 'bold' }}>用户统计</div> |
||||
|
<div className='row'> |
||||
|
<div style={{ flex: 3, marginTop: 30 }}> |
||||
|
<h2>{userTotal.toLocaleString()}</h2> |
||||
|
<div className='row-items' style={{ marginTop: 20 }}> |
||||
|
<div className='img-box'> |
||||
|
<img src={require('./vector.png')} alt="" /> |
||||
|
</div> |
||||
|
<div style={{ marginLeft: 10 }}> |
||||
|
<div style={{ fontWeight: 'bold' }}>+{newToDay.toLocaleString()}</div> |
||||
|
<div style={{ fontSize: 12, marginTop: 5 }}>今日新增</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div className='solid' style={{ backgroundColor: theme ? '#e8e8e8' : '#555' }}></div> |
||||
|
<div style={{ flex: 4, marginLeft: 20 }}> |
||||
|
<div className='row' style={{ textAlign: 'center' }}> |
||||
|
<div style={{ flex: 1 }}>类型</div> |
||||
|
<div style={{ flex: 1 }}>截止昨日</div> |
||||
|
<div style={{ flex: 1 }}>今日新增</div> |
||||
|
</div> |
||||
|
<div> |
||||
|
{ |
||||
|
userTable.map((item, index) => ( |
||||
|
<div key={index} className='row' style={{ textAlign: 'center', marginTop: 20 }}> |
||||
|
<div style={{ flex: 1 }}>{item.type}</div> |
||||
|
<div style={{ flex: 1 }}> |
||||
|
<div>{Number(item.yesterday_amount).toLocaleString()}</div> |
||||
|
<div>{item.yesterday_percentage}</div> |
||||
|
</div> |
||||
|
<div style={{ flex: 1, color: '#44D600' }}> |
||||
|
<div>{Number(item.new_today_amount).toLocaleString()}</div> |
||||
|
<div>{item.new_today_percentage}</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
)) |
||||
|
} |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
{/* */} |
||||
|
<div className='box row' style={{ backgroundColor: theme ? '#f5f5f5' : '#333', marginTop: 30 }}> |
||||
|
<div style={{ flex: 3 }}> |
||||
|
<div style={{ fontWeight: 'bold', fontSize: 14 }}>今日合约交易订单统计</div> |
||||
|
<div style={{ marginTop: 20, textAlign: 'center', flexWrap: 'wrap' }} className='row-items'> |
||||
|
{ |
||||
|
toDayTx.map((item, index) => ( |
||||
|
<div key={index} style={{ width: '50%', marginTop: 10 }}> |
||||
|
<div style={{ fontSize: 14 }}>{item.title}</div> |
||||
|
<div style={{ fontWeight: 'bold', fontSize: 14, color: item.color }}>{Number(item.value).toLocaleString()}</div> |
||||
|
</div> |
||||
|
)) |
||||
|
} |
||||
|
</div> |
||||
|
</div> |
||||
|
<div className='solid' style={{ backgroundColor: theme ? '#e8e8e8' : '#555', margin: '0 20px' }}></div> |
||||
|
<div style={{ flex: 4 }}> |
||||
|
<div className='row-between'> |
||||
|
<div className='row-items'> |
||||
|
<div style={{ fontWeight: 'bold', fontSize: 14 }}>周期合约交易订单统计</div> |
||||
|
<div style={{ marginLeft: 10 }}> |
||||
|
<RangePicker |
||||
|
defaultValue={defaultValue} |
||||
|
onChange={setDefaultValue} |
||||
|
format={dateFormat} |
||||
|
/> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div className='row-items'> |
||||
|
<div>导出</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div style={{ marginTop: 20, textAlign: 'center', flexWrap: 'wrap' }} className='row-items'> |
||||
|
{ |
||||
|
weekTx.map((item, index) => ( |
||||
|
<div key={index} style={{ width: '50%', marginTop: 10 }}> |
||||
|
<div style={{ fontSize: 14 }}>{item.title}</div> |
||||
|
<div style={{ fontWeight: 'bold', fontSize: 14, color: item.color }}>{Number(item.value).toLocaleString()}</div> |
||||
|
</div> |
||||
|
)) |
||||
|
} |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
{/* */} |
||||
|
{transaction[0] && transaction[1] && <div className='box row' style={{ backgroundColor: theme ? '#f5f5f5' : '#333', marginTop: 30 }}> |
||||
|
<div style={{ flex: 4 }}> |
||||
|
<div style={{ fontWeight: 'bold', fontSize: 14 }}>{transaction[0].symbol} 充值提现</div> |
||||
|
{/* <div style={{ fontSize: 14, marginTop: 30 }}>净入金:<span style={{ fontSize: 20, color: '#3BB900', fontWeight: 'bold' }}>2131223</span></div> |
||||
|
<div style={{ fontSize: 14, marginTop: 30 }}>充值提现比:<span style={{ fontSize: 20, color: '#3BB900', fontWeight: 'bold' }}>150%</span></div> */} |
||||
|
<div className='row' style={{ textAlign: 'center', marginTop: 30 }}> |
||||
|
<div style={{ flex: 1 }}> |
||||
|
<div>总充值</div> |
||||
|
<div style={{ fontSize: 20, color: '#3BB900', fontWeight: 'bold' }}>{Number(transaction[0].deposit_amount).toLocaleString()}</div> |
||||
|
</div> |
||||
|
<div style={{ flex: 1 }}> |
||||
|
<div>充值笔数</div> |
||||
|
<div style={{ fontSize: 20, color: '#3BB900', fontWeight: 'bold' }}>{transaction[0].deposit_num}</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div className='row' style={{ textAlign: 'center', marginTop: 20 }}> |
||||
|
<div style={{ flex: 1 }}> |
||||
|
<div>总提现</div> |
||||
|
<div style={{ fontSize: 20, color: '#3BB900', fontWeight: 'bold' }}>{Number(transaction[0].withdrawal_amount).toLocaleString()}</div> |
||||
|
</div> |
||||
|
<div style={{ flex: 1 }}> |
||||
|
<div>提现笔数</div> |
||||
|
<div style={{ fontSize: 20, color: '#3BB900', fontWeight: 'bold' }}>{transaction[0].withdrawal_num}</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div className='solid' style={{ backgroundColor: theme ? '#e8e8e8' : '#555', margin: '0 20px' }}></div> |
||||
|
<div style={{ flex: 4 }}> |
||||
|
<div style={{ fontWeight: 'bold', fontSize: 14 }}>{transaction[1].symbol} 充值提现</div> |
||||
|
<div className='row' style={{ textAlign: 'center', marginTop: 30 }}> |
||||
|
<div style={{ flex: 1 }}> |
||||
|
<div>总充值</div> |
||||
|
<div style={{ fontSize: 20, color: '#3BB900', fontWeight: 'bold' }}>{Number(transaction[1].deposit_amount).toLocaleString()}</div> |
||||
|
</div> |
||||
|
<div style={{ flex: 1 }}> |
||||
|
<div>充值笔数</div> |
||||
|
<div style={{ fontSize: 20, color: '#3BB900', fontWeight: 'bold' }}>{transaction[1].deposit_num}</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div className='row' style={{ textAlign: 'center', marginTop: 20 }}> |
||||
|
<div style={{ flex: 1 }}> |
||||
|
<div>总提现</div> |
||||
|
<div style={{ fontSize: 20, color: '#3BB900', fontWeight: 'bold' }}>{Number(transaction[1].withdrawal_amount).toLocaleString()}</div> |
||||
|
</div> |
||||
|
<div style={{ flex: 1 }}> |
||||
|
<div>提现笔数</div> |
||||
|
<div style={{ fontSize: 20, color: '#3BB900', fontWeight: 'bold' }}>{transaction[1].withdrawal_num}</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div>} |
||||
|
<div style={{ display: 'block', height: 30 }}></div> |
||||
|
</div > |
||||
) |
) |
||||
} |
} |
||||
|
|
||||
|
After Width: 90 | Height: 90 | Size: 589 B |
Write
Preview
Loading…
Cancel
Save
Reference in new issue