2024-08-03 02:33:09 +00:00
|
|
|
// ========== COMMON - 公共模块 ==========
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 与后端Terminal枚举一一对应
|
|
|
|
*/
|
|
|
|
export const TerminalEnum = {
|
|
|
|
UNKNOWN: 0, // 未知, 目的:在无法解析到 terminal 时,使用它
|
|
|
|
WECHAT_MINI_PROGRAM: 10, //微信小程序
|
|
|
|
WECHAT_WAP: 11, // 微信公众号
|
|
|
|
H5: 20, // H5 网页
|
|
|
|
APP: 31, // 手机 App
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2024-08-08 05:04:34 +00:00
|
|
|
* 将 uni-app 提供的平台转换为后端所需的 terminal值
|
|
|
|
*
|
|
|
|
* @return 终端
|
2024-08-03 02:33:09 +00:00
|
|
|
*/
|
2024-08-08 05:04:34 +00:00
|
|
|
export const getTerminal = () => {
|
|
|
|
const platformType = uni.getSystemInfoSync().uniPlatform;
|
2024-08-03 02:33:09 +00:00
|
|
|
// 与后端terminal枚举一一对应
|
|
|
|
switch (platformType) {
|
|
|
|
case 'app':
|
2024-08-08 05:04:34 +00:00
|
|
|
return TerminalEnum.APP;
|
2024-08-03 02:33:09 +00:00
|
|
|
case 'web':
|
2024-08-08 05:04:34 +00:00
|
|
|
return TerminalEnum.H5;
|
2024-08-03 02:33:09 +00:00
|
|
|
case 'mp-weixin':
|
2024-08-08 05:04:34 +00:00
|
|
|
return TerminalEnum.WECHAT_MINI_PROGRAM;
|
2024-08-03 02:33:09 +00:00
|
|
|
default:
|
2024-08-08 05:04:34 +00:00
|
|
|
return TerminalEnum.UNKNOWN;
|
2024-08-03 02:33:09 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2023-11-22 08:57:59 +00:00
|
|
|
// ========== MALL - 营销模块 ==========
|
|
|
|
|
2024-09-28 06:43:04 +00:00
|
|
|
import dayjs from 'dayjs';
|
2024-01-11 03:08:14 +00:00
|
|
|
|
2023-11-22 08:57:59 +00:00
|
|
|
/**
|
|
|
|
* 优惠类型枚举
|
|
|
|
*/
|
|
|
|
export const PromotionDiscountTypeEnum = {
|
2024-09-28 06:43:04 +00:00
|
|
|
PRICE: {
|
|
|
|
type: 1,
|
|
|
|
name: '满减',
|
|
|
|
},
|
|
|
|
PERCENT: {
|
|
|
|
type: 2,
|
|
|
|
name: '折扣',
|
|
|
|
},
|
|
|
|
};
|
2023-11-22 08:57:59 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 优惠劵模板的有限期类型的枚举
|
|
|
|
*/
|
|
|
|
export const CouponTemplateValidityTypeEnum = {
|
2024-09-28 06:43:04 +00:00
|
|
|
DATE: {
|
|
|
|
type: 1,
|
|
|
|
name: '固定日期可用',
|
|
|
|
},
|
|
|
|
TERM: {
|
|
|
|
type: 2,
|
|
|
|
name: '领取之后可用',
|
|
|
|
},
|
|
|
|
};
|
2023-11-22 08:57:59 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 营销的商品范围枚举
|
|
|
|
*/
|
|
|
|
export const PromotionProductScopeEnum = {
|
2024-09-28 06:43:04 +00:00
|
|
|
ALL: {
|
|
|
|
scope: 1,
|
|
|
|
name: '通用劵',
|
|
|
|
},
|
|
|
|
SPU: {
|
|
|
|
scope: 2,
|
|
|
|
name: '商品劵',
|
|
|
|
},
|
|
|
|
CATEGORY: {
|
|
|
|
scope: 3,
|
|
|
|
name: '品类劵',
|
|
|
|
},
|
|
|
|
};
|
2024-01-11 03:08:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
// 时间段的状态枚举
|
|
|
|
export const TimeStatusEnum = {
|
2024-09-28 06:43:04 +00:00
|
|
|
WAIT_START: '即将开始',
|
|
|
|
STARTED: '进行中',
|
|
|
|
END: '已结束',
|
|
|
|
};
|
2024-01-11 03:08:14 +00:00
|
|
|
|
2024-07-31 11:48:13 +00:00
|
|
|
/**
|
|
|
|
* 微信小程序的订阅模版
|
|
|
|
*/
|
|
|
|
export const WxaSubscribeTemplate = {
|
2024-09-28 06:43:04 +00:00
|
|
|
TRADE_ORDER_DELIVERY: '订单发货通知',
|
|
|
|
PROMOTION_COMBINATION_SUCCESS: '拼团结果通知',
|
|
|
|
PAY_WALLET_RECHARGER_SUCCESS: '充值成功通知',
|
|
|
|
};
|
|
|
|
export const PromotionActivityTypeEnum = {
|
|
|
|
NORMAL: {
|
|
|
|
type: 0,
|
|
|
|
name: '普通',
|
|
|
|
},
|
|
|
|
SECKILL: {
|
|
|
|
type: 1,
|
|
|
|
name: '秒杀',
|
|
|
|
},
|
|
|
|
BARGAIN: {
|
|
|
|
type: 2,
|
|
|
|
name: '砍价',
|
|
|
|
},
|
|
|
|
COMBINATION: {
|
|
|
|
type: 3,
|
|
|
|
name: '拼团',
|
|
|
|
},
|
|
|
|
POINT: {
|
|
|
|
type: 4,
|
2024-09-28 08:24:57 +00:00
|
|
|
name: '积分商城',
|
2024-09-28 06:43:04 +00:00
|
|
|
},
|
|
|
|
};
|
2024-07-24 09:17:44 +00:00
|
|
|
|
2024-01-11 03:08:14 +00:00
|
|
|
export const getTimeStatusEnum = (startTime, endTime) => {
|
2024-09-28 06:43:04 +00:00
|
|
|
const now = dayjs();
|
|
|
|
if (now.isBefore(startTime)) {
|
|
|
|
return TimeStatusEnum.WAIT_START;
|
|
|
|
} else if (now.isAfter(endTime)) {
|
|
|
|
return TimeStatusEnum.END;
|
|
|
|
} else {
|
|
|
|
return TimeStatusEnum.STARTED;
|
|
|
|
}
|
|
|
|
};
|