zyejMAll-mobile/sheep/util/const.js

68 lines
1.1 KiB
JavaScript
Raw Normal View History

2024-08-07 10:31:42 +08:00
// ========== MALL - 营销模块 ==========
2024-08-07 21:40:27 +08:00
import dayjs from 'dayjs';
2024-08-07 10:31:42 +08:00
/**
* 优惠类型枚举
*/
export const PromotionDiscountTypeEnum = {
2024-08-07 21:40:27 +08:00
PRICE: {
type: 1,
name: '满减',
},
PERCENT: {
type: 2,
name: '折扣',
},
};
2024-08-07 10:31:42 +08:00
/**
* 优惠劵模板的有限期类型的枚举
*/
export const CouponTemplateValidityTypeEnum = {
2024-08-07 21:40:27 +08:00
DATE: {
type: 1,
name: '固定日期可用',
},
TERM: {
type: 2,
name: '领取之后可用',
},
};
2024-08-07 10:31:42 +08:00
/**
* 营销的商品范围枚举
*/
export const PromotionProductScopeEnum = {
2024-08-07 21:40:27 +08:00
ALL: {
scope: 1,
name: '通用劵',
},
SPU: {
scope: 2,
name: '商品劵',
},
CATEGORY: {
scope: 3,
name: '品类劵',
},
};
2024-08-07 10:31:42 +08:00
// 时间段的状态枚举
export const TimeStatusEnum = {
2024-08-07 21:40:27 +08:00
WAIT_START: '即将开始',
STARTED: '进行中',
END: '已结束',
};
2024-08-07 10:31:42 +08:00
export const getTimeStatusEnum = (startTime, endTime) => {
2024-08-07 21:40:27 +08:00
const now = dayjs();
if (now.isBefore(startTime)) {
return TimeStatusEnum.WAIT_START;
} else if (now.isAfter(endTime)) {
return TimeStatusEnum.END;
} else {
return TimeStatusEnum.STARTED;
}
};