import {
	apiurl
} from "./apiurl.js"

// 此处第二个参数vm，就是我们在页面使用的this，你可以通过vm获取vuex等操作，更多内容详见uView对拦截器的介绍部分：
const install = (Vue, vm) => {

	// 测试
	let test = (params = {}) => vm.$u.post(apiurl.testApi, params);
	
	let getPhoneLoginCode = (params = {}) => vm.$u.post(apiurl.phoneLoginCodeUrl, params);
	let phoneLoginAuth = (params = {}) => vm.$u.post(apiurl.phoneLoginAuthUrl, {code:params.code},{Authorization:`Bearer ${params.accessToken}`,user_id:params.userId});
	// 获取自定义富文本内容: 0-包月须知 1-用户服务条款 2-隐私权政策信息 3-收费标准 4-退款温馨提示
	let getSysterms = (params = {}) => vm.$u.get(apiurl.getSystermsApi + params.termsType);
	// 首页轮播
	let getIndexBannerList = (params = {}) => vm.$u.get(apiurl.indexBannerListUrl,params);
	// 首页新闻列表
	let getIndexNewsList = (params = {}) => vm.$u.get(apiurl.indexNewsList,params);
	// 新闻详情
	let getNewsDetails = (params = {}) => vm.$u.get(apiurl.newsDetailsUrl,params);
	// 政策法规详情
	let getPolicyNewsDetails = (params = {}) => vm.$u.get(apiurl.policyNewsDetailsUrl,params);
	// 军人认证
	let veteEduc = (params = {}) => vm.$u.post(apiurl.veteEducUrl, params);
	// 认证状态查询
	let getVeteEducCheck = (params = {}) => vm.$u.get(apiurl.veteEducCheckUrl,params);
	//我的认证申请
	let getVeteEducData = (params = {}) => vm.$u.get(apiurl.veteEducUrl,params);
	// 我的详细信息
	let getmemberinfo = (params = {}) => vm.$u.get(apiurl.memberinfoUrl,params);
	// 首页新闻列表
	let getpolicyNewsList = (params = {}) => vm.$u.get(apiurl.policyNewsListUrl,params);
	// 枚举值key查询 key 新闻类型 news_type, 政策法规 policy_type 人员属性 vete_attribute
	let getDictdataUrl = (params = {}) => vm.$u.get(apiurl.dictdataUrl,params);
	// 适应性培训课程列表
	let getAdaptTrainOnline = (params = {}) => vm.$u.get(apiurl.adaptTrainOnlineUrl,params);
	// 适应性培训课程详情
	let getAdaptTrainOnlineDetails = (params = {}) => vm.$u.get(apiurl.adaptTrainOnlineDetailsUrl+params.id);
	// 适应性培训学习进度
	let getAdaptTrainOnlineRate = (params = {}) => vm.$u.post(apiurl.adaptTrainOnlineRateUrl, params);
	// 上传适应性培训视频播放情况
	let upAdaptTrainOnlineInfo = (params = {}) => vm.$u.post(apiurl.upAdaptTrainOnlineInfoUrl, params);
	// 适应性培训线下内容
	let getAdaptTrainOffline = (params = {}) => vm.$u.get(apiurl.adaptTrainOfflineUrl,params);
	// 查询线下培训详情
	let getAdaptTrainIdOffline = (params = {}) => vm.$u.get(apiurl.adaptTrainIdOfflineUrl+params.id);
	// 页面点击统计
	let postAnalysis = (params = {}) => vm.$u.post(apiurl.analysisUrl, params);
	// 线下培训签到
	let postSignOffline = (params = {}) => vm.$u.post(apiurl.signOfflineUrl, params);
	// 根据身份证号读取信息
	let getIdInfo = (params = {}) => vm.$u.get(apiurl.getIdInfoUrl+params.id);
	// 合作学校分页数据
	let getSchoolList = (params = {}) => vm.$u.get(apiurl.getSchoolListUrl, params);
	
	
	// 将各个定义的接口名称，统一放进对象挂载到vm.$u.api(因为vm就是this，也即this.$u.api)下
	vm.$u.api = {
		test,
		getPhoneLoginCode,
		phoneLoginAuth,
		getSysterms,
		getIndexBannerList,
		getIndexNewsList,
		getNewsDetails,
		veteEduc,
		getVeteEducCheck,
		getmemberinfo,
		getpolicyNewsList,
		getVeteEducData,
		getPolicyNewsDetails,
		getDictdataUrl,
		getAdaptTrainOnline,
		getAdaptTrainOnlineDetails,
		getAdaptTrainOnlineRate,
		upAdaptTrainOnlineInfo,
		getAdaptTrainOffline,
		postAnalysis,
		postSignOffline,
		getAdaptTrainIdOffline,
		getIdInfo,
		getSchoolList
	};
}

export default {
	install
}