import request from 'libs/request'

/*
 * @Desc: 管理
 */

// 登录接口
export function login(data) {
  console.log(data, 'data')
  return request({
    url: 'login',
    method: 'post',
    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 fetchViewerList (params= {}) {
  const defaultParams = {
    registerType: '',
    keyword: params.searchKey,
    pageSize: 10,
    pageNum: 1
  }
  return request.get('viewer/queryViewerList', {params: Object.assign(defaultParams, params)})
}


// 观众修改为讲解员
export function updateViewerToGuide (id) {
  return request.get('viewer/changeToGuide', {params: {viewerId: id}})
}


// 获取讲解员列表
export function fetchGuidList (params= {}) {
  const defaultParams = {
    keyword: params.searchKey,
    pageSize: 10,
    pageNum: 1
  }
  return request.get('viewer/queryGuidList', {params: Object.assign(defaultParams, params)})
}

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

// 修改讲解员资料
export function updateGuide (data) {
  return request.post('viewer/updateGuide', data)
}

// 修改首页运营的数据
export function upadteActivity (data) {
  return request.post('activity/update', data)
}

// 获取最新一个展会的详情
export function getActivityDetail () {
  return request.get('activity/getLatest')
}

export function refreshAdminerInfo (adminId) {
  return request.get('getAdminById', { params: { adminId } })
}
