import request from '@/utils/request'

/* 用户登录 */
export function login(data) {
  return request({
    url: '/sys/user/login',
    method: 'post',
    data: data,
    toast: false
  })
}
/* 添加用户 */
export function addUser(data) {
  return request({
    url: '/sys/user',
    method: 'POST',
    data: data
  })
}
/* 获取用户详情 */
export function getUser(id) {
  return request({
    url: `/sys/user/${id}`,
    method: 'GET'
  })
}
/* 编辑用户 */
export function updateUser(data) {
  return request({
    url: '/sys/user',
    method: 'PUT',
    data: data
  })
}
/* 删除用户 */
export function deleteUser(id) {
  return request({
    url: `/sys/user/${id}`,
    method: 'DELETE'
  })
}
/* 启用用户 */
export function enableUser(id) {
  return request({
    url: `/sys/user/enable/${id}`,
    method: 'PUT'
  })
}
/* 禁用用户 */
export function disableUser(id) {
  return request({
    url: `/sys/user/disable/${id}`,
    method: 'PUT'
  })
}
/* 重置用户密码 */
export function resetUserPwd(userId) {
  return request({
    url: `/sys/user/resetPassword/${userId}`,
    method: 'PUT'
  })
}

export function authConfig(code) { // 获取是否展示密码眼睛配置
  return request({
    url: '/tparameters/systemConfig?codes=' + code,
    method: 'get',
    errtoast: false
  })
}
export function sendSmsCode(data) { // 获取短信验证码
  return request({
    url: '/auth/sendSmsCode',
    method: 'get',
    params: data
  })
}

export function getInfo(token) {
  return request({
    url: '/sys/user',
    method: 'get',
    // params: { token },
    toast: false
  })
}

export function logout() {
  return request({
    url: '/sys/user/logout',
    method: 'put',
    toast: false
  })
}

// 拉取左边菜单
export function getMenueList() {
  return request({
    url: '/sys/user/menuTree',
    method: 'get',
    toast: false
  })
}

// 修改密码
export function updatePassword(data) {
  return request({
    url: '/sys/user/updatePassword',
    method: 'put',
    data,
    toast: false
  })
}

// 获取验证码
export function getBufferImage() {
  return request({
    url: '/sys/verifyCode',
    method: 'get',
    responseType: 'blob'
  })
}

// 坐席人员 - /tcloudservicecustomers/getCloudCustomer/{centerid}
export function getCloudCustomer(id) {
  return request({
    url: '/tcloudservicecustomers/getCloudCustomer/' + id,
    method: 'get'
  })
}
// 坐席人员 - /tcloudservicecustomers/getCloudCustomerList/{centerid}
export function getCloudCustomerList(id) {
  return request({
    url: '/tcloudservicecustomers/getCloudCustomerList/' + id,
    method: 'get'
  })
}
