import request from '@/utils/request'

/**
 * 获取商品分类模板配置
 */
export function getGoodsCategoryConfig() {
    return request.get(`mall/miniPageSetMini/current`)
}

/**
 * 获取商品分类树结构
 */
export function getGoodsCategoryTree(params:any) {
    return request.get(`product/miniProduct/getProductCategoryTree`,params)
}

/**
 * 获取商品分类列表
 */
export function getGoodsCategoryList(params: Record<string, any>) {
    return request.get(`shop/goods/category/list`, params)
}

/**
 * 获取商品列表
 */
export function getGoodsPages(params: Record<string, any>) {
    return request.get(`shop/goods/pages`, params)
}

/**
 * 获取商品详情
 */
export function getGoodsDetail(productNo: any) {
    return request.get(`product/miniProduct/getProductDetail/${productNo}`)
}

/**
 * 获取商品规格
 */
export function getGoodsSku(sku_id: any) {
    return request.get(`shop/goods/sku/${ sku_id }`)
}

/**
 * 收藏列表
 */
export function getCollectList(params: Record<string, any>) {
    return request.get(`product/miniProduct/getFavoritesProductPage`, params)
}

/**
 * 取消收藏
 */
export function cancelCollect(params: any) {
    return request.delete(`product/miniProduct/cancelProductCollect`, params, { showSuccessMessage: true })
}

/**
 *  收藏
 */
export function collect(params: any) {
    return request.post(`product/miniProduct/addProductCollect` ,params, { showSuccessMessage: true })
}

/**
 *  是否收藏
 */
export function isProductInDefaultCollect(goods_id: any) {
    return request.get(`product/miniProduct/isProductInDefaultCollect/${ goods_id }`)
}


/**
 * 获取评价
 */
export function getEvaluateList(goods_id: any) {
    return request.get(`shop/goods/evaluate/list`, { goods_id })
}

/**
 * 获取商品列表供组件调用
 */
export function getGoodsComponents(params: Record<string, any>) {
    return request.get(`product/miniProduct/getDiyProductPage`, params)
}

/**
 * 获取商品满减信息
 */
export function getManjian(params: Record<string, any>) {
    return request.get(`shop/manjian/info`, params)
}

/**
 *  商品足迹添加
 */
export function browse(goods_id: any) {
    return request.post(`product/miniProduct/addProductBrowsingHistory/${goods_id}`)
}

/**
 *  商品足迹列表
 */
export function getBrowse(params: Record<string, any>) {
    return request.get(`product/miniProduct/getProductBrowsingHistory`, params)
}

/**
 * 商品足迹删除
 */
export function delBrowse(ids: any) {
    return request.delete(`/product/miniProduct/deleteProductBrowsingHistory/${ids}`)
}

/**
 *  获取商品搜索配置
 */
export function getGoodsConfigSearch() {
    return request.get(`shop/goods/config/search`)
}