import request from '$project/utils/request'
import Qs from 'qs';

import {
	getToken
} from '$project/utils/storage'

//获取用户角色列表
export function getRoleList() {
	return request({
		url: '/mobile/personInfoApi/findPopedomList',
		data: Qs.stringify({}),
		method: 'post',
	})
}

//切换用户角色列表
export function exchangePopedom(params) {
	return request({
		url: '/mobile/personInfoApi/exchangePopedom',
		data: Qs.stringify(params),
		method: 'post',
	})
}

//退出
export function logOut() {
	return request({
		url: '/mobile/personInfoApi/logOut',
		data: Qs.stringify({}),
		method: 'post',
	})
}

//获取所有功能列表,不包括常用功能
export function getFunList() {
	return request({
		url: '/mobile/icon/findIconByPersonRole',
		data: Qs.stringify({}),
		method: 'post',
	})
}

//获取所有功能列表,包括常用功能
export function getAllFunList(token) {
	var token = token || (getToken() ? getToken() : '');
	return request({
		url: '/mobile/icon/findAllIconByPersonRole',
		data: Qs.stringify({}),
		method: 'post',
		headers: {
			'Authorization': token,
		},
	})
}

//获取所有鉴权功能列表,包括常用功能
export function getAuthFunList(token) {
	var token = token || (getToken() ? getToken() : '');
	return request({
		url: '/mobile/icon/findIconRouteByPerson',
		data: Qs.stringify({}),
		method: 'post',
		headers: {
			'Authorization': token,
		},
	})
}

//保存常用功能
export function saveFun(ids) {
	return request({
		url: '/mobile/icon/updatePersonIcon',
		data: Qs.stringify({
			ids: ids
		}),
		method: 'post',
	})
}
