Browse Source

添加抽奖、版本设置

main
mac 7 days ago
parent
commit
9ccfccfb8b
  1. 15
      src/api/index.ts
  2. 119
      src/pages/lotteryTime/index.tsx
  3. 60
      src/pages/walletVersion/index.tsx
  4. 20
      src/route/routes.ts
  5. 16
      src/utils/index.ts

15
src/api/index.ts

@ -57,5 +57,20 @@ export default {
},
get_visa_list(params: object) {
return $axios.post('/admin/visaList', params)
},
get_lotteryTime() {
return $axios.post('/admin/getLotterySetting')
},
set_lotteryTime(params: object) {
return $axios.post('/admin/setLotterySetting', params)
},
get_walletVersion() {
return $axios.post('/admin/getVersion')
},
set_walletVersion(params: object) {
return $axios.post('/admin/setVersion', params)
},
get_lotteryList(params) {
return $axios.post('/admin/lotteryList', params)
}
}

119
src/pages/lotteryTime/index.tsx

@ -0,0 +1,119 @@
import React, { useEffect, useRef, useState } from 'react';
import { Button, DatePicker, Input, notification, Space } from 'antd';
import { exprotExcel, getTime } from '@/utils';
import api from '@/api';
import moment from 'moment';
import MyTable from '@/components/MyTable';
const { RangePicker } = DatePicker;
const LotteryTime = () => {
const [startTime, setStartTime] = useState(0)
const [endTime, setEndTime] = useState(0)
const RangeRefs = useRef(null)
const saveTime = async () => {
try {
const start_time = Math.floor(startTime / 1000)
const end_time = Math.floor(endTime / 1000)
const res: any = await api.set_lotteryTime({
start_time,
end_time
})
if (res.code === 0) {
notification.success({
message: '保存成功'
})
}
} catch (error) {
}
}
const getData = async () => {
try {
const res: any = await api.get_lotteryTime()
if (res.code === 0) {
setStartTime(res.data.start_time)
setEndTime(res.data.end_time)
}
} catch (error) {
}
}
useEffect(() => {
getData()
}, [])
const columns = [
{
title: 'ID',
width: 100,
dataIndex: "id",
},
{
title: '钱包地址',
width: 300,
dataIndex: "address",
},
{
title: 'BuzzUp DID',
width: 300,
dataIndex: "public_key_min",
},
{
title: '时间',
dataIndex: 'time',
render: (time) => (
<div>{getTime(time * 1000)}</div>
)
},
]
const searchConfigList = [
{
key: 'search',
slot: <Input placeholder='请输入要搜索的内容' style={{ width: 200 }} />,
}
]
return (
<div style={{ marginTop: 20, marginBottom: 50 }}>
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
<div>
{startTime > 0 && endTime > 0 && <RangePicker
ref={RangeRefs}
defaultValue={startTime > 0 && [moment(startTime * 1000), moment(endTime * 1000)]}
showTime={{ format: 'HH:mm' }}
format="YYYY-MM-DD HH:mm"
onChange={(value, dateString) => {
setStartTime(new Date(dateString[0]).getTime())
setEndTime(new Date(dateString[1]).getTime())
}}
/>}
<Button style={{ marginLeft: 10 }} type='primary' onClick={saveTime}></Button>
</div>
<Button style={{ marginLeft: 10 }} type='primary' onClick={() => exprotExcel()}>excel</Button>
</div>
<div style={{ border: '1px solid #333', marginTop: 20 }}></div>
<div style={{ marginTop: 20 }}>
<MyTable
apiFun={api.get_lotteryList}
columns={columns}
searchConfigList={searchConfigList}
/>
</div>
</div>
)
}
export default LotteryTime

60
src/pages/walletVersion/index.tsx

@ -0,0 +1,60 @@
import api from "@/api";
import { Button, Form, Input, notification, Switch } from "antd"
import React, { useEffect, useState } from "react"
const WalletVersion = () => {
const [formWallet] = Form.useForm();
const onFinish = async (values) => {
try {
const res: any = await api.set_walletVersion(values)
if (res.code === 0) {
notification.success({
message: '设置成功'
})
}
} catch (error) {
}
}
const getData = async () => {
try {
const res: any = await api.get_walletVersion()
if (res.code === 0) {
formWallet.setFieldsValue(res.data)
}
} catch (error) {
}
}
useEffect(() => {
getData()
}, [])
return (
<div style={{ marginTop: 20, marginBottom: 40 }}>
<Form form={formWallet} onFinish={onFinish}>
<Form.Item label="Android 版本" name="version_android" >
<Input style={{ maxWidth: 300 }} />
</Form.Item>
<Form.Item label="Android 强制升级" name="must_upgrade_android" valuePropName="checked">
<Switch />
</Form.Item>
<Form.Item label="iOS 版本" name="version_ios">
<Input style={{ maxWidth: 300 }} />
</Form.Item>
<Form.Item label="iOS 强制升级" name="must_upgrade_ios" valuePropName="checked">
<Switch />
</Form.Item>
<div>
<Button type="primary" htmlType="submit"></Button>
</div>
</Form >
</div >
)
}
export default WalletVersion

20
src/route/routes.ts

@ -4,6 +4,8 @@ import System from "@/pages/notify/system"
import { HomeOutlined, SolutionOutlined } from "@ant-design/icons"
import BUZZUPNews from "@/pages/notify/news"
import Visa from "@/pages/visa"
import LotteryTime from "@/pages/lotteryTime"
import WalletVersion from "@/pages/walletVersion"
const routes = [
{
@ -51,6 +53,24 @@ const routes = [
component: Visa,
routes: []
},
{
path: '/walletVersion',
name: '钱包版本管理',
exact: true,
key: 'walletVersion',
icon: SolutionOutlined,
component: WalletVersion,
routes: []
},
{
path: '/lotteryTime',
name: '抽奖设置',
exact: true,
key: 'lotteryTime',
icon: SolutionOutlined,
component: LotteryTime,
routes: []
}
]

16
src/utils/index.ts

@ -1,5 +1,7 @@
import { notification } from 'antd';
import './axios'
import { getBaseUrl } from './axios';
import { store } from '@/store';
export const splitAddress = (address: string, index?: number) => {
try {
@ -46,4 +48,18 @@ export function copy(value: string) {
notification.success({
message: '复制成功'
})
}
export const exprotExcel = async () => {
const { token = '' } = store.getState().storeData.userInfo || {}
const base_url = `${getBaseUrl()}/admin/lotteryExcel`;
const res = await fetch(base_url, {
headers: {
Token: token
},
method: 'get',
})
const blob = await res.blob()
const url = window.URL.createObjectURL(blob)
window.open(url)
}
Loading…
Cancel
Save