This commit is contained in:
saplf
2019-09-05 23:24:49 +08:00
parent df25ff4244
commit c8f919ce5a
19 changed files with 658 additions and 37 deletions

View File

@@ -6,7 +6,6 @@ import { HomeFundModelState } from './model';
import { Journal, JournalOp } from '@/types/common';
import Label from '@/components/Label';
import List from '@/components/List';
import { dispatch } from '@/utils/utils';
import styles from './style.less';
@@ -19,6 +18,7 @@ const FundPage: React.FC<HomeFundModelState & DispatchProp> = ({
data,
refreshingBasic,
errorBasic,
loadingDraw,
info,
}) => {
@@ -42,25 +42,26 @@ const FundPage: React.FC<HomeFundModelState & DispatchProp> = ({
<div className="bg" />
<span className="title">{formatMessage({ id: 'home.fund.total' })}</span>
<span className="content">
<span className="large">{info ? info.balanceSum : 0}</span>
<span className="large">{info ? info.sum : 0}</span>
VIC
</span>
<div className={styles.card}>
<div className="left">
<span className="line">
<span className="title2">{formatMessage({ id: 'home.fund.totalVIC' })}</span>
<span className="value">+{info ? info.balanceVIC : 0} VIC</span>
<span className="value">+{info ? info.vic : 0} VIC</span>
</span>
<span className="line">
<span className="title2">{formatMessage({ id: 'home.fund.totalUSDT' })}</span>
<span className="value">+{info ? info.balanceUSDT : 0} USDT</span>
<span className="value">+{info ? info.usdt : 0} USDT</span>
</span>
</div>
<div
className="right app-btn"
onClick={() => dispatch({ type: 'homeFund/gotoDraw' })}
>
{formatMessage({ id: 'home.fund.draw' })}
{loadingDraw ? <Spin size="small" /> : formatMessage({ id: 'home.fund.draw' })}
</div>
</div>
</div>
@@ -79,7 +80,7 @@ const FundPage: React.FC<HomeFundModelState & DispatchProp> = ({
<div className="detail">
{it.detail}
</div>
<div className="small">{it.timestamp}</div>
<div className="small">{it.createdAt}</div>
</div>
</div>
);

View File

@@ -1,7 +1,9 @@
import { Model, routerRedux } from 'dva';
import { message } from 'antd';
import { message, Modal } from 'antd';
import { Journal, FundBasic } from '@/types/common';
import { getFundList, getFundBasic } from './service';
import { getFundList } from './service';
import { checkFundPwd, getFundBasic } from '@/services/common';
import { formatMessage } from 'umi-plugin-locale';
export interface HomeFundModelState {
refreshingList: boolean;
@@ -15,6 +17,7 @@ export interface HomeFundModelState {
info: FundBasic | null;
pageIndex: number;
loadingDraw: boolean;
}
const FundModel: Model = {
@@ -32,6 +35,7 @@ const FundModel: Model = {
info: null,
pageIndex: 1,
loadingDraw: false,
} as HomeFundModelState,
effects: {
@@ -99,6 +103,30 @@ const FundModel: Model = {
});
}
},
*gotoDraw(_, { put, select, call }) {
const { loadingDraw } = yield select((state: any) => state.homeFund);
if (loadingDraw) return;
yield put({ type: 'onUpdateState', loadingDraw: true });
try {
const settled = yield call(checkFundPwd);
if (settled) {
yield put(routerRedux.push('/draw'));
} else {
Modal.confirm({
okText: formatMessage({ id: 'common.ok' }),
cancelText: formatMessage({ id: 'common.cancel' }),
title: formatMessage({ id: 'common.prompt' }),
content: formatMessage({ id: 'home.fund.prompt' }),
onOk: () => { message.warn('暂未完成,请再次点击'); },
});
}
} catch (e) {
message.error(e.message);
} finally {
yield put({ type: 'onUpdateState', loadingDraw: false });
}
},
},
reducers: {

View File

@@ -1,24 +1,12 @@
import http from '@/utils/http';
import { Journal, FundBasic } from '@/types/common';
export async function getFundBasic(): Promise<FundBasic> {
const {
ok,
data,
msg,
} = await http.get<FundBasic>('/fund/detail');
if (ok && data) {
return data;
}
throw Error(msg);
}
import { Journal } from '@/types/common';
export async function getFundList(pageIndex: number, pageSize: number): Promise<Journal[]> {
const {
ok,
data,
msg,
} = await http.get<Journal[]>('/fund/journals', {
} = await http.get<Journal[]>('/fund/actions', {
pageIndex,
pageSize,
});

View File

@@ -86,6 +86,8 @@
.app-btn {
user-select: none;
white-space: nowrap;
width: 80px;
text-align: center;
background-color: @blue-one;
@btn-height: 28px;
height: @btn-height;