import request from './request';
let api = {
  goodsList: '/mtsw/Goods/goodsList', // 获取商品列表
  getRecommendGoods: '/mtsw/Goods/getRecommendGoods', // 获取推荐商品列表
  getGoodsMsg: '/mtsw/Goods/getGoodsMsg', // 获取商品信息
  getAddressList: '/mtsw/address/getAddressList', // 获取地址列表
  addAddress: '/mtsw/address/addAddress', // 添加地址
  editAddress: '/mtsw/address/editAddress', // 编辑地址
  delAddress: '/mtsw/address/delAddress', // 删除地址
  createOrder: '/mtsw/order/createOrder' // 提交订单
};
const prodApi = {
  goodsList: 'https://privateapi.guangdianyun.tv/v1/mtsw/Goods/goodsList', // 获取商品列表
  getRecommendGoods: 'https://privateapi.guangdianyun.tv/v1/mtsw/Goods/getRecommendGoods', // 获取推荐商品列表
  getGoodsMsg: 'https://privateapi.guangdianyun.tv/v1/mtsw/Goods/getGoodsMsg', // 获取商品信息
  getAddressList: 'https://privateapi.guangdianyun.tv/v1/mtsw/MtswAddress/getAddressList', // 获取地址列表
  addAddress: 'https://privateapi.guangdianyun.tv/v1/mtsw/MtswAddress/addAddress', // 添加地址
  editAddress: 'https://privateapi.guangdianyun.tv/v1/mtsw/MtswAddress/editAddress', // 编辑地址
  delAddress: 'https://privateapi.guangdianyun.tv/v1/mtsw/MtswAddress/delAddress', // 删除地址
  createOrder: 'https://privateapi.guangdianyun.tv/v1/mtsw/Order/createOrder' // 提交订单
};
const preApi = {
  // goodsList: '', // 获取商品列表
  // getRecommendGoods: '', // 获取推荐商品列表
  // getGoodsMsg: '', // 获取商品信息
  // getAddressList: '', // 获取地址列表
  // addAddress: '', // 添加地址
  // editAddress: '', // 编辑地址
  // delAddress: '', // 删除地址
  // createOrder: '' // 提交订单
};
const testApi = {
  // goodsList: '', // 获取商品列表
  // getRecommendGoods: '', // 获取推荐商品列表
  // getGoodsMsg: '', // 获取商品信息
  // getAddressList: '', // 获取地址列表
  // addAddress: '', // 添加地址
  // editAddress: '', // 编辑地址
  // delAddress: '', // 删除地址
  // createOrder: '' // 提交订单
};
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 };
  }
}

export const goodsList = data => {
  return request.get(api['goodsList'], data);
};
export const getRecommendGoods = data => {
  return request.get(api['getRecommendGoods'], data);
};
export const getGoodsMsg = data => {
  return request.get(api['getGoodsMsg'], data);
};
export const getAddressList = data => {
  return request.get(api['getAddressList'], data);
};
export const addAddress = data => {
  return request.post(api['addAddress'], data);
};
export const editAddress = data => {
  return request.post(api['editAddress'], data);
};
export const delAddress = data => {
  return request.post(api['delAddress'], data);
};
export const createOrder = data => {
  return request.post(api['createOrder'], data);
};
export default {
  goodsList,
  getRecommendGoods,
  getGoodsMsg,
  getAddressList,
  addAddress,
  editAddress,
  delAddress,
  createOrder
};
