64 lines
1.8 KiB
JavaScript
Raw Permalink 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",
2026-01-21 10:35:08 +08:00
getCorpMemberJob: "getCorpMemberJob"
2026-01-20 19:36:49 +08:00
},
knowledgeBase: {
getArticleByIds: 'getArticleByIds',
getPageDisease: "getPageDisease"
},
member: {
addCustomer: 'add',
addMedicalRecord: 'addMedicalRecord',
2026-01-21 10:35:08 +08:00
authCustomerToTeam: 'authCustomerToTeam', // 授权客户到团队
2026-01-20 19:36:49 +08:00
bindMiniAppArchive: "bindMiniAppArchive",
getCustomerByCustomerId: 'getCustomerByCustomerId',
getMiniAppCustomers: 'getMiniAppCustomers',
getTeamCustomers: 'getTeamCustomers',
getUnbindMiniAppCustomers: 'getUnbindMiniAppCustomers',
getCustomerMedicalRecord: 'getCustomerMedicalRecord',
getMedicalRecordById: 'getMedicalRecordById',
unbindMiniAppArchive: 'unbindMiniAppArchive',
2026-01-21 10:35:08 +08:00
updateMedicalRecord: 'updateMedicalRecord',
2026-01-20 19:36:49 +08:00
},
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
}, {})
2026-01-21 10:35:08 +08:00
export default async function api(urlId, data = {}, loading = true) {
2026-01-20 19:36:49 +08:00
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,
}
2026-01-21 10:35:08 +08:00
}, loading)
2026-01-20 19:36:49 +08:00
}