goods.ts 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. import { useMyRequest } from '~/composables/useFetchRequest'
  2. enum Api {
  3. GoodsList = '/client/merchandise/list/default',
  4. GoodsTrendingList = '/client/merchandise/recommendList/trending',
  5. GoodsHotSaleList = '/client/merchandise/recommendList/hotSale',
  6. Favorite = '/client/merchandise/favorite',
  7. GoodsDetail = '/client/merchandise/detail',
  8. GoodsRecommendList = '/client/merchandise/recommendList/similar',
  9. AddShopCart = '/client/cart/add',
  10. RecommendListOne = '/client/merchandise/recommendList/sameSupplier',
  11. RecommendListTwo = '/client/merchandise/recommendList/sameCategory',
  12. }
  13. /**
  14. * 获取商品列表
  15. * @param params
  16. * @returns
  17. */
  18. export async function getGoodsListApi(params?: any) {
  19. return await useMyRequest().post(Api.GoodsList, params)
  20. }
  21. /**
  22. * 获取trending 商品列表
  23. * @param params
  24. * @returns
  25. */
  26. export async function getGoodsTrendingListApi(params?: any) {
  27. return await useMyRequest().get(Api.GoodsTrendingList, params)
  28. }
  29. /**
  30. * 获取热卖 商品列表
  31. * @param params
  32. * @returns
  33. */
  34. export async function getGoodsHotSaleListApi(params?: any) {
  35. return await useMyRequest().get(Api.GoodsHotSaleList, params)
  36. }
  37. /**
  38. * 是否收藏
  39. * @param params
  40. * @returns
  41. */
  42. export async function setGoodsFavoriteApi(params: any) {
  43. return await useMyRequest().post(Api.Favorite, params)
  44. }
  45. /**
  46. * 获取商品详情
  47. * @param params
  48. * @returns
  49. */
  50. export async function getGoodsDetailApi(params?: any) {
  51. return await useMyRequest().get(Api.GoodsDetail, params)
  52. }
  53. /**
  54. * 获取商品推荐
  55. * @param params
  56. * @returns
  57. */
  58. export async function getGoodsRecommendListApi(params?: any) {
  59. return await useMyRequest().get(Api.GoodsRecommendList, params)
  60. }
  61. /**
  62. * 添加购物车
  63. * @param params
  64. * @returns
  65. */
  66. export async function addShopCartApi(params: any) {
  67. return await useMyRequest().post(Api.AddShopCart, params)
  68. }
  69. /**
  70. * 获取推荐商品1
  71. * @param params
  72. * @returns
  73. */
  74. export async function getRecommendListOneApi(params?: any) {
  75. return await useMyRequest().get(Api.RecommendListOne, params)
  76. }
  77. /**
  78. * 获取推荐商品2
  79. * @param params
  80. * @returns
  81. */
  82. export async function getRecommendListTwoApi(params?: any) {
  83. return await useMyRequest().get(Api.RecommendListTwo, params)
  84. }