//api集合
let apiApp = {
	login: '/api/mobile/user/login',
	user: '/api/mobile/user/show',
	saveUser: '/api/mobile/user/save',
	getUserMobile: '/api/mobile/user/mobile',
	getConfig: '/api/mobile/user/config',

	getUserAddress: '/api/mobile/user/address',
	saveUserAddress: '/api/mobile/user/address-update',
	delUserAddress: '/api/mobile/user/address-delete',

	saveFeedback: '/api/mobile/user/feedback-update',

	getCard: '/api/mobile/user/get-card',
	getDates: '/api/mobile/user/get-available-dates',
	getExpress:'/api/mobile/user/express-type',
	
	getUserOrder: '/api/mobile/user/delivery',
	addUserOrder: '/api/mobile/user/confirm',

	saveUserOrder: '/api/mobile/user/update-delivery',

	getRegion: '/api/mobile/user/region',
	matchRegion: '/api/mobile/user/region-match',



}

// 此处第二个参数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 getUserMobile = (params = {}) => vm.$u.get(apiApp.getUserMobile, params);
	let getConfig = (params = {}) => vm.$u.get(apiApp.getConfig, params);
	
	let saveUser = (params = {}) => vm.$u.post(apiApp.saveUser, params);
	let getUserAddress = (params = {}) => vm.$u.get(apiApp.getUserAddress, params);
	let saveUserAddress = (params = {}) => vm.$u.post(apiApp.saveUserAddress, params);
	let delUserAddress = (params = {}) => vm.$u.get(apiApp.delUserAddress, params);
	let saveFeedback = (params = {}) => vm.$u.post(apiApp.saveFeedback, params);
	let getCard = (params = {}) => vm.$u.get(apiApp.getCard, params);
	let getDates = (params = {}) => vm.$u.get(apiApp.getDates, params);
	let getExpress = (params = {}) => vm.$u.get(apiApp.getExpress, params);
	

	let getUserOrder = (params = {}) => vm.$u.get(apiApp.getUserOrder, params);
	let addUserOrder = (params = {}) => vm.$u.post(apiApp.addUserOrder, params);
	let saveUserOrder = (params = {}) => vm.$u.post(apiApp.saveUserOrder, params);
	let getRegion = (params = {}) => vm.$u.get(apiApp.getRegion, params);
	let matchRegion = (params = {}) => vm.$u.get(apiApp.matchRegion, params);

	// 将各个定义的接口名称，统一放进对象挂载到vm.$u.api(因为vm就是this，也即this.$u.api)下
	vm.$u.api = {
		login,
		user,
		getUserMobile,
		getConfig,
		saveUser,
		getUserAddress,
		saveUserAddress,
		delUserAddress,
		saveFeedback,
		getCard,
		getDates,
		getExpress,
		getUserOrder,
		addUserOrder,
		saveUserOrder,
		getRegion,
		matchRegion
	};
}

export default {
	install
}