import request from '@/utils/request';

// 登录方法
export function login(username, password, newPassword) {
  const data = {
    username,
    password,
    newPassword
  };
  return request({
    url: '/mobile/login',
    method: 'post',
    data: data
  });
}
// 注册
export function register(username, password, newPassword) {
  const data = {
    username,
    password,
    newPassword
  };
  return request({
    url: '/mobile/register',
    method: 'post',
    data: data
  });
}
// 获取验证码
export function getAuthCode(params) {
  return request({
    url: '/mobile/getAuthCode',
    params
  });
}

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

// 退出方法
export function logout() {
  return request({
    url: '/admin/logout',
    method: 'post'
  });
}
export function fetchList(params) {
  return request({
    url: '/admin/list',
    method: 'get',
    params: params
  });
}

export function createAdmin(data) {
  return request({
    url: '/admin/register',
    method: 'post',
    data: data
  });
}

export function updateAdmin(id, data) {
  return request({
    url: '/admin/update/' + id,
    method: 'post',
    data: data
  });
}

export function updateStatus(id, params) {
  return request({
    url: '/admin/updateStatus/' + id,
    method: 'post',
    params: params
  });
}

export function deleteAdmin(id) {
  return request({
    url: '/admin/delete/' + id,
    method: 'post'
  });
}

export function getRoleByAdmin(id) {
  return request({
    url: '/admin/role/' + id,
    method: 'get'
  });
}

export function allocRole(params) {
  return request({
    url: '/admin/role/update',
    method: 'post',
    params
  });
}
