import { useMyRequest } from '~/composables/useFetchRequest'

enum Api {
  GoodsList = '/client/merchandise/list/default',
  GoodsTrendingList = '/client/merchandise/recommendList/trending',
  GoodsHotSaleList = '/client/merchandise/recommendList/hotSale',
  Favorite = '/client/merchandise/favorite',
  GoodsDetail = '/client/merchandise/detail',
  GoodsRecommendList = '/client/merchandise/recommendList/similar',
  AddShopCart = '/client/cart/add',
  RecommendListOne = '/client/merchandise/recommendList/sameSupplier',
  RecommendListTwo = '/client/merchandise/recommendList/sameCategory',
}

/**
 * 获取商品列表
 * @param params
 * @returns
 */
export async function getGoodsListApi(params?: any) {
  return await useMyRequest().post(Api.GoodsList, params)
}

/**
 * 获取trending 商品列表
 * @param params
 * @returns
 */
export async function getGoodsTrendingListApi(params?: any) {
  return await useMyRequest().get(Api.GoodsTrendingList, params)
}
/**
 * 获取热卖 商品列表
 * @param params
 * @returns
 */
export async function getGoodsHotSaleListApi(params?: any) {
  return await useMyRequest().get(Api.GoodsHotSaleList, params)
}

/**
 * 是否收藏
 * @param params
 * @returns
 */
export async function setGoodsFavoriteApi(params: any) {
  return await useMyRequest().post(Api.Favorite, params)
}

/**
 * 获取商品详情
 * @param params
 * @returns
 */
export async function getGoodsDetailApi(params?: any) {
  return await useMyRequest().get(Api.GoodsDetail, params)
}

/**
 * 获取商品推荐
 * @param params
 * @returns
 */
export async function getGoodsRecommendListApi(params?: any) {
  return await useMyRequest().get(Api.GoodsRecommendList, params)
}
/**
 * 添加购物车
 * @param params
 * @returns
 */
export async function addShopCartApi(params: any) {
  return await useMyRequest().post(Api.AddShopCart, params)
}

/**
 * 获取推荐商品1
 * @param params
 * @returns
 */
export async function getRecommendListOneApi(params?: any) {
  return await useMyRequest().get(Api.RecommendListOne, params)
}
/**
 * 获取推荐商品2
 * @param params
 * @returns
 */
export async function getRecommendListTwoApi(params?: any) {
  return await useMyRequest().get(Api.RecommendListTwo, params)
}
