Files
yshop-pro-uniapp/api/product.js
2023-11-14 17:21:03 +08:00

111 lines
2.8 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import api from './api'
/**
* 获得商品分类列表
*/
export function getCategoryList(data) {
return api.get('/product/category/list', data, {login: false})
}
/**
* 商品列表
*/
export function getProductList(data) {
return api.get('/product/products', data, {login: false})
}
/**
* 商品详情
*/
export function getProductDetail(data) {
return api.get(`/product/detail/${ data }`, {}, {login: false})
}
/**
* 添加收藏
*/
export function getProductAddCollect(data) {
return api.post(`/relation/collect/add`, data, {login: false})
}
/**
* 取消收藏
*/
export function getProductDelCollect(data) {
return api.post(`/relation/collect/del`, data, {login: false})
}
// ================= 👆 我不知道上面的命名方式是什么命名方式,屎山我也不敢动
// ================= 👆 后面的兄弟要骂娘骂上面人的娘,我是没看过这种傻逼命名方式
// ================= 👆 shaw只是init仓库也别骂他娘
// ================= 👇 下面的才是我写的
/**
* 分页获取收藏
* @param data 分页信息
* @returns {*}
*/
export const collectPage = (data) => api.get(`/relation/collect/user`, {...data, type: 'collect'})
/**
* 收藏
* @param data {{ productId:any,type?:'collect' }}
* productId产品ID
* typecollect
* @returns {*}
*/
export const collectSingle = (data) => api.post(`/relation/collect/add`, {...data, type: 'collect'})
/**
* 取消多个收藏
* @param data {{ productId:any,type?:'collect' }}
* @returns {*}
*/
export const unCollectByList = (data) => api.post(`/relation/collect/batchDel`, {...data, type: 'collect'})
/**
* 取消单个收藏
* @param data {{ productId:any,type?:'collect' }}
* @returns {*}
*/
export const unCollectSingle = (data) => api.post(`/relation/collect/del`, {...data, type: 'collect'})
/**
* 分页获取足迹信息
* @param data {{ productId:any,type?:'collect' }}
* @returns {*}
*/
export const footprintPage = (data) => api.get(`/relation/collect/user`, {...data, type: 'foot'})
/**
* 删除多个足迹
* @param data {{ productId:any,type?:'collect' }}
* @returns {*}
*/
export const unFootprintByList = (data) => api.post(`/relation/collect/batchDel`, {...data, type: 'foot'})
/**
* 取消单个收藏
* @param data {{ productId:any,type?:'collect' }}
* @returns {*}
*/
export const unFootprintSingle = (data) => api.post(`/relation/collect/del`, {...data, type: 'foot'})
/**
* 获取热门搜索
* @returns {*}
*/
export const hotSearch = (start, end) => api.get(`/product/search/popular/${start}/${end}`)
/**
* 历史搜索记录
* @returns {*}
*/
export const historySearch = () => api.get(`/product/search/history`)
/**
* 清空历史搜索记录
* @param data
* @returns {*}
*/
export const clearHistorySearch = () => api.post(`/product/search/history/del`)