import request from '@/utils/request.js'
import config from '@/config'
import upload from '@/utils/upload'
import {
	getSession
} from '@/utils/auth.js'
const preUrl = '/clientServices.do?iscrypt=1'

export function getUserInfo(useId) {
	return request({
		url: preUrl,
		method: 'post',
		data: {
			serviceId: 'eu_2013V01loadMe',
			params: {
				staffId: useId
			}
		}
	})
}

//检查今日考勤状况
export function checkAttendance({universalid,rizi}) {
	return request({
		url: preUrl,
		method: 'post',
		data: {
			serviceId: 'hr_2018V01CheckAttendance',
			params: {
				universalid,
				rizi
			}
		}
	})
}

//获取我的考勤数据统计
export function getMyTotalCount({
	staffId,
	start_date,
	end_date
}) {
	return request({
		url: preUrl,
		method: 'post',
		data: {
			serviceId: 'hr_2015V01getMyTotalCount',
			params: {
				staffId,
				start_date,
				end_date
			}
		}
	})
}

//考勤打卡
export function createAttendance(params) {
	return request({
		url: preUrl,
		method: 'post',
		data: {
			serviceId: 'hr_2018V01CreateAttendance',
			params: params
		}
	})
}

// 经纬度转地址
export function tranAddress(locationStr) {
	return request({
		baseUrl: 'https://apis.map.qq.com/ws/geocoder/v1/?location=' + locationStr + '&key=' + config.mapKey +
			'&get_poi=1',
		method: 'GET'
	})
}

//修改个人信息
export function modifyMe(params) {
	return request({
		url: preUrl,
		method: 'post',
		data: {
			serviceId: 'eu_2013V01modifyMe',
			params: {
				staffId: params.staffId,
				qq: params.qq,
				msn: params.msn,
				// birthday: params.birthday,
				// sex: params.sex,
				// mail: params.mail,
				// desktopPhone: params.desktopPhone
			}
		}
	})
}

//修改密码
export function changePWD(params) {
	return request({
		url: preUrl,
		method: 'post',
		data: {
			serviceId: 'eu_2013V01ChangePWD',
			params: {
				staffId: params.staffId,
				oldpassword: params.oldpassword,
				newpassword: params.newpassword,
			}
		}
	})
}

//打卡历史记录
export function getMyQDQtAttendance(params) {
	return request({
		url: preUrl,
		method: 'post',
		data: {
			serviceId: 'hr_2018V01GetMyQDQtAttendance',
			params: {
				type: params.type,//1.不限时间2.限制时间
				universalid: params.universalid,
				ks_att_time: params.ks_att_time,
				js_att_time: params.js_att_time,
				pSize: params.pSize,
				p: params.p
			}
		}
	})
}

//头像文件上传
export function uploadAvatarFile(data) {
	return upload({
    url: '/MiniAppUploadAvatarAction.do',
    name: data.name,
    filePath: data.filePath,
	isSession:true,
  })
}

//个人信息头像路径修改
export function updateUserInfoHeaderFileId(params) {
	return request({
		url: preUrl,
		method: 'post',
		data: {
			serviceId: 'miniapp_updateUserInfoPhoto',
			params: {
				userid: params.userid,
				headerFileId: params.headerFileId
			}
		}
	})
}

