favorite.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import request from '@/sheep/request';
  2. import {
  3. t
  4. } from '@/locale';
  5. const FavoriteApi = {
  6. // 获得商品收藏分页
  7. getFavoritePage: (data) => {
  8. return request({
  9. url: '/product/favorite/page',
  10. method: 'GET',
  11. params: data,
  12. });
  13. },
  14. // 检查是否收藏过商品
  15. isFavoriteExists: (spuId) => {
  16. return request({
  17. url: '/product/favorite/exits',
  18. method: 'GET',
  19. params: {
  20. spuId,
  21. },
  22. });
  23. },
  24. // 添加商品收藏
  25. createFavorite: (spuId) => {
  26. return request({
  27. url: '/product/favorite/create',
  28. method: 'POST',
  29. data: {
  30. spuId,
  31. },
  32. custom: {
  33. auth: true,
  34. showSuccess: true,
  35. successMsg: t('common.collect_success'),
  36. },
  37. });
  38. },
  39. // 添加商品收藏时调用的加身价
  40. createCollectBefore: (spuId) => {
  41. return request({
  42. url: '/distri/user-collect-before/create',
  43. method: 'POST',
  44. data: {
  45. productSpuId:spuId,
  46. }
  47. });
  48. },
  49. // 取消商品收藏
  50. deleteFavorite: (spuId) => {
  51. return request({
  52. url: '/product/favorite/delete',
  53. method: 'DELETE',
  54. data: {
  55. spuId,
  56. },
  57. custom: {
  58. auth: true,
  59. showSuccess: true,
  60. successMsg: t('common.cancel_success'),
  61. },
  62. });
  63. },
  64. };
  65. export default FavoriteApi;