You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.6 KiB
TypeScript
52 lines
1.6 KiB
TypeScript
2 months ago
|
import { failMockApiProps, successMockApiProps } from "../typing";
|
||
|
export function fetchMockSuccessFullByOther({
|
||
|
data,
|
||
|
msg
|
||
|
}): successMockApiProps {
|
||
|
// return {
|
||
|
// code: 0, // 0 成功
|
||
|
// success: true, // true 成功
|
||
|
// data: data || null, // mock业务层数据
|
||
|
// msg: msg | "ok", // 成功提示
|
||
|
// isMock: true // true 标识当前是模拟数据
|
||
|
// } as successMockApiProps;
|
||
|
const result: successMockApiProps = {
|
||
|
code: 0, // 0 成功
|
||
|
success: true, // true 成功
|
||
|
data: data || null, // mock业务层数据
|
||
|
msg: msg as string | "ok", // 成功提示
|
||
|
isMock: true // true 标识当前是模拟数据
|
||
|
};
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
export function fetchMockFailFullByOther({ data, msg }): failMockApiProps {
|
||
|
// return {
|
||
|
// code: 599, // 0 成功
|
||
|
// success: true, // true 成功
|
||
|
// data: data || null, // mock业务层数据
|
||
|
// msg: msg | "fail", // 成功提示
|
||
|
// isMock: true // true 标识当前是模拟数据
|
||
|
// } as failMockApiProps;
|
||
|
const result: failMockApiProps = {
|
||
|
code: 599, // 0 成功
|
||
|
success: false, // true 成功
|
||
|
data: data || null, // mock业务层数据
|
||
|
msg: msg as string | "fail", // 成功提示
|
||
|
isMock: true // true 标识当前是模拟数据
|
||
|
};
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
// 分页展示
|
||
|
export function fetchCurrPageByList({ data }): successMockApiProps {
|
||
|
// console.log("fetchCurrPageByList_data", data);
|
||
|
const { page, pageSize } = data;
|
||
|
const prevPage = page - 1;
|
||
|
const currPageData = {
|
||
|
...data,
|
||
|
list: data.list.slice(prevPage * pageSize, page * pageSize)
|
||
|
};
|
||
|
return fetchMockSuccessFullByOther({ data: currPageData });
|
||
|
}
|