// 如果没有通过拦截器配置域名的话，可以在这里写上完整的URL(加上域名部分)
let hotSearchUrl = '/ebapi/store_api/hot_search';
let indexUrl = '/ebapi/public_api/index';

// 此处第二个参数vm，就是我们在页面使用的this，你可以通过vm获取vuex等操作，更多内容详见uView对拦截器的介绍部分：
// https://uviewui.com/js/http.html#%E4%BD%95%E8%B0%93%E8%AF%B7%E6%B1%82%E6%8B%A6%E6%88%AA%EF%BC%9F
const install = (Vue, vm) => {
	// 此处没有使用传入的params参数
	let getSearch = (params = {}) => vm.$u.get(hotSearchUrl, {
		id: 2
	});
	// 此处使用了传入的params参数，一切自定义即可
	let getUserInfo = (params = {}) => vm.$u.get('/system/user/info/', params);//获取用户信息
	
	let getCode = (params = {}) => vm.$u.post('/system/sendmsg/', params); //获取邮箱验证码
	
	let codeLogin = (params = {}) => vm.$u.post('/token2/', params); //邮箱验证码登录
	
	let login = (params = {}) => vm.$u.post('/token/', params); //账户密码登录
	// 将各个定义的接口名称，统一放进对象挂载到vm.$u.api(因为vm就是this，也即this.$u.api)下
	
	let wxmplogin = (params = {}) => vm.$u.post('/wxmplogin/', params); //微信登录
	
	let bindmp = (params = {}) => vm.$u.post('/system/user/bindwxmp/', params); //微信绑定
	
	let unbindmp = (params = {}) => vm.$u.post('/system/user/unbindwxmp/', params); //微信绑定
	
	let getMyInspectTaskList = (params = {}) => vm.$u.get('/quality/subinspecttask/self/', params);
	
	let getSubinspectTask = (id, params)=> vm.$u.get(`/quality/subinspecttask/${id}/`, params);
	
	//获取子任务涉及的单位
	let getSubtaskDepts = (id, params)=> vm.$u.get(`/quality/subinspecttask/${id}/depts/`, params);
	
	//获取子任务单位的详细信息
	let getSubtaskDept = (id, params)=> vm.$u.get(`/quality/inspectdept/${id}/`, params);
	let getInspectRecords = (params)=> vm.$u.get('/quality/inspectrecord/', params);
	let getInspectRecord = (id, params)=> vm.$u.get(`/quality/inspectrecord/${id}/`, params);
	let checkInspectRecord = (id, params)=> vm.$u.put(`/quality/inspectrecord/${id}/check/`, params);
	let startInspectDept = (id, params)=>vm.$u.put(`/quality/inspectdept/${id}/start/`, params);//开始检查
	let upInspectDept = (id, params)=>vm.$u.put(`/quality/inspectdept/${id}/up/`, params);//提交记录
	let appointChecker = (params) => vm.$u.post('/quality/inspectrecord/appoint/', params);//检查指派
	let getDocument = (params={})=>vm.$u.get('/quality/document/', params);//文档
	let getVideos = (params={})=>vm.$u.get('/vod/video/', params);//点播视频
	let getDickey = (params={})=>vm.$u.get('/system/dict/', params);//查询字典
	let putMyVideoView =(id)=>vm.$u.put(`/vod/video/${id}/myview/`);//更新本人观看信息
	
	
	//考试有关
	let getExamList = (params={})=>vm.$u.get('/exam/exam/', params);//考试列表
	let startExam = (id)=>vm.$u.post(`/exam/exam/${id}/start/`);//开始考试
	let submitExam = (id,params={})=>vm.$u.post(`/exam/examrecord/${id}/submit/`,params);//开始考试
	let examRecord = (id,params={})=>vm.$u.get(`/exam/examrecord/self/`,params);//我的考试记录
	let examRecordDetail = (id,params={})=>vm.$u.get(`/exam/examrecord/${id}/`,params);//我的考试记录
	
	vm.$u.api = {getUserInfo, 
				getCode,
				codeLogin,
				login,
				wxmplogin,
				bindmp,
				unbindmp,
				getMyInspectTaskList,
				getSubinspectTask,
				getSubtaskDepts,
				getInspectRecords,
				getSubtaskDept,
				getInspectRecord,
				checkInspectRecord,
				upInspectDept,
				appointChecker,
				startInspectDept,
				getDocument,
				getVideos,
				getDickey,
				putMyVideoView,
				
				getExamList,
				startExam,
				submitExam,
				examRecord,
				examRecordDetail
				};
}

export default {
	install
}