import request from './request';
let api = {
  getSpecialRedList: '/Program/Redpacket/getSpecialRedList', // 获取 分享，商家，竞答红包
  robRedpacket: '/Program/Redpacket/robRedpacket', // 获取红包详情
  openRedpacket: '/Program/Redpacket/openRedpacket', // 打开 普通，口令红包
  redpacketDetail: '/Program/Redpacket/redpacketDetail', // 获取手气信息
  answerQuestion: '/Program/Redpacket/answerQuestion', // 获取竞答红包
  submitAnswerQuestion: '/Program/Redpacket/submitAnswerQuestion', // 答题
  userReviveCard: '/Program/Redpacket/userReviveCard', // 使用复活卡
  openAnswerRedpacket: '/Program/Redpacket/openAnswerRedpacket', // 打开竞答红包
  openBusinessRedpacket: '/Program/Redpacket/openBusinessRedpacket' // 打开商家红包
};
const prodApi = {
  getSpecialRedList:
    'https://1812501212048408.cn-hangzhou.fc.aliyuncs.com/2016-08-15/proxy/gdyRedPacket.online/gdyRed/program/redenvelope/getSpecialRedList', // 获取 分享，商家，竞答红包
  robRedpacket:
    'https://1812501212048408.cn-hangzhou.fc.aliyuncs.com/2016-08-15/proxy/gdyRedPacket.online/gdyRed/program/redpacket/robRedpacket', // 获取红包详情
  openRedpacket:
    'https://1812501212048408.cn-hangzhou.fc.aliyuncs.com/2016-08-15/proxy/gdyRedPacket.online/gdyRed/program/redpacket/openRedpacket', // 打开 普通，口令红包
  redpacketDetail:
    'https://1812501212048408.cn-hangzhou.fc.aliyuncs.com/2016-08-15/proxy/gdyRedPacket.online/gdyRed/program/redenvelope/redpacketDetail', // 获取手气信息
  answerQuestion: 'https://privateapi.guangdianyun.tv/v1/Program/Redpacket/answerQuestion', // 获取竞答红包
  submitAnswerQuestion:
    'https://privateapi.guangdianyun.tv/v1/Program/Redpacket/submitAnswerQuestion', // 答题
  userReviveCard: 'https://privateapi.guangdianyun.tv/v1/Program/Redpacket/userReviveCard', // 使用复活卡
  openAnswerRedpacket:
    'https://privateapi.guangdianyun.tv/v1/Program/Redpacket/openAnswerRedpacket', // 打开竞答红包
  openBusinessRedpacket:
    'https://1812501212048408.cn-hangzhou.fc.aliyuncs.com/2016-08-15/proxy/gdyRedPacket.online/gdyRed/program/redenvelope/openBusinessRedpacket' // 打开商家红包
};
const preApi = {
  getSpecialRedList:
    'https://1812501212048408.cn-hangzhou.fc.aliyuncs.com/2016-08-15/proxy/gdyRedPacket/gdyRed/program/redenvelope/getSpecialRedList', // 获取 分享，商家，竞答红包
  robRedpacket:
    'https://1812501212048408.cn-hangzhou.fc.aliyuncs.com/2016-08-15/proxy/gdyRedPacket/gdyRed/program/redpacket/robRedpacket', // 获取红包详情
  openRedpacket:
    'https://1812501212048408.cn-hangzhou.fc.aliyuncs.com/2016-08-15/proxy/gdyRedPacket/gdyRed/program/redpacket/openRedpacket', // 打开 普通，口令红包
  redpacketDetail:
    'https://1812501212048408.cn-hangzhou.fc.aliyuncs.com/2016-08-15/proxy/gdyRedPacket/gdyRed/program/redenvelope/redpacketDetail', // 获取手气信息
  // answerQuestion: '', // 获取竞答红包
  // submitAnswerQuestion: '', // 答题
  // userReviveCard: '', // 使用复活卡
  // openAnswerRedpacket: '', // 打开竞答红包
  openBusinessRedpacket:
    'https://1812501212048408.cn-hangzhou.fc.aliyuncs.com/2016-08-15/proxy/gdyRedPacket/gdyRed/program/redenvelope/openBusinessRedpacket' // 打开商家红包
};
const testApi = {
  // getSpecialRedList: '', // 获取 分享，商家，竞答红包
  // robRedpacket: '', // 获取红包详情
  // openRedpacket: '', // 打开 普通，口令红包
  // redpacketDetail: '', // 获取手气信息
  // answerQuestion: '', // 获取竞答红包
  // submitAnswerQuestion: '', // 答题
  // userReviveCard: '', // 使用复活卡
  // openAnswerRedpacket: '', // 打开竞答红包
  // openBusinessRedpacket: '' // 打开商家红包
};
const privateApi = {
  getSpecialRedList: '/php/program/redenvelope/getSpecialRedList', // 获取 分享，商家，竞答红包
  robRedpacket: '/php/program/redpacket/robRedpacket', // 获取红包详情
  openRedpacket: '/php/program/redpacket/openRedpacket', // 打开 普通，口令红包
  redpacketDetail: '/php/program/redenvelope/redpacketDetail', // 获取手气信息
  openBusinessRedpacket: '/php/program/redenvelope/openBusinessRedpacket' // 打开商家红包
};
if (!process.env.private) {
  if (!process.env.X_CA_STAGE) {
    api = { ...api, ...prodApi };
  } else if (process.env.X_CA_STAGE === 'PRE') {
    api = { ...api, ...preApi };
  } else if (process.env.X_CA_STAGE === 'TEST') {
    api = { ...api, ...testApi };
  }
} else {
  api = { ...api, ...privateApi };
}

export const getSpecialRedList = data => {
  return request.get(api['getSpecialRedList'], data);
};
export const robRedpacket = data => {
  return request.post(api['robRedpacket'], data);
};
export const openRedpacket = data => {
  return request.post(api['openRedpacket'], data);
};
export const redpacketDetail = data => {
  return request.get(api['redpacketDetail'], data);
};
export const answerQuestion = data => {
  return request.post(api['answerQuestion'], data);
};
export const submitAnswerQuestion = data => {
  return request.post(api['submitAnswerQuestion'], data);
};
export const userReviveCard = data => {
  return request.post(api['userReviveCard'], data);
};
export const openAnswerRedpacket = data => {
  return request.post(api['openAnswerRedpacket'], data);
};
export const openBusinessRedpacket = data => {
  return request.post(api['openBusinessRedpacket'], data);
};
export default {
  getSpecialRedList,
  robRedpacket,
  openRedpacket,
  redpacketDetail,
  answerQuestion,
  submitAnswerQuestion,
  userReviveCard,
  openAnswerRedpacket,
  openBusinessRedpacket
};
