import http from '@/utils/request'

/** 注册 */
export const userRegister = data => {
  return http({
    url: '/api/register',
    method: 'post',
    data
  })
}

/** 登录 */
export const userLogin = data => {
  return http({
    url: '/api/login',
    method: 'post',
    data
  })
}

/** 退出登录 */
export const userLogout = () => {
  return http({
    url: '/api/mobile/out',
    method: 'get'
  })
}

/** 获取用户信息 */
export const getUserData = () => {
  return http({
    url: '/api/userInfo',
    method: 'get'
  })
}

/** 修改用户信息 */
export const updateUserData = data => {
  return http({
    url: '/api/user/edit',
    method: 'put',
    data
  })
}

/** 获取用户地址列表 */
export const getUserAddress = (data, loading = true) => {
  return http({
    url: '/api/service/userAddress/list',
    method: 'get',
    loading,
    data
  })
}

/** 获取用户地址详情 */
export const getUserAddressDetail = id => {
  return http({
    url: `/api/service/userAddress/${id}`,
    method: 'get'
  })
}

/** 添加地址 */
export const addUserAddress = data => {
  return http({
    url: '/api/service/userAddress',
    method: 'post',
    data
  })
}

/** 修改地址 */
export const updateUserAddress = data => {
  return http({
    url: '/api/service/userAddress',
    method: 'put',
    data
  })
}

/** 删除地址 */
export const deleteUserAddress = id => {
  return http({
    url: `/api/service/userAddress/${id}`,
    method: 'delete'
  })
}

/** 获取全国省市区县辖区街道 */
export const getRegion = data => {
  return http({
    url: '/api/third/area/list',
    method: 'get',
    data
  })
}

/** 用户积分排行榜 */
export const getUserIntegralRank = data => {
  return http({
    url: '/api/system/userPoints/list',
    method: 'get',
    data
  })
}

/** 签到列表 */
export const getSignList = data => {
  return http({
    url: '/api/system/signRecord/list',
    method: 'get',
    data
  })
}

/** 签到 */
export const signIn = () => {
  return http({
    url: '/api/system/signRecord',
    method: 'post'
  })
}

/** 根据id获取文章详细信息 */
export const getArticleDetail = id => {
  return http({
    url: `/api/service/articleContent/type/${id}`,
    method: 'get'
  })
}

/** 获取腾讯usersig */
export const getTencentUserSig = () => {
  return http({
    url: '/api/user/usersig',
    method: 'get'
  })
}


/** 根据ip判断是否黑名单 */
export const getIpBlack = (loading = true) => {
  return http({
    url: '/api/free/black/isBlack',
    method: 'get',
    loading
  })
}

/** 获取随机群号 */
export const getRandomGroup = () => {
  return http({
    url: '/api/service/customerStaff/generateGroupId',
    method: 'get'
  })
}