Files
vic-user-react/src/pages/home/estate/service.ts
2019-09-03 17:24:52 +08:00

36 lines
729 B
TypeScript

import http from '@/utils/http';
import { Mines, MineBasic } from '@/types/common';
import { loadMineList, storeMineList } from '@/utils/storage';
export async function getMineBasic(): Promise<MineBasic> {
const {
ok,
data,
msg,
} = await http.get<MineBasic>('/mine/basic');
if (ok && data) {
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);
}