//api集合
let apiApp = {
	login: '/api/mobile/user/wechat-login',
	user: '/api/mobile/user/show',
	saveUser: '/api/mobile/user/save',
	getAppId: '/api/mobile/user/wechat-login-url',
	getQuestions: '/api/mobile/quiz/get-questions',
	getPoints: '/api/mobile/map-point/point-list',
	baseFormIndex: '/api/mobile/base-form/index',
	baseFormShow: '/api/mobile/base-form/show',
	baseFormSave: '/api/mobile/base-form/save',
	baseFormDestroy: '/api/mobile/base-form/destroy',
	saveQuiz: '/api/mobile/map-point/save-quiz',
	pointDetail: '/api/mobile/map-point/point-detail',
	share: '/api/mobile/user/wechat-share',
	savePoster: '/api/mobile/vr/save-poster',
	getPoster: '/api/mobile/vr/get-poster',
}

// 此处第二个参数vm，就是我们在页面使用的this，你可以通过vm获取vuex等操作
const install = (Vue, vm) => {

	//api方法
	let login = (params = {}) => vm.$u.get(apiApp.login, params);
	let user  = (params = {}) => vm.$u.get(apiApp.user, params);
	let getAppId = (params = {}) => vm.$u.get(apiApp.getAppId, params);
    let getQuestions = (params = {}) => vm.$u.get(apiApp.getQuestions, params);
	let getPoints = (params = {}) => vm.$u.get(apiApp.getPoints, params)
	let baseFormIndex = (params = {}) => vm.$u.get(apiApp.baseFormIndex, params);
	let baseFormShow = (params = {}) => vm.$u.get(apiApp.baseFormShow, params);
	let baseFormSave = (data = {}) => vm.$u.post(apiApp.baseFormSave, data);
	let baseFormDestroy = (params = {}) => vm.$u.post(apiApp.baseFormDestroy, params);
	let saveQuiz = (params = {}) => vm.$u.post(apiApp.saveQuiz, params);
	let pointDetail = (params = {}) => vm.$u.get(apiApp.pointDetail, params);
	let share = (params = {}) => vm.$u.get(apiApp.share, params);
	let savePoster = (params = {}) => vm.$u.get(apiApp.savePoster, params);
	let getPoster = (params = {}) => vm.$u.get(apiApp.getPoster, params)
	let saveUser = (params = {}) => vm.$u.post(apiApp.saveUser, params);
	// 将各个定义的接口名称，统一放进对象挂载到vm.$u.api(因为vm就是this，也即this.$u.api)下
	vm.$u.api = { login, getAppId, getQuestions, baseFormIndex, baseFormShow, baseFormSave, baseFormDestroy, getPoints, saveQuiz, pointDetail, share, savePoster, user, saveUser, getPoster };
}

export default {
	install
}
