矿场列表
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user