import request from '@/utils/request'

/** 接口 */
const Api = {
	save: '/api/sys/user/save',
	edit: '/api/sys/user/edit',
	getDeptWarehouse: '/api/sys/dept/getDeptWarehouse',
	editPassword: '/api/sys/user/password/edit',
	resetPassword: '/api/sys/user/password/reset',	
	role: '/api/sys/user/role',
	login: '/api/login',
	logout: '/api/logout',
	profile: '/api/sys/user/profile',
	connectionTest:''
}

// 登录方法
export function login(username, password, code, uuid) {
	const data = {
		username,
		password,
		code,
		uuid
	}
	return request({
		'url': Api.login,
		headers: {
			isToken: false
		},
		'method': 'post',
		'params': data
	})
}

/** 注册方法  暂时不可用;*/
export function register(data) {
	return request({
		url: '/register',
		headers: {
			isToken: false
		},
		method: 'post',
		data: data
	})
}
/** 个人信息 */
export const profile = data => {
	return request({
		url: Api.profile,
		data: data,
		method: 'GET'
	})
}
/** 部门信息 */
export const getDeptWarehouse = data => {
	return request({
		url: Api.getDeptWarehouse,
		data: data,
		method: 'get'
	})
}

// 获取用户详细信息
export function getInfo() {
	return request({
		'url': '/getInfo',
		'method': 'get'
	})
}

/** 注销 */
export const logout = data => {
  return request({
    url: Api.logout,
    data: data,
    method: 'GET'
  })
}
// 获取验证码
export function getCodeImg() {
	return request({
		'url': '/captchaImage',
		headers: {
			isToken: false
		},
		method: 'get',
		timeout: 20000
	})
}
// 联通性测试
export const connectionTest = data => {
	return request({
		url: Api.profile,
		data: data,
		method: 'GET',
		timeout: 20000
	})
}