import http from '@/utils/request'

/** 分类 */
export const getCategory = () => {
  return http({
    url: '/api/service/productCategory/list',
    method: 'get'
  })
}

/** 商品列表 */
export const getProductList = data => {
  return http({
    url: '/api/service/product/list',
    method: 'get',
    data
  })
}

/** 商品详情 */
export const getProductDetail = productId => {
  return http({
    url: `/api/service/product/${productId}`,
    method: 'get'
  })
}

/** 商品评价列表 */
export const getProductCommentList = (data, loading = true) => {
  return http({
    url: '/api/service/productReview/list',
    method: 'get',
    data,
    loading
  })
}

/** 添加商品评论 */
export const addProductComment = data => {
  return http({
    url: '/api/service/productReview',
    method: 'post',
    data
  })
}

/** 新增订单 */
export const addOrder = data => {
  return http({
    url: '/api/service/order',
    method: 'post',
    data
  })
}

/** 创建普通订单接口 */
export const createOrder = data => {
  return http({
    url: '/api/service/order/normal',
    method: 'post',
    data
  })
}

/** 我的拼团列表 */
export const getMyGroupList = data => {
  return http({
    url: '/api/service/groupOrder/list',
    method: 'get',
    data
  })
}

/** 获取拼团详情 */
export const getGroupDetail = id => {
  return http({
    url: `/api/service/groupOrder/${id}`,
    method: 'get',
    loading: false
  })
}

/** 获取可参与的拼团列表 */
export const getParticipateList = id => {
  return http({
    url: `/api/service/groupOrder/available/${id}`,
    method: 'get',
    loading: false
  })
}
