import request from 'libs/request'

/*
 * @Desc: 管理
 */

// 登录接口
export function login(data) {
  console.log(data, 'data')
  return request({
    url: 'login',
    method: 'post',
    data
  })
}

// 注册接口
export function register(data) {
  return request({
    url: 'register',
    method: 'post',
    data
  })
}

// 获取验证码接口
export function getCode(data) {
  data.area_num = '86'
  return request({
    url: `getMsgAuthCode`,
    method: 'get',
    params: data
  })
}

// 修改密码
export function changePassword (data) {
  return request({
    url: `changePassword`,
    method: 'post',
    data: data
  })
}

// 获取管理员列表
export function fetchUserList (params= {}) {
  const defaultParams = {
    query_name: params.searchKey,
    page_size: 10,
    page_num: 1
  }
  return request.get('listAdmin', {params: Object.assign(defaultParams, params)})
}

export function fetchRoleList () {
  return request.get('sysRole/list')
}
// 获取首页统计信息
export function getHomeData () {
  return request.get('home')
}

export function updateUser (data) {
  return request.post('changeInfo', data)
}

