mall-uniapp/sheep/api/product/favorite.js

55 lines
1.0 KiB
JavaScript
Raw Normal View History

2023-12-14 16:01:54 +00:00
import request from '@/sheep/request';
const FavoriteApi = {
// 获得商品收藏分页
getFavoritePage: (data) => {
return request({
url: '/product/favorite/page',
2023-12-14 16:01:54 +00:00
method: 'GET',
2024-01-20 09:28:04 +00:00
params: data,
2023-12-14 16:01:54 +00:00
});
},
// 检查是否收藏过商品
isFavoriteExists: (spuId) => {
return request({
url: '/product/favorite/exits',
method: 'GET',
params: {
2024-01-20 09:28:04 +00:00
spuId,
},
});
},
// 添加商品收藏
createFavorite: (spuId) => {
return request({
url: '/product/favorite/create',
method: 'POST',
data: {
2024-01-20 09:28:04 +00:00
spuId,
},
custom: {
auth: true,
showSuccess: true,
successMsg: '收藏成功',
},
});
},
2023-12-14 16:01:54 +00:00
// 取消商品收藏
deleteFavorite: (spuId) => {
return request({
url: '/product/favorite/delete',
2023-12-14 16:01:54 +00:00
method: 'DELETE',
data: {
2024-01-20 09:28:04 +00:00
spuId,
},
custom: {
auth: true,
showSuccess: true,
successMsg: '取消成功',
},
2023-12-14 16:01:54 +00:00
});
2024-01-20 09:28:04 +00:00
},
2023-12-14 16:01:54 +00:00
};
2024-01-20 09:28:04 +00:00
export default FavoriteApi;