favorite.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. createCollectBefore: (spuId) => {
  38. return request({
  39. url: '/distri/user-collect-before/create',
  40. method: 'POST',
  41. data: {
  42. productSpuId:spuId,
  43. }
  44. });
  45. },
  46. // 取消商品收藏
  47. deleteFavorite: (spuId) => {
  48. return request({
  49. url: '/product/favorite/delete',
  50. method: 'DELETE',
  51. data: {
  52. spuId,
  53. },
  54. custom: {
  55. auth: true,
  56. showSuccess: true,
  57. successMsg: '取消成功',
  58. },
  59. });
  60. },
  61. };
  62. export default FavoriteApi;