92 lines
3.0 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',
2026-01-28 13:38:05 +08:00
getCommonPhrases: 'getCommonPhrases',
saveCommonPhrase: 'saveCommonPhrase',
deleteCommonPhrase: 'deleteCommonPhrase',
getCommonPhraseCategories: 'getCommonPhraseCategories',
saveCommonPhraseCategory: 'saveCommonPhraseCategory',
// 个人常用语接口
getPersonalPhrases: 'getPersonalPhrases',
savePersonalPhrase: 'savePersonalPhrase',
deletePersonalPhrase: 'deletePersonalPhrase',
getPersonalPhraseCategories: 'getPersonalPhraseCategories',
savePersonalPhraseCategory: 'savePersonalPhraseCategory',
deletePersonalPhraseCategory: 'deletePersonalPhraseCategory',
// 宣教文章接口
getArticleCateList: 'getArticleCateList',
getArticleList: 'getArticleList',
getArticle: 'getArticle',
addArticleSendRecord: 'addArticleSendRecord'
2026-01-20 19:36:49 +08:00
},
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'
2026-01-28 13:38:05 +08:00
},
im: {
2026-01-28 14:01:24 +08:00
getUserSig: 'getUserSig',
2026-01-28 13:38:05 +08:00
sendSystemMessage: "sendSystemMessage",
getChatRecordsByGroupId: "getChatRecordsByGroupId",
sendConsultRejectedMessage: "sendConsultRejectedMessage",
endConsultation: "endConsultation",
getGroupListByGroupId: "getGroupListByGroupId",
2026-01-28 14:01:24 +08:00
createConsultGroup: "createConsultGroup",
cancelConsultApplication: "cancelConsultApplication"
2026-01-20 19:36:49 +08:00
}
}
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-28 13:38:05 +08:00
}