import {
	request
} from '@/untils/AxiosUtils.js';
import {
	getStore
} from '@/untils/store.js'

function getHeader() {
	const platformId = getStore({
		name: 'platformId'
	})
	if (platformId) {
		return {
			'Platform-Id': platformId
		}
	} else {
		return {}
	}
}

/*首页 最新任务(10条)*/
export const newMission = () => {
	return request({
		url: '/api/jobslink-api/missions/front/mission/guestList',
		method: 'get',
		headers: getHeader()
	})
}


/*首页 推荐任务(10条)*/
export const recMission = () => {
	return request({
		url: '/api/jobslink-api/missions/user/mission/interestedList',
		method: 'get',
		headers: getHeader()
	})
}

/*抢任务-附近任务*/
export const nearMission = (current, size, lat, lon, distance) => {
	return request({
		url: '/api/jobslink-api/missions/user/mission/nearByList',
		method: 'get',
		params: {
			current,
			size,
			lat,
			lon,
			distance
		},
		headers: getHeader()
	})
}

/*抢任务-推荐任务*/
export const recommendMission = (current, size, seaStr) => {
	return request({
		url: '/api/jobslink-api/missions/user/mission/recommendList',
		method: 'get',
		params: {
			current,
			size,
			seaStr
		},
		headers: getHeader()
	})
}


/*抢任务-最新任务*/
export const newMissionAll = (current, size, seaStr) => {
	return request({
		url: '/api/jobslink-api/missions/user/mission/lastList',
		method: 'get',
		params: {
			current,
			size,
			seaStr
		},
		headers: getHeader()
	})
}

/*提交抢任务*/
export const submit = (missionNo) => {
	return request({
		url: '/api/jobslink-api/missions/user/mission/missionApply',
		method: 'post',
		params: {
			missionNo
		}
	})
}



/*我的任务*/
export const myMission = (current, size, status) => {
	return request({
		url: '/api/jobslink-api/missions/user/mission/getUserMissionList',
		method: 'get',
		params: {
			current,
			size,
			status
		}
	})
}

/*任务详情*/
export const missionDetail = (missionNo) => {
	return request({
		url: '/api/jobslink-api/missions/front/mission/detail',
		method: 'get',
		params: {
			missionNo
		}
	})
}
