/* eslint-disable no-confusing-arrow */
import { post, get } from '@/api/request'
import CONFIG, { ENV_CONFIG } from '@/config'
const { activityDomain, privateDomain, voteDomain, consolesDomain } = CONFIG
const flag = ENV_CONFIG.X_CA_STAGE

// 获取抽奖(场次)列表
export const getLotterySessionList = data =>
  flag
    ? get('/activity/Draw/getDrawList', { data })
    : get('/activity/Draw/getDrawList', { data, baseURL: activityDomain })

// 获取抽奖信息
export const getLotteryInfos = data =>
  flag
    ? get('/activity/Draw/getDrawInfo', { data })
    : get('/activity/Draw/getDrawInfo', { data, baseURL: activityDomain })

// 抽奖
export const setLottery = data =>
  flag ? post('/activity/Draw/drawing', data) : post('/activity/Draw/drawing', data, { baseURL: activityDomain })

// 获取抽奖记录列表
export const getLotteryRecordList = data =>
  flag
    ? get('/activity/DrawResult/personResult', { data })
    : get('/activity/DrawResult/personResult', { data, baseURL: activityDomain })

// 获取中奖名单列表
export const getWinnersList = data =>
  flag
    ? get('/activity/Draw/getWinningRecord', { data })
    : get('/activity/Draw/getWinningRecord', { data, baseURL: activityDomain })

// 获取已绑定直播间的抽奖信息
export const getLiveLottery = data =>
  flag
    ? get('/activity/Draw/getLiveDraw', { data })
    : get('/activity/Draw/getLiveDraw', { data, baseURL: activityDomain })

// 获取用户抽奖记录
export const getUserRecord = data =>
  flag
    ? get('/activity/DrawResult/getUserRecord', { data })
    : get('/activity/DrawResult/getUserRecord', { data, baseURL: activityDomain })

// 前置条件检测
export const checkPremise = data =>
  flag ? post('/activity/Draw/checkPremise', data) : post('/activity/Draw/checkPremise', data, { baseURL: activityDomain })

// 保存前置条件
export const savePremise = data =>
flag
  ? post('/activity/Draw/savePremise', data)
  : post('/activity/Draw/savePremise', data, { baseURL: activityDomain })

// 发送手机验证码
export const setSendSmsCode = (data) =>
  flag ? post('/Program/Person/sendSms', data) : post('/Program/Person/sendSms', data, { baseURL: privateDomain })

// 验证手机验证码
export const setValidSmsCode = (data) =>
  flag
    ? post('/Program/Person/checkSmsCode', data)
    : post('/Program/Person/checkSmsCode', data, { baseURL: privateDomain })

// 检测前置活动投票
export const checkVote = data =>
  flag ? get('/live/Vote/checkVoted', { data }) : get('/live/Vote/checkVoted', { data, baseURL: voteDomain })
// 检测前置活动问卷
export const checkQuestionnaire = data =>
  flag ? get('/activity/Questionnaire/checkQuestionnaired', { data }) : get('/activity/Questionnaire/checkQuestionnaired', { data, baseURL: activityDomain })

// 获取用户简单信息
export const getUserSimpleInfo = (data) => get('/user/openapi/getUserSimpleInfo', { data, baseURL: consolesDomain })

// 提交问卷
export const saveAnswer = (data) =>
  flag
  ? post('/activity/Draw/saveAnswer', data)
  : post('/activity/Draw/saveAnswer', data, { baseURL: activityDomain })

