coupon.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. "use strict";
  2. const sheep_request_index = require("../../request/index.js");
  3. const CouponApi = {
  4. // 获得优惠劵模板列表
  5. getCouponTemplateListByIds: (ids) => {
  6. return sheep_request_index.request({
  7. url: "/promotion/coupon-template/list-by-ids",
  8. method: "GET",
  9. params: { ids },
  10. custom: {
  11. showLoading: false,
  12. // 不展示 Loading,避免领取优惠劵时,不成功提示
  13. showError: false
  14. }
  15. });
  16. },
  17. // 获得优惠劵模版列表
  18. getCouponTemplateList: (spuId, productScope, count) => {
  19. return sheep_request_index.request({
  20. url: "/promotion/coupon-template/list",
  21. method: "GET",
  22. params: { spuId, productScope, count }
  23. });
  24. },
  25. // 获得优惠劵模版分页
  26. getCouponTemplatePage: (params) => {
  27. return sheep_request_index.request({
  28. url: "/promotion/coupon-template/page",
  29. method: "GET",
  30. params
  31. });
  32. },
  33. // 获得优惠劵模版
  34. getCouponTemplate: (id) => {
  35. return sheep_request_index.request({
  36. url: "/promotion/coupon-template/get",
  37. method: "GET",
  38. params: { id }
  39. });
  40. },
  41. // 我的优惠劵列表
  42. getCouponPage: (params) => {
  43. return sheep_request_index.request({
  44. url: "/promotion/coupon/page",
  45. method: "GET",
  46. params
  47. });
  48. },
  49. // 领取优惠券
  50. takeCoupon: (templateId) => {
  51. return sheep_request_index.request({
  52. url: "/promotion/coupon/take",
  53. method: "POST",
  54. data: { templateId },
  55. custom: {
  56. auth: true,
  57. showLoading: true,
  58. loadingMsg: "领取中",
  59. showSuccess: true,
  60. successMsg: "领取成功"
  61. }
  62. });
  63. },
  64. // 获得优惠劵
  65. getCoupon: (id) => {
  66. return sheep_request_index.request({
  67. url: "/promotion/coupon/get",
  68. method: "GET",
  69. params: { id }
  70. });
  71. },
  72. // 获得未使用的优惠劵数量
  73. getUnusedCouponCount: () => {
  74. return sheep_request_index.request({
  75. url: "/promotion/coupon/get-unused-count",
  76. method: "GET",
  77. custom: {
  78. showLoading: false,
  79. auth: true
  80. }
  81. });
  82. },
  83. // 获得匹配指定商品的优惠劵列表
  84. getMatchCouponList: (price, spuIds, skuIds, categoryIds) => {
  85. return sheep_request_index.request({
  86. url: "/promotion/coupon/match-list",
  87. method: "GET",
  88. params: {
  89. price,
  90. spuIds: spuIds.join(","),
  91. skuIds: skuIds.join(","),
  92. categoryIds: categoryIds.join(",")
  93. },
  94. custom: {
  95. showError: false,
  96. showLoading: false
  97. // 避免影响 settlementOrder 结算的结果
  98. }
  99. });
  100. }
  101. };
  102. exports.CouponApi = CouponApi;