182 lines
5.5 KiB
JavaScript
182 lines
5.5 KiB
JavaScript
import request from "./http";
|
||
|
||
const urlsConfig = {
|
||
corp: {
|
||
getCorpMemberHomepageInfo: 'getCorpMemberHomepageInfo',
|
||
getTeamBaseInfo: 'getTeamBaseInfo',
|
||
getTeamData: 'getTeamData',
|
||
getTeamBymember: 'getTeamBymember',
|
||
getCurrentTemplate: 'getCurrentTemplate',
|
||
wxAppLogin: 'wxAppLogin',
|
||
getDeptList: 'getRealDeptList',
|
||
getHospitalList: 'getRealHospital',
|
||
addCorpMember: 'addCorpMember',
|
||
getCorpMemberData: 'getCorpMemberData',
|
||
updateCorpMember: 'updateCorpMember',
|
||
addCorpMemberFromWxapp: "addCorpMemberFromWxapp",
|
||
updateCorpMemberFromWxapp: "updateCorpMemberFromWxapp",
|
||
submitCertProfile: 'submitCertProfile',
|
||
getMemberVerifyStatus: "getMemberVerifyStatus"
|
||
},
|
||
|
||
knowledgeBase: {
|
||
getArticleByIds: 'getArticleByIds',
|
||
// 诊断库(对齐 ykt-management-mobile/src/api/knowledgeBase.js)
|
||
getDisease: 'getDisease',
|
||
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'
|
||
},
|
||
|
||
survery: {
|
||
getSurveyCateList: 'getSurveryCateList',
|
||
getSurveyList: 'getList',
|
||
createSurveyRecord: 'createRecord',
|
||
getSurveyDetail: 'getDetail'
|
||
},
|
||
member: {
|
||
addCustomer: 'add',
|
||
updateCustomer: 'update',
|
||
transferCustomers: 'transferCustomers',
|
||
getGroups: 'getGroups',
|
||
createGroup: 'createGroup',
|
||
updateGroup: 'updateGroup',
|
||
removeGroup: 'removeGroup',
|
||
sortGroups: 'sortGroups',
|
||
addGroupIdForMember: 'addGroupIdForMember',
|
||
bindMiniAppArchive: "bindMiniAppArchive",
|
||
getCustomerByCustomerId: 'getCustomerByCustomerId',
|
||
getMiniAppCustomers: 'getMiniAppCustomers',
|
||
getTeamCustomers: 'getTeamCustomers',
|
||
getUnbindMiniAppCustomers: 'getUnbindMiniAppCustomers',
|
||
searchCorpCustomer: 'searchCorpCustomer',
|
||
searchCorpCustomerWithFollowTime: 'searchCorpCustomerWithFollowTime',
|
||
unbindMiniAppArchive: 'unbindMiniAppArchive',
|
||
// 健康档案相关接口(对齐 ykt-management-mobile/src/api/member.js)
|
||
addMedicalRecord: 'addMedicalRecord',
|
||
getMedicalRecordById: 'getMedicalRecordById',
|
||
updateMedicalRecord: 'updateMedicalRecord',
|
||
removeMedicalRecord: 'removeMedicalRecord',
|
||
getCustomerMedicalRecord: 'getCustomerMedicalRecord',
|
||
},
|
||
wecom: {
|
||
addContactWay: 'addContactWay'
|
||
},
|
||
im: {
|
||
getUserSig: 'getUserSig',
|
||
sendSystemMessage: "sendSystemMessage",
|
||
getChatRecordsByGroupId: "getChatRecordsByGroupId"
|
||
},
|
||
todo: {
|
||
getCustomerTodos: 'getCustomerTodos',
|
||
getTodoById: 'getTodoById',
|
||
setTodoStatus: 'setTodoStatus',
|
||
updateTaskTodoResult: 'updateTaskTodoResult',
|
||
updateEvent: 'updateEvent',
|
||
removeTodo: 'removeTodo',
|
||
createEvents: 'createEvents',
|
||
executeManagementPlanTodo: 'executeManagementPlanTodo',
|
||
getManagementPlan: 'getManagementPlan',
|
||
getManagementPlanById: 'getManagementPlanById',
|
||
getNextFollowUpTime: 'getNextFollowUpTime',
|
||
// 服务记录(对齐 ykt-management-mobile/src/api/todo.js)
|
||
getServiceRecord: 'getServiceRecord',
|
||
addServiceRecord: 'addServiceRecord',
|
||
updateServiceRecord: 'updateServiceRecord',
|
||
removeServiceRecord: 'removeServiceRecord',
|
||
getChatRecordsByGroupId: "getChatRecordsByGroupId",
|
||
sendConsultRejectedMessage: "sendConsultRejectedMessage"
|
||
}
|
||
|
||
}
|
||
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
|
||
}, {})
|
||
console.log('urls: ', urls)
|
||
|
||
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,
|
||
}
|
||
})
|
||
}
|
||
|
||
// 宣教文章相关 API
|
||
export async function getArticleCateList(data) {
|
||
return api('getArticleCateList', data);
|
||
}
|
||
|
||
export async function getArticleList(data) {
|
||
return api('getArticleList', data);
|
||
}
|
||
|
||
export async function getArticle(data) {
|
||
return api('getArticle', data);
|
||
}
|
||
|
||
export async function addArticleSendRecord(data) {
|
||
return api('addArticleSendRecord', data);
|
||
}
|
||
|
||
// 问卷相关 API
|
||
export async function getSurveyCateList(data) {
|
||
return api('getSurveyCateList', data);
|
||
}
|
||
|
||
export async function getSurveyList(data) {
|
||
return api('getSurveyList', data);
|
||
}
|
||
|
||
export async function createSurveyRecord(data) {
|
||
return api('createSurveyRecord', data);
|
||
}
|
||
|
||
export async function getSurveyDetail(data) {
|
||
return api('getSurveyDetail', data);
|
||
}
|
||
|
||
|
||
|
||
// IM 系统消息相关 API
|
||
export async function sendConsultRejectedMessage(data) {
|
||
return request({
|
||
url: '/getYoucanData/im',
|
||
data: {
|
||
type: 'sendConsultRejectedMessage',
|
||
...data
|
||
}
|
||
});
|
||
}
|