import axios from 'axios';
// var baseURL='https://www.scxjc.club'
var baseURL = ''
axios.interceptors.request.use(
	config => {
		const token = localStorage.getItem('token');
		// if (config.url.indexOf('downloadzip') >= 0) {
		// if (token) { // 判断是否存在token，如果存在的话，则每个http header都加上token                      
		// 	config.headers.Authorization = `${token}`;   
		// } else {
		// 	//未登录
		// 	window.location.hash = "/login";
		// }
		// } 
		return config;
	},
	err => {
		return Promise.reject(err);
	});
axios.interceptors.response.use(function (response) {
	// console.log(response.headers)
	// IE 8-9 
	if (response.data == null && response.config.responseType === 'json' && response.request.responseText != null) {
		try {
			// eslint-disable-next-line no-param-reassign
			response.data = JSON.parse(response.request.responseText);
		} catch (e) {
			// ignored
		}
	}
	// 对响应数据做点什么
	if (response.data.code == 401) {
		// window.location.hash = "/login";
		// window.location.hash = "/";
	}
	if (response.data.code == 305) {
		// window.location.hash = "/";
	}
	return response;
}, function (error) {
	// 对响应错误做点什么
	if (error.request.status == 403) {
		// window.location.hash = "/login";
		window.location.hash = "/";
	}
	// console.log(Object.getOwnPropertyNames(error))
	// console.log(error.request,error.message)
	return Promise.reject(error);
});
export default {
	//登录
	login: params => {
		return axios.post(`${baseURL}/api/account/login`, params);
	},
	logout: params => {
		return axios.post(`${baseURL}/api/account/logout`, params);
	},
	// 全局账号信息
	getAccountInfo: params => {
		return axios.get(`${baseURL}/api/account/info`)
	},
	// 验证码
	getCode: params => {
		return axios.get(`${baseURL}/api/account/imgcode`)
	},
	// 账号
	getUserList: params => {
		return axios.get(`${baseURL}/api/admin/user/list`, { params: params })
	},
	getAllSysUserList: params => {
		return axios.get(`${baseURL}/api/admin/user/all`, { params: params })
	},
	getUserinfoList: params => {
		return axios.get(`${baseURL}/api/admin/userinfo/list`, { params: params })
	},
	// 获取用户待选期刊列表
	getUserJournals: () => {
		return axios.get(`${baseURL}/api/admin/user/journals`)
	},
	// 获取用户待选角色列表
	getUserRoles: () => {
		return axios.get(`${baseURL}/api/admin/user/roles`)
	},
	//新增管理员
	addUser: params => {
		return axios.post(`${baseURL}/api/admin/user`, params);
	},
	// 修改管理员
	editUser: params => {
		return axios.put(`${baseURL}/api/admin/user`, params);
	},
	// 删除管理员
	delUser: params => {
		return axios.delete(`${baseURL}/api/admin/user`, { params: params });
	},
	// 获取角色权限
	getUserPermissions: () => {
		return axios.get(`${baseURL}/api/admin/user/permissions`)
	},
	// 新增表单模板
	addTemplate: params => {
		return axios.post(`${baseURL}/api/admin/message/template`, params);
	},
	// 编辑表单模板
	editTemplate: params => {
		return axios.put(`${baseURL}/api/admin/message/template`, params);
	},
	editTemplateStatus: params => {
		return axios.put(`${baseURL}/api/admin/message/template/status`, params);
	},
	// 删除表单模板
	delTemplate: params => {
		return axios.delete(`${baseURL}/api/admin/message/template`, { params: params });
	},
	// 获取模板详情
	getTemplate: params => {
		return axios.get(`${baseURL}/api/admin/message/template`, { params: params });
	},
	// 获取模板列表
	getTemplateList: params => {
		return axios.get(`${baseURL}/api/admin/message/template/list`, { params: params })
	},
	//获取所有模板列表
	getAllTemplateList: params => {
		return axios.get(`${baseURL}/api/admin/message/template/all`, { params: params })
	},
	// 新增角色
	addRole: params => {
		return axios.post(`${baseURL}/api/admin/role`, params);
	},
	// 修改角色
	editRole: params => {
		return axios.put(`${baseURL}/api/admin/role`, params);
	},
	delRole: params => {
		return axios.delete(`${baseURL}/api/admin/role`, { params: params });
	},
	// 获取角色列表
	getRoleList: params => {
		return axios.get(`${baseURL}/api/admin/role/list`, { params: params });
	},
	// 获取角色详情
	getRoleInfo: params => {
		return axios.get(`${baseURL}/api/admin/role`, { params: params });
	},
	// 消息管理
	addMessage: params => {
		return axios.post(`${baseURL}/api/admin/message`, params);
	},
	editMessage: params => {
		return axios.put(`${baseURL}/api/admin/message`, params);
	},
	editMessageStatus: params => {
		return axios.put(`${baseURL}/api/admin/message/status`, params);
	},
	getMessageList: params => {
		return axios.get(`${baseURL}/api/admin/message/list`, { params: params });
	},
	getMessageReceiverList: params => {
		return axios.get(`${baseURL}/api/admin/message/receiver/list`, { params: params });
	},
	getMessageInfo: params => {
		return axios.get(`${baseURL}/api/admin/message`, { params: params });
	},
	delMessageInfo: params => {
		return axios.delete(`${baseURL}/api/admin/message`, { params: params });
	},
	uploadFile: params => {
		return axios.post(`${baseURL}/api/admin/uploadfile`, params);
	},
	saveSurveyResult: params => {
		return axios.post(`${baseURL}/api/admin/message/survey/result`, params);
	},
	saveSurveyResultOut: params => {
		return axios.post(`${baseURL}/api/admin/message/survey/result/out`, params);
	},
	getMessageSurveyAnalyse: params => {
		return axios.get(`${baseURL}/api/admin/message/survey/analyse`, { params: params });
	},
	getMessageSurveyAnalyseOut: params => {
		return axios.get(`${baseURL}/api/admin/message/survey/analyse/out`, { params: params });
	},
	getMessageSurveyQuestionAnalyse: params => {
		return axios.get(`${baseURL}/api/admin/message/survey/question/analyse`, { params: params });
	},
	downloadSurveyResult: params => {
		return axios.get(`${baseURL}/api/admin/message/survey/result/download`, {
			params: params, responseType: "blob"
		});
	},
	downloadSurveyResultOut: params => {
		return axios.get(`${baseURL}/api/admin/message/survey/result/download/out`, {
			params: params, responseType: "blob"
		});
	},
	downloadAnalyseAll:params => {
		return axios.get(`${baseURL}/api/admin/message/survey/result/download/all`, {
			params: params, responseType: "blob"
		});
	},
	downloadAnalyseItem:params => {
		return axios.post(`${baseURL}/api/admin/message/survey/result/download/item`,params,{responseType:"blob"});
	},
	showAnalyseItem: params => {
		return axios.get(`${baseURL}/api/admin/message/survey/result/show/item`, { params: params });
	},
	// 通知管理
	addNotice: params => {
		return axios.post(`${baseURL}/api/admin/message/notice`, params);
	},
	editNotice: params => {
		return axios.put(`${baseURL}/api/admin/message/notice`, params);
	},
	getNoticeList: params => {
		return axios.get(`${baseURL}/api/admin/message/notice/list`, { params: params });
	},
	getNoticeInfo: params => {
		return axios.get(`${baseURL}/api/admin/message/notice`, { params: params });
	},
	delNotice: params => {
		return axios.delete(`${baseURL}/api/admin/message/notice`, { params: params });
	},
	getNoticeAnalyse: params => {
		return axios.get(`${baseURL}/api/admin/message/notice/analyse`, { params: params });
	},
	downloadNoticeAnalyse: params => {
		return axios.get(`${baseURL}/api/admin/message/notice/analyse/download`, {
			params: params, responseType: "blob"
		});
	},
	// 会议相关
	getCityList: params => {
		return axios.get(`${baseURL}/api/admin/common/city`, { params: params });
	},
	getAllOrganizer: params => {
		return axios.get(`${baseURL}/api/admin/journal/organizer/all`, { params: params });
	},
	// 文章相关
	getArticleList: params => {
		return axios.get(`${baseURL}/api/admin/article/list`, { params: params });
	},
	getArticle: params => {
		return axios.get(`${baseURL}/api/admin/article`, { params: params });
	},
	addArticle: params => {
		return axios.post(`${baseURL}/api/admin/article`, params);
	},
	updateArticle: params => {
		return axios.put(`${baseURL}/api/admin/article`, params);
	},
	delArticle: params => {
		return axios.delete(`${baseURL}/api/admin/article`, { params: params });
	},
	searchJournalList: params => {
		return axios.get(`${baseURL}/api/admin/journal/search`, { params: params });
	},
	// 会议管理相关
	getConferenceList: params => {
		return axios.get(`${baseURL}/api/admin/conference/list`, { params: params });
	},
	addConference: params => {
		return axios.post(`${baseURL}/api/admin/conference`, params);
	},
	getConference: params => {
		return axios.get(`${baseURL}/api/admin/conference`, {params:params});
	},
	putConference: params => {
		return axios.put(`${baseURL}/api/admin/conference`, params);
	},
	deleteConference: params => {
		return axios.delete(`${baseURL}/api/admin/conference`, {params:params});
	},
	getSignupList: params => {
		return axios.get(`${baseURL}/api/admin/signup/list`, { params: params });
	},
	putSignup: params => {
		return axios.put(`${baseURL}/api/admin/signup`, params);
	},
	getVerifierList: params => {
		return axios.get(`${baseURL}/api/admin/verifier/list`, { params: params });
	},
	addVerifier: params => {
		return axios.post(`${baseURL}/api/admin/verifier`, params);
	},
	deleteVerifier: params => {
		return axios.delete(`${baseURL}/api/admin/verifier`, {params:params});
	},
	addConferenceHotel: params => {
		return axios.post(`${baseURL}/api/admin/conference/hotel`, params);
	},
	getConferenceHotel: params => {
		return axios.get(`${baseURL}/api/admin/conference/hotel`, {params:params});
	},
	deleteConferenceHotel: params => {
		return axios.delete(`${baseURL}/api/admin/conference/hotel`, {params:params});
	},
	updown: params => {
		return axios.put(`${baseURL}/api/admin/conference/hotel/rank`, params);
	},
	getHotelList: params => {
		return axios.get(`${baseURL}/api/admin/hotel/list`, { params: params });
	},
	addHotel: params => {
		return axios.post(`${baseURL}/api/admin/hotel`, params);
	},
	editHotel: params => {
		return axios.put(`${baseURL}/api/admin/hotel`, params);
	},
	delHotel: params => {
		return axios.delete(`${baseURL}/api/admin/hotel`, {params:params});
	},
	getHotel: params => {
		return axios.get(`${baseURL}/api/admin/hotel`, {params:params});
	},
	// 活动管理
	getActivityList: params => {
		return axios.get(`${baseURL}/api/admin/activity/list`, { params: params });
	},
	addActivity: params => {
		return axios.post(`${baseURL}/api/admin/activity`, params);
	},
	getActivity: params => {
		return axios.get(`${baseURL}/api/admin/activity`, {params:params});
	},
	putActivity: params => {
		return axios.put(`${baseURL}/api/admin/activity`, params);
	},
	// 期刊管理相关
	getJournalList: params => {
		return axios.get(`${baseURL}/api/admin/journal/list`, { params: params });
	},
	getJournal: params => {
		return axios.get(`${baseURL}/api/admin/journal`, { params: params });
	},
	addJournal: params => {
		return axios.post(`${baseURL}/api/admin/journal`, params);
	},
	updateJournal: params => {
		return axios.put(`${baseURL}/api/admin/journal`, params);
	},
	delJournal: params => {
		return axios.delete(`${baseURL}/api/admin/journal`, { params: params });
	},
	searchSubjectList: params => {
		return axios.get(`${baseURL}/api/admin/subject/search`, { params: params });
	},
	searchOrganizerList: params => {
		return axios.get(`${baseURL}/api/admin/organizer/search`, { params: params });
	},
	// 主办单位
	getOrganizerList: params => {
		return axios.get(`${baseURL}/api/admin/organizer/list`, { params: params });
	},
	addOrganizer: params => {
		return axios.post(`${baseURL}/api/admin/organizer`, params);
	},
	updateOrganizer: params => {
		return axios.put(`${baseURL}/api/admin/organizer`, params);
	},
	delOrganizer: params => {
		return axios.delete(`${baseURL}/api/admin/organizer`, { params: params });
	},
	getOrganizer: params => {
		return axios.get(`${baseURL}/api/admin/organizer`, { params: params });
	},
	// 学科
	getSubjectList: params => {
		return axios.get(`${baseURL}/api/admin/subject/list`, { params: params });
	},
	addSubject: params => {
		return axios.post(`${baseURL}/api/admin/subject`, params);
	},
	updateSubject: params => {
		return axios.put(`${baseURL}/api/admin/subject`, params);
	},
	delSubject: params => {
		return axios.delete(`${baseURL}/api/admin/subject`, { params: params });
	},
	getSubject: params => {
		return axios.get(`${baseURL}/api/admin/subject`, { params: params });
	},
}