import request from '@/utils/request'
import {httpRequest} from '@/utils/request/axios'
const baseUrl = 'https://api.1024api.com/api-interface/app'

// api地址
const api = {
  list: 'goods/list',
  detail: 'goods/detail',
  basic: 'goods/basic',
  specData: 'goods/specData',
  skuInfo: 'goods/skuInfo'
}

// 商品列表
export const list = (param, option) => {
  return request.get(api.list, param, option)
}

// 商品详情(详细数据)
export const detail = (goodsId, verifyStatus = true, param = {}) => {
  verifyStatus = Number(verifyStatus)
  return request.get(api.detail, { goodsId, verifyStatus, ...param })
}

// 商品详情(基本数据)
export const basic = (goodsId, verifyStatus = true, param = {}) => {
  verifyStatus = Number(verifyStatus)
  return request.get(api.basic, { goodsId, verifyStatus, ...param })
}

// 获取商品规格数据
export const specData = (goodsId) => {
  return request.get(api.specData, { goodsId })
}

// 获取商品的指定SKU信息
export const skuInfo = (goodsId, goodsSkuId, param) => {
  return request.get(api.skuInfo, { goodsId, goodsSkuId, ...param })
}

// 获取商品列表
export const apiGetCommodityList = (data) => {
    return httpRequest.post(
      `${baseUrl}/index/page/list`,
      data
    );
  }

// 获取商品详情
export const apiGetCommodityDetail = (data) => {
    return httpRequest.post(
      `${baseUrl}/index/product/detail`,
      data
    );
  }

// 加入购物车
export const apiAddCart = (data) => {
    return httpRequest.post(
      `${baseUrl}/shipping/cart/addOrUpdate`,
      data
    );
  }

// 获取商品评价列表
export const apiGetCommentList = (data) => {
    return httpRequest.post(
      `${baseUrl}/comment/list`,
      data
    );
  }

