import request from "./http"; const urlsConfig = { corp: { getCorpMemberHomepageInfo: 'getCorpMemberHomepageInfo', getTeamBaseInfo: 'getTeamBaseInfo', getTeamData: 'getTeamData', queryWxJoinedTeams: 'queryWxJoinedTeams', wxAppLogin: 'wxAppLogin', getTeamHealthTemplate: 'getTeamHealthTemplate', getTeamHealthTemps: "getTeamHealthTemps", }, knowledgeBase: { getArticleByIds: 'getArticleByIds', getPageDisease: "getPageDisease" }, member: { addCustomer: 'add', addMedicalRecord: 'addMedicalRecord', bindMiniAppArchive: "bindMiniAppArchive", getCustomerByCustomerId: 'getCustomerByCustomerId', getMiniAppCustomers: 'getMiniAppCustomers', getTeamCustomers: 'getTeamCustomers', getUnbindMiniAppCustomers: 'getUnbindMiniAppCustomers', getCustomerMedicalRecord: 'getCustomerMedicalRecord', getMedicalRecordById: 'getMedicalRecordById', unbindMiniAppArchive: 'unbindMiniAppArchive', updateMedicalRecord: 'updateMedicalRecord' }, wecom: { addContactWay: 'addContactWay' } } const urls = Object.keys(urlsConfig).reduce((acc, path) => { const config = urlsConfig[path] || {}; const keys = Object.keys(config); keys.forEach((key) => { const data = acc[key]; if (data) { throw new Error(`${data[0]}.${data[1]}ε’Œ${path}.${url}重倍了`) } acc[key] = [path, config[key]] return acc }) return acc }, {}) export default async function api(urlId, data) { const config = urls[urlId]; if (!config) { throw new Error(`Unknown URL ID: ${urlId}`); } const [path, type] = config; return request({ url: `/getYoucanData/${path}`, data: { ...data, type, } }) }