ykt-wxapp/utils/api.js

97 lines
2.8 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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'
},
knowledgeBase: {
getArticleByIds: 'getArticleByIds'
},
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',
},
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',
}
}
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,
}
})
}