矿场列表

This commit is contained in:
saplf
2019-09-03 17:24:52 +08:00
parent 47d7819f2d
commit 8742eedac8
13 changed files with 492 additions and 263 deletions

View File

@@ -1,21 +1,34 @@
import http from '@/utils/http';
import { Estates, EstateType } from '@/types/common';
import { calcEstate } from '@/utils/transform';
import { Mines, MineBasic } from '@/types/common';
import { loadMineList, storeMineList } from '@/utils/storage';
export interface EstateList {
total: number;
list: Estates;
}
export async function getEstateList(pageIndex: number, pageSize: number, type: EstateType) {
export async function getMineBasic(): Promise<MineBasic> {
const {
ok,
data,
msg,
} = await http.get<EstateList>('/estateorder/list', { type, pageIndex, pageSize });
} = await http.get<MineBasic>('/mine/basic');
if (ok && data) {
data.list.forEach(it => it.type = type);
data.list.forEach(calcEstate);
return data;
}
throw Error(msg);
}
export async function getMineList(refresh = false): Promise<Mines> {
if (!refresh) {
const dataCached = loadMineList();
if (dataCached && dataCached.length) {
return dataCached;
}
}
const {
ok,
data,
msg,
} = await http.get<Mines>('/mine/list');
if (ok && data) {
storeMineList(data);
return data;
}
throw Error(msg);