service.js
727 Bytes
import {
getMockSchoolList,
saveMockRegistration
} from './mock';
const normalizeSchoolList = (list = []) => list.map((school) => ({
text: school.name,
value: school.id,
children: (school.classes || []).map((item) => ({
text: item.name,
value: item.id
}))
}));
export const fetchSchoolOptions = async () => {
const res = await getMockSchoolList();
if (res.code !== 1) {
throw new Error(res.msg || '获取幼儿园信息失败');
}
return normalizeSchoolList(res.data);
};
export const submitRegistration = async (formData) => {
const res = await saveMockRegistration(formData);
if (res.code !== 1) {
throw new Error(res.msg || '保存报名信息失败');
}
return res.data;
};