//api集合
let apiAuth = {
	login: "/api/nurse/auth/login",
	me: "/api/nurse/auth/me",
	logout: "/api/nurse/auth/logout",
	save: "/api/nurse/auth/save",
};

let apiTask = {
	nurseList: "/api/nurse/nurse-list",
	nurseDetail: "/api/nurse/nurse-detail",
	nurseSave: "/api/nurse/nurse-save",
	processSave: "/api/nurse/process-save",
	nurseCalendar: "/api/nurse/nurse-calendar",
	noticeList: "/api/nurse/notice-list",
	noticeDetail: "/api/nurse/notice-detail",
	statistic: "/api/nurse/statistic",
	customerAndOrder: "/api/nurse/customer-and-order",
	scheduleSave: "/api/nurse/schedule-save",
};
//站长
let apiAdmin = {
	login: "/api/admin/auth/login",
	logout: "/api/admin/auth/logout",
	me: "/api/admin/auth/me",
	scheduleList: "/api/admin/schedule/schedule-index",
	customerList: "/api/admin/customer/get-list",
	saveCallback: "/api/admin/schedule-list-callbacks/save",
	saveCheck: "/api/admin/schedule-list-checks/save",
	callbackList: "/api/admin/schedule-list-callbacks/get-list",
	callbackDetail: "/api/admin/schedule-list-callbacks/get-form/",
	checkList: "/api/admin/schedule-list-checks/get-list",
	checkDetail: "/api/admin/schedule-list-checks/get-form/",
	productTypeList: "/api/admin/product-type/get-list",
	saveLongInsurance: "/api/admin/long-insurance/save",
	longInsuranceList: "/api/admin/long-insurance/get-list",
	longInsuranceDetail: "/api/admin/long-insurance/get-form/",
}
// 此处第二个参数vm，就是我们在页面使用的this，你可以通过vm获取vuex等操作
const install = (Vue, vm) => {
	//api方法
	let login = (data = {}) => vm.$u.post(apiAuth.login, data);
	let me = (data = {}) => vm.$u.post(apiAuth.me, data);
	let logout = (data = {}) => vm.$u.post(apiAuth.logout, data);
	let save = (data = {}) => vm.$u.post(apiAuth.save, data);

	let nurseList = (params = {}) => vm.$u.get(apiTask.nurseList, params);
	let nurseDetail = (params = {}) => vm.$u.get(apiTask.nurseDetail, params);
	let nurseSave = (data = {}) => vm.$u.post(apiTask.nurseSave, data);
	let processSave = (data = {}) => vm.$u.post(apiTask.processSave, data);
	let nurseCalendar = (params = {}) => vm.$u.get(apiTask.nurseCalendar, params);
	let noticeList = (params = {}) => vm.$u.get(apiTask.noticeList, params);
	let noticeDetail = (params = {}) => vm.$u.get(apiTask.noticeDetail, params);
	let statistic = (params = {}) => vm.$u.get(apiTask.statistic, params);
	let customerAndOrder = (params = {}) => vm.$u.get(apiTask.customerAndOrder, params);
	let scheduleSave = (data = {}) => vm.$u.post(apiTask.scheduleSave, data)

	//站长
	let adminLogin = (data = {}) => vm.$u.post(apiAdmin.login, data);
	let adminLogout = (data = {}) => vm.$u.post(apiAdmin.logout, data);
	let adminMe = (data = {}) => vm.$u.post(apiAdmin.me, data);
	let adminScheduleList = (data = {}) => vm.$u.get(apiAdmin.scheduleList, data);
	let adminCustomerList = (data = {}) => vm.$u.get(apiAdmin.customerList, data);
	let adminSaveCallback = (data = {}) => vm.$u.post(apiAdmin.saveCallback, data);
	let adminSaveCheck = (data = {}) => vm.$u.post(apiAdmin.saveCheck, data);
	let adminCallbackList = (data = {}) => vm.$u.get(apiAdmin.callbackList, data);
	let adminCallbackDetail = (id) => vm.$u.get(apiAdmin.callbackDetail + id);
	let adminCheckList = (data = {}) => vm.$u.get(apiAdmin.checkList, data);
	let adminCheckDetail = (id) => vm.$u.get(apiAdmin.checkDetail + id);
	let adminProductTypeList = (data) => vm.$u.get(apiAdmin.productTypeList, data);
	let adminSaveLongInsurance = (data) => vm.$u.post(apiAdmin.saveLongInsurance, data);
	let adminLongInsuranceList = (data) => vm.$u.get(apiAdmin.longInsuranceList, data);
	let adminLongInsuranceDetail = (id) => vm.$u.get(apiAdmin.longInsuranceDetail + id);
	// 将各个定义的接口名称，统一放进对象挂载到vm.$u.api(因为vm就是this，也即this.$u.api)下
	vm.$u.api = {
		login,
		me,
		logout,
		save,
		nurseList,
		nurseDetail,
		nurseSave,
		processSave,
		nurseCalendar,
		noticeList,
		noticeDetail,
		statistic,
		customerAndOrder,
		scheduleSave,

		adminLogin,
		adminLogout,
		adminMe,
		adminScheduleList,
		adminCustomerList,
		adminSaveCallback,
		adminSaveCheck,
		adminCallbackList,
		adminCallbackDetail,
		adminCheckList,
		adminCheckDetail,
		adminProductTypeList,
		adminSaveLongInsurance,
		adminLongInsuranceList,
		adminLongInsuranceDetail
	};
};

export default {
	install,
};
