62 lines
1.7 KiB
JavaScript
Raw Normal View History

2026-01-20 19:36:49 +08:00
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,
}
})
}