const.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // ========== MALL - 营销模块 ==========
  2. import dayjs from "dayjs";
  3. /**
  4. * 优惠类型枚举
  5. */
  6. export const PromotionDiscountTypeEnum = {
  7. PRICE: {
  8. type: 1,
  9. name: '满减'
  10. },
  11. PERCENT: {
  12. type: 2,
  13. name: '折扣'
  14. }
  15. }
  16. /**
  17. * 优惠劵模板的有限期类型的枚举
  18. */
  19. export const CouponTemplateValidityTypeEnum = {
  20. DATE: {
  21. type: 1,
  22. name: '固定日期可用'
  23. },
  24. TERM: {
  25. type: 2,
  26. name: '领取之后可用'
  27. }
  28. }
  29. /**
  30. * 营销的商品范围枚举
  31. */
  32. export const PromotionProductScopeEnum = {
  33. ALL: {
  34. scope: 1,
  35. name: '通用劵'
  36. },
  37. SPU: {
  38. scope: 2,
  39. name: '商品劵'
  40. },
  41. CATEGORY: {
  42. scope: 3,
  43. name: '品类劵'
  44. }
  45. }
  46. // 时间段的状态枚举
  47. export const TimeStatusEnum = {
  48. WAIT_START: '即将开始',
  49. STARTED: '进行中',
  50. END: '已结束',
  51. }
  52. export const getTimeStatusEnum = (startTime, endTime) => {
  53. const now = dayjs();
  54. if (now.isBefore(startTime)) {
  55. return TimeStatusEnum.WAIT_START;
  56. } else if (now.isAfter(endTime)) {
  57. return TimeStatusEnum.END;
  58. } else {
  59. return TimeStatusEnum.STARTED;
  60. }
  61. }