favorite.js 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import request from '@/sheep/request';
  2. const FavoriteApi = {
  3. // 获得商品收藏分页
  4. getFavoritePage: (data) => {
  5. return request({
  6. url: '/product/favorite/page',
  7. method: 'GET',
  8. params: data,
  9. });
  10. },
  11. // 检查是否收藏过商品
  12. isFavoriteExists: (spuId) => {
  13. return request({
  14. url: '/product/favorite/exits',
  15. method: 'GET',
  16. params: {
  17. spuId,
  18. },
  19. });
  20. },
  21. // 添加商品收藏
  22. createFavorite: (spuId) => {
  23. return request({
  24. url: '/product/favorite/create',
  25. method: 'POST',
  26. data: {
  27. spuId,
  28. },
  29. custom: {
  30. auth: true,
  31. showSuccess: true,
  32. successMsg: '收藏成功',
  33. },
  34. });
  35. },
  36. // 取消商品收藏
  37. deleteFavorite: (spuId) => {
  38. return request({
  39. url: '/product/favorite/delete',
  40. method: 'DELETE',
  41. data: {
  42. spuId,
  43. },
  44. custom: {
  45. auth: true,
  46. showSuccess: true,
  47. successMsg: '取消成功',
  48. },
  49. });
  50. },
  51. };
  52. export default FavoriteApi;