import request from "./http"; const urlsConfig = { corp: { getCorpMemberHomepageInfo: 'getCorpMemberHomepageInfo', getTeamBaseInfo: 'getTeamBaseInfo', getTeamData: 'getTeamData', queryWxJoinedTeams: 'queryWxJoinedTeams', wxAppLogin: 'wxAppLogin', getTeamHealthTemplate: 'getTeamHealthTemplate', getTeamHealthTemps: "getTeamHealthTemps", getCorpMemberJob: "getCorpMemberJob" }, knowledgeBase: { getArticleByIds: 'getArticleByIds', 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' }, member: { addCustomer: 'add', addMedicalRecord: 'addMedicalRecord', authCustomerToTeam: 'authCustomerToTeam', // 授权客户到团队 bindMiniAppArchive: "bindMiniAppArchive", getCustomerByCustomerId: 'getCustomerByCustomerId', getMiniAppCustomers: 'getMiniAppCustomers', getTeamCustomers: 'getTeamCustomers', getUnbindMiniAppCustomers: 'getUnbindMiniAppCustomers', getCustomerMedicalRecord: 'getCustomerMedicalRecord', getMedicalRecordById: 'getMedicalRecordById', unbindMiniAppArchive: 'unbindMiniAppArchive', updateMedicalRecord: 'updateMedicalRecord', }, wecom: { addContactWay: 'addContactWay' }, im: { getUserSig: 'getUserSig', sendSystemMessage: "sendSystemMessage", getChatRecordsByGroupId: "getChatRecordsByGroupId", sendConsultRejectedMessage: "sendConsultRejectedMessage", endConsultation: "endConsultation", getGroupListByGroupId: "getGroupListByGroupId", createConsultGroup: "createConsultGroup" } } 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 = {}, loading = true) { 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, } }, loading) }