product.service.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /**
  2. * 这是与购物有关的业务逻辑的服务
  3. */
  4. export default class ProductService {
  5. constructor(AjaxService) {
  6. Object.assign(this, { AjaxService })
  7. this.name = 'ProductService'
  8. }
  9. /**
  10. * @查询搜索商品列表
  11. * @param:name 商品名称关键词
  12. * @param:pageNum 页码
  13. * @param:pageSize 条数
  14. */
  15. QueryProductList (data = {}) {
  16. return this.AjaxService.get({
  17. url:'/product/list',
  18. data,
  19. isLoading: false ,
  20. })
  21. }
  22. /**
  23. * @商品详情-查询商品详情
  24. * @param:userId 用户ID(未登录传0或者'')
  25. * @param:productIds 商品ID
  26. */
  27. QueryProductDetils (data = {}) {
  28. return this.AjaxService.get({
  29. url:'/product/details',
  30. data,
  31. isLoading: false ,
  32. })
  33. }
  34. /**
  35. * @加入购物车
  36. * @param:userId 用户ID(必填)
  37. * @param:productID 用户ID(必填)
  38. * @param:productCount 商品数量(必填)
  39. */
  40. shoppingAddCart (data = {}) {
  41. return this.AjaxService.post({
  42. url:'/shopping/add/cart',
  43. data,
  44. isLoading: true
  45. })
  46. }
  47. /**
  48. * @购物车列表
  49. * @param:userId 用户ID(必填)
  50. */
  51. QueryShoppingCartList (data = {}) {
  52. return this.AjaxService.get({
  53. url:'/shopping/info',
  54. data,
  55. isLoading: false
  56. })
  57. }
  58. /**
  59. * @更新购物车商品增减
  60. * @param:cartId 购物车ID
  61. * @param:productCount 商品数量ID(必填)
  62. */
  63. ShoppingCartUpdate (data = {}) {
  64. return this.AjaxService.post({
  65. url:'/shopping/update',
  66. data,
  67. isLoading: true
  68. })
  69. }
  70. /**
  71. * @删除购物车商品
  72. * @param:cartIds 购物车ID(用','号拼接)
  73. */
  74. ShoppingCartDelete (data = {}) {
  75. return this.AjaxService.post({
  76. url:'/shopping/delete',
  77. data,
  78. isLoading: true
  79. })
  80. }
  81. /* 查询搜索历史记录 */
  82. GetProductSearchHistory (data = {}) {
  83. return this.AjaxService.get({
  84. url:'/product/searchHistory',
  85. data,
  86. isLoading: false ,
  87. })
  88. }
  89. /* 添加搜索历史记录 */
  90. GetAddProductSearchHistory (data = {}) {
  91. return this.AjaxService.get({
  92. url:'/product/history/add',
  93. data,
  94. isLoading: true ,
  95. })
  96. }
  97. /* 清除搜索历史记录 */
  98. GetDeleteProductSearchHistory (data = {}) {
  99. return this.AjaxService.get({
  100. url:'/product/searchHistory/delete',
  101. data,
  102. isLoading: false ,
  103. })
  104. }
  105. /* 搜索商品列表 */
  106. GetProductSearchList (data = {}) {
  107. return this.AjaxService.get({
  108. url:'/search/query/product',
  109. data,
  110. isLoading: true ,
  111. })
  112. }
  113. }