const globalUrl = process.uniEnv || {}
const ucenterApiUrl = globalUrl.ucenterUrl.apiUrl
const collegeApiUrl = globalUrl.ucenterUrl.xueUrl
const sysApiUrl = globalUrl.systemUrl.apiUrl
let learnApiFun = function(vm){
	
	/* 通知消息基本信息 */
	let getTrainingNoticeList = async (params = {}) => await vm.$u.get(ucenterApiUrl+'/v1/notice/list', params);
	
	/* 获取学习视频基本信息 */
	let CourseList = async (params = {}) => await vm.$u.get(collegeApiUrl+'/v1/course-details',params);
	/* 获取章节详情 */
	let ChapterDetails = async (params = {}) => await vm.$u.get(collegeApiUrl+'/v1/chapter-sections',params);
	/* 获取课程节信息*/
	let CourseSection  = async (params = {}) => await vm.$u.get(collegeApiUrl+'/v1/section-details',params);
	/* 更新学习情况*/
	let updateLearnCourses  = async (params = {}) => await vm.$u.post(collegeApiUrl+'/v1/update-learn-courses',params);

    /* 获取考试结果 */
    let getExamResult  = async (examId, params = {}) => await vm.$u.post(sysApiUrl + '/wxh-worker-rest/rest/exam/serviceRule/userExamInfo/' + vm.vuex_token + '?examId=' + examId, params);
    /* 申请考试 */
    let applyExam  = async (examId, params = {}) => await vm.$u.post(sysApiUrl + '/wxh-worker-rest/rest/exam/serviceRule/' + vm.vuex_token + '?examId=' + examId, params);
    /* 获取下一题 */
    let getNextQuestion  = async (userExamId, questionId, userAnswerIds, params = {}) => await vm.$u.post(sysApiUrl + '/wxh-worker-rest/rest/exam/serviceRule/next/' + vm.vuex_token + '?userExamId=' + userExamId + '&questionId=' + questionId + '&userAnswerIds=' + (userAnswerIds || "9999"), params);
    /* 获取版本号*/
    let getVersionInfo  = async (version) => await vm.$u.get(ucenterApiUrl +'/v1/version/info?version=' + version);
	const learnApi = {
		getTrainingNoticeList,CourseList,ChapterDetails,CourseSection,updateLearnCourses,getExamResult,applyExam,getNextQuestion,getVersionInfo
	}
	return learnApi
}

module.exports =  {
	learnApiFun
}