【功能完善】积分商城: 首页活动装修显示

pull/105/head
puhui999 2024-09-28 14:43:04 +08:00
parent d2f516e1ae
commit 5552236952
3 changed files with 367 additions and 178 deletions

View File

@ -39,12 +39,18 @@
class="xs-goods-price font-OPPOSANS" class="xs-goods-price font-OPPOSANS"
:style="[{ color: goodsFields.price.color }]" :style="[{ color: goodsFields.price.color }]"
> >
<text class="price-unit ss-font-24">{{ priceUnit }}</text>
<!-- 活动价格 --> <!-- 活动价格 -->
<text v-if="data.promotionPrice > 0">{{ fen2yuan(data.promotionPrice) }}</text> <text v-if="data.activityType && data.activityType === PromotionActivityTypeEnum.POINT.type">
<text v-else> {{ data.point }}积分
{{ isArray(data.price) ? fen2yuan(data.price[0]) : fen2yuan(data.price) }} {{ !data.pointPrice || data.pointPrice === 0 ? '' : `+${fen2yuan(data.pointPrice)}` }}
</text> </text>
<template v-else>
<text class="price-unit ss-font-24">{{ priceUnit }}</text>
<text v-if="data.promotionPrice > 0">{{ fen2yuan(data.promotionPrice) }}</text>
<text v-else>
{{ isArray(data.price) ? fen2yuan(data.price[0]) : fen2yuan(data.price) }}
</text>
</template>
</view> </view>
</view> </view>
</view> </view>
@ -87,12 +93,18 @@
class="sm-goods-price font-OPPOSANS" class="sm-goods-price font-OPPOSANS"
:style="[{ color: goodsFields.price.color }]" :style="[{ color: goodsFields.price.color }]"
> >
<text class="price-unit ss-font-24">{{ priceUnit }}</text>
<!-- 活动价格 --> <!-- 活动价格 -->
<text v-if="data.promotionPrice > 0">{{ fen2yuan(data.promotionPrice) }}</text> <text v-if="data.activityType && data.activityType === PromotionActivityTypeEnum.POINT.type">
<text v-else> {{ data.point }}积分
{{ isArray(data.price) ? fen2yuan(data.price[0]) : fen2yuan(data.price) }} {{ !data.pointPrice || data.pointPrice === 0 ? '' : `+${fen2yuan(data.pointPrice)}` }}
</text> </text>
<template v-else>
<text class="price-unit ss-font-24">{{ priceUnit }}</text>
<text v-if="data.promotionPrice > 0">{{ fen2yuan(data.promotionPrice) }}</text>
<text v-else>
{{ isArray(data.price) ? fen2yuan(data.price[0]) : fen2yuan(data.price) }}
</text>
</template>
</view> </view>
</view> </view>
</view> </view>
@ -149,12 +161,18 @@
class="md-goods-price ss-m-t-16 font-OPPOSANS ss-m-r-10" class="md-goods-price ss-m-t-16 font-OPPOSANS ss-m-r-10"
:style="[{ color: goodsFields.price.color }]" :style="[{ color: goodsFields.price.color }]"
> >
<text class="price-unit ss-font-24">{{ priceUnit }}</text>
<!-- 活动价格 --> <!-- 活动价格 -->
<text v-if="data.promotionPrice > 0">{{ fen2yuan(data.promotionPrice) }}</text> <text v-if="data.activityType && data.activityType === PromotionActivityTypeEnum.POINT.type">
<text v-else> {{ data.point }}积分
{{ isArray(data.price) ? fen2yuan(data.price[0]) : fen2yuan(data.price) }} {{ !data.pointPrice || data.pointPrice === 0 ? '' : `+${fen2yuan(data.pointPrice)}` }}
</text> </text>
<template v-else>
<text class="price-unit ss-font-24">{{ priceUnit }}</text>
<text v-if="data.promotionPrice > 0">{{ fen2yuan(data.promotionPrice) }}</text>
<text v-else>
{{ isArray(data.price) ? fen2yuan(data.price[0]) : fen2yuan(data.price) }}
</text>
</template>
</view> </view>
<view <view
v-if=" v-if="
@ -253,12 +271,18 @@
class="goods-origin-price ss-flex ss-col-bottom font-OPPOSANS" class="goods-origin-price ss-flex ss-col-bottom font-OPPOSANS"
:style="[{ color: originPriceColor }]" :style="[{ color: originPriceColor }]"
> >
<text class="price-unit ss-font-20">{{ priceUnit }}</text>
<!-- 活动价格 --> <!-- 活动价格 -->
<text v-if="data.promotionPrice > 0">{{ fen2yuan(data.promotionPrice) }}</text> <text v-if="data.activityType && data.activityType === PromotionActivityTypeEnum.POINT.type">
<text v-else> {{ data.point }}积分
{{ isArray(data.price) ? fen2yuan(data.price[0]) : fen2yuan(data.price) }} {{ !data.pointPrice || data.pointPrice === 0 ? '' : `+${fen2yuan(data.pointPrice)}` }}
</text> </text>
<template v-else>
<text class="price-unit ss-font-20">{{ priceUnit }}</text>
<text v-if="data.promotionPrice > 0">{{ fen2yuan(data.promotionPrice) }}</text>
<text v-else>
{{ isArray(data.price) ? fen2yuan(data.price[0]) : fen2yuan(data.price) }}
</text>
</template>
</view> </view>
</view> </view>
<view class="ss-m-t-8 ss-flex ss-col-center ss-flex-wrap"> <view class="ss-m-t-8 ss-flex ss-col-center ss-flex-wrap">
@ -268,7 +292,7 @@
</view> </view>
<slot name="cart"> <slot name="cart">
<view class="buy-box ss-flex ss-col-center ss-row-center" v-if="buttonShow"> </view> <view class="buy-box ss-flex ss-col-center ss-row-center" v-if="buttonShow"> </view>
</slot> </slot>
</view> </view>
@ -324,12 +348,18 @@
</view> </view>
<view v-if="goodsFields.price?.show" class="ss-flex ss-col-bottom font-OPPOSANS"> <view v-if="goodsFields.price?.show" class="ss-flex ss-col-bottom font-OPPOSANS">
<view class="sl-goods-price ss-m-r-12" :style="[{ color: goodsFields.price.color }]"> <view class="sl-goods-price ss-m-r-12" :style="[{ color: goodsFields.price.color }]">
<text class="price-unit ss-font-24">{{ priceUnit }}</text>
<!-- 活动价格 --> <!-- 活动价格 -->
<text v-if="data.promotionPrice > 0">{{ fen2yuan(data.promotionPrice) }}</text> <text v-if="data.activityType && data.activityType === PromotionActivityTypeEnum.POINT.type">
<text v-else> {{ data.point }}积分
{{ isArray(data.price) ? fen2yuan(data.price[0]) : fen2yuan(data.price) }} {{ !data.pointPrice || data.pointPrice === 0 ? '' : `+${fen2yuan(data.pointPrice)}` }}
</text> </text>
<template v-else>
<text class="price-unit ss-font-24">{{ priceUnit }}</text>
<text v-if="data.promotionPrice > 0">{{ fen2yuan(data.promotionPrice) }}</text>
<text v-else>
{{ isArray(data.price) ? fen2yuan(data.price[0]) : fen2yuan(data.price) }}
</text>
</template>
</view> </view>
<view <view
v-if=" v-if="
@ -361,39 +391,41 @@
* 商品卡片 * 商品卡片
* *
* @property {Array} size = [xs | sm | md | lg | sl ] - 列表数据 * @property {Array} size = [xs | sm | md | lg | sl ] - 列表数据
* @property {String} tag - md及以上才有 * @property {String} tag - md及以上才有
* @property {String} img - 图片 * @property {String} img - 图片
* @property {String} background - 背景色 * @property {String} background - 背景色
* @property {String} topRadius - 上圆角 * @property {String} topRadius - 上圆角
* @property {String} bottomRadius - 下圆角 * @property {String} bottomRadius - 下圆角
* @property {String} title - 标题 * @property {String} title - 标题
* @property {String} titleColor - 标题颜色 * @property {String} titleColor - 标题颜色
* @property {Number} titleWidth = 0 - 标题宽度默认0单位rpx * @property {Number} titleWidth = 0 - 标题宽度默认0单位rpx
* @property {String} subTitle - 副标题 * @property {String} subTitle - 副标题
* @property {String} subTitleColor - 副标题颜色 * @property {String} subTitleColor - 副标题颜色
* @property {String} subTitleBackground - 副标题背景 * @property {String} subTitleBackground - 副标题背景
* @property {String | Number} price - 价格 * @property {String | Number} price - 价格
* @property {String} priceColor - 价格颜色 * @property {String} priceColor - 价格颜色
* @property {String | Number} originPrice - 原价/划线价 * @property {String | Number} originPrice - 原价/划线价
* @property {String} originPriceColor - 原价颜色 * @property {String} originPriceColor - 原价颜色
* @property {String | Number} sales - 销售数量 * @property {String | Number} sales - 销售数量
* @property {String} salesColor - 销售数量颜色 * @property {String} salesColor - 销售数量颜色
* *
* @slots activity - 活动插槽 * @slots activity - 活动插槽
* @slots cart - 购物车插槽默认包含文字背景色文字颜色 || 图片 || 行为 * @slots cart - 购物车插槽默认包含文字背景色文字颜色 || 图片 || 行为
* *
* @event {Function()} click - 点击卡片 * @event {Function()} click - 点击卡片
* *
*/ */
import { computed, getCurrentInstance, onMounted, nextTick } from 'vue'; import { computed, getCurrentInstance, nextTick, onMounted } from 'vue';
import sheep from '@/sheep'; import sheep from '@/sheep';
import { import {
fen2yuan, fen2yuan,
formatExchange,
formatSales, formatSales,
formatStock,
getRewardActivityRuleItemDescriptions, getRewardActivityRuleItemDescriptions,
} from '@/sheep/hooks/useGoods'; } from '@/sheep/hooks/useGoods';
import { formatStock } from '@/sheep/hooks/useGoods';
import { isArray } from 'lodash-es'; import { isArray } from 'lodash-es';
import { PromotionActivityTypeEnum } from '@/sheep/util/const';
// //
const props = defineProps({ const props = defineProps({
@ -520,10 +552,18 @@
const salesAndStock = computed(() => { const salesAndStock = computed(() => {
let text = []; let text = [];
if (props.goodsFields.salesCount?.show) { if (props.goodsFields.salesCount?.show) {
text.push(formatSales(props.data.sales_show_type, props.data.salesCount)); if (props.data.activityType && props.data.activityType === PromotionActivityTypeEnum.POINT.type) {
text.push(formatExchange(props.data.sales_show_type, (props.data.pointTotalStock || 0) - (props.data.pointStock || 0)));
}else {
text.push(formatSales(props.data.sales_show_type, props.data.salesCount));
}
} }
if (props.goodsFields.stock?.show) { if (props.goodsFields.stock?.show) {
text.push(formatStock(props.data.stock_show_type, props.data.stock)); if (props.data.activityType && props.data.activityType === PromotionActivityTypeEnum.POINT.type) {
text.push(formatStock(props.data.stock_show_type, props.data.pointTotalStock));
}else {
text.push(formatStock(props.data.stock_show_type, props.data.stock));
}
} }
return text.join(' | '); return text.join(' | ');
}); });
@ -560,6 +600,7 @@
}); });
} }
} }
onMounted(() => { onMounted(() => {
nextTick(() => { nextTick(() => {
getGoodsPriceCardWH(); getGoodsPriceCardWH();

View File

@ -1,104 +1,166 @@
<!-- 装修商品组件积分商城商品卡片 -->
<template> <template>
<!-- 商品卡片 -->
<view> <view>
<!-- 布局1. 单列大图上图下内容-->
<view <view
v-if="mode === 1 && state.scoreList.length" v-if="layoutType === LayoutTypeEnum.ONE_COL_BIG_IMG && state.spuList.length"
class="goods-sl-box"
>
<view
class="goods-box"
v-for="item in state.spuList"
:key="item.id"
:style="[{ marginBottom: data.space * 2 + 'rpx' }]"
>
<s-goods-column
class=""
size="sl"
:goodsFields="data.fields"
:tagStyle="data.badge"
:data="item"
:titleColor="data.fields.name?.color"
:subTitleColor="data.fields.introduction.color"
:topRadius="data.borderRadiusTop"
:bottomRadius="data.borderRadiusBottom"
@click="sheep.$router.go('/pages/goods/point', { id: item.activityId })"
>
<!-- 购买按钮 -->
<template v-slot:cart>
<button class="ss-reset-button cart-btn" :style="[buyStyle]">
{{ btnBuy.type === 'text' ? btnBuy.text : '' }}
</button>
</template>
</s-goods-column>
</view>
</view>
<!-- 布局2. 单列小图左图右内容 -->
<view
v-if="layoutType === LayoutTypeEnum.ONE_COL_SMALL_IMG && state.spuList.length"
class="goods-lg-box"
>
<view
class="goods-box"
:style="[{ marginBottom: data.space + 'px' }]"
v-for="item in state.spuList"
:key="item.id"
>
<s-goods-column
class="goods-card"
size="lg"
:goodsFields="data.fields"
:data="item"
:tagStyle="data.badge"
:titleColor="data.fields.name?.color"
:subTitleColor="data.fields.introduction.color"
:topRadius="data.borderRadiusTop"
:bottomRadius="data.borderRadiusBottom"
@tap="sheep.$router.go('/pages/goods/point', { id: item.activityId })"
>
<!-- 购买按钮 -->
<template v-slot:cart>
<button class="ss-reset-button cart-btn" :style="[buyStyle]">
{{ btnBuy.type === 'text' ? btnBuy.text : '' }}
</button>
</template>
</s-goods-column>
</view>
</view>
<!-- 布局3. 双列每一列上图下内容-->
<view
v-if="layoutType === LayoutTypeEnum.TWO_COL && state.spuList.length"
class="goods-md-wrap ss-flex ss-flex-wrap ss-col-top" class="goods-md-wrap ss-flex ss-flex-wrap ss-col-top"
> >
<view class="goods-list-box"> <view class="goods-list-box">
<view <view
class="left-list" class="left-list"
:style="[{ paddingRight: data.space + 'rpx', marginBottom: data.space + 'px' }]" :style="[{ paddingRight: data.space + 'rpx', marginBottom: data.space + 'px' }]"
v-for="item in state.leftScoreList" v-for="item in state.leftSpuList"
:key="item.id" :key="item.id"
> >
<s-point-card <s-goods-column
class="goods-md-box" class="goods-md-box"
size="md" size="md"
:goodsFields="goodsFields" :goodsFields="data.fields"
:tagStyle="data.badge"
:data="item" :data="item"
:titleColor="goodsFields.title?.color" :titleColor="data.fields.name?.color"
:subTitleColor="goodsFields.subtitle.color" :subTitleColor="data.fields.introduction.color"
:topRadius="data.borderRadiusTop" :topRadius="data.borderRadiusTop"
:bottomRadius="data.borderRadiusBottom" :bottomRadius="data.borderRadiusBottom"
:titleWidth="330 - marginLeft - marginRight" :titleWidth="330 - marginLeft - marginRight"
@click="sheep.$router.go('/pages/goods/score', { id: item.id })" @click="sheep.$router.go('/pages/goods/seckill', { id: item.activityId })"
@getHeight="mountMasonry($event, 'left')" @getHeight="calculateGoodsColumn($event, 'left')"
> >
<!-- 购买按钮 -->
<template v-slot:cart> <template v-slot:cart>
<button class="ss-reset-button cart-btn" :style="[buyStyle]"> <button class="ss-reset-button cart-btn" :style="[buyStyle]">
{{ buyNowStyle.mode === 1 ? buyNowStyle.text : '' }} {{ btnBuy.type === 'text' ? btnBuy.text : '' }}
</button> </button>
</template> </template>
</s-point-card> </s-goods-column>
</view> </view>
</view> </view>
<view class="goods-list-box"> <view class="goods-list-box">
<view <view
class="right-list" class="right-list"
:style="[{ paddingLeft: data.space + 'rpx', marginBottom: data.space + 'px' }]" :style="[{ paddingLeft: data.space + 'rpx', marginBottom: data.space + 'px' }]"
v-for="item in state.rightScoreList" v-for="item in state.rightSpuList"
:key="item.id" :key="item.id"
> >
<s-score-card <s-goods-column
class="goods-md-box" class="goods-md-box"
size="md" size="md"
:goodsFields="goodsFields" :goodsFields="data.fields"
:tagStyle="data.badge"
:data="item" :data="item"
:titleColor="goodsFields.title?.color" :titleColor="data.fields.name?.color"
:subTitleColor="goodsFields.subtitle.color" :subTitleColor="data.fields.introduction.color"
:topRadius="data.borderRadiusTop" :topRadius="data.borderRadiusTop"
:bottomRadius="data.borderRadiusBottom" :bottomRadius="data.borderRadiusBottom"
:titleWidth="330 - marginLeft - marginRight" :titleWidth="330 - marginLeft - marginRight"
@click="sheep.$router.go('/pages/goods/score', { id: item.id })" @click="sheep.$router.go('/pages/goods/seckill', { id: item.activityId })"
@getHeight="mountMasonry($event, 'right')" @getHeight="calculateGoodsColumn($event, 'right')"
> >
<!-- 购买按钮 -->
<template v-slot:cart> <template v-slot:cart>
<button class="ss-reset-button cart-btn" :style="[buyStyle]"> <button class="ss-reset-button cart-btn" :style="[buyStyle]">
{{ buyNowStyle.mode === 1 ? buyNowStyle.text : '' }} {{ btnBuy.type === 'text' ? btnBuy.text : '' }}
</button> </button>
</template> </template>
</s-score-card> </s-goods-column>
</view> </view>
</view> </view>
<!-- <view class="goods-hack" v-if="state.scoreList.length % 2 == 1" style="width: 345rpx"></view> -->
</view>
<view v-if="mode === 2 && state.scoreList.length" class="goods-lg-box">
<view
class="goods-box"
:style="[{ marginBottom: data.space + 'px' }]"
v-for="item in state.scoreList"
:key="item.id"
>
<s-score-card
class="goods-card"
size="lg"
:goodsFields="goodsFields"
:data="item"
:titleColor="goodsFields.title?.color"
:subTitleColor="goodsFields.subtitle.color"
:topRadius="data.borderRadiusTop"
:bottomRadius="data.borderRadiusBottom"
@tap="sheep.$router.go('/pages/goods/score', { id: item.id })"
>
<template v-slot:cart>
<button class="ss-reset-button cart-btn" :style="[buyStyle]">
{{ buyNowStyle.mode === 1 ? buyNowStyle.text : '' }}
</button>
</template>
</s-score-card>
</view>
</view> </view>
</view> </view>
</template> </template>
<script setup> <script setup>
import { computed, reactive, onMounted } from 'vue'; /**
* 商品卡片
*/
import { computed, onMounted, reactive, ref } from 'vue';
import sheep from '@/sheep'; import sheep from '@/sheep';
import SpuApi from '@/sheep/api/product/spu';
import PointApi from '@/sheep/api/promotion/point';
import { PromotionActivityTypeEnum } from '@/sheep/util/const';
//
const LayoutTypeEnum = {
//
ONE_COL_BIG_IMG: 'oneColBigImg',
//
TWO_COL: 'twoCol',
//
ONE_COL_SMALL_IMG: 'oneColSmallImg',
};
const state = reactive({ const state = reactive({
scoreList: [], spuList: [],
leftScoreList: [], leftSpuList: [],
rightScoreList: [], rightSpuList: [],
}); });
const props = defineProps({ const props = defineProps({
data: { data: {
@ -110,56 +172,113 @@
default() {}, default() {},
}, },
}); });
const { mode, buyNowStyle, goodsFields, goodsIds } = props.data ?? {};
const { marginLeft, marginRight } = props.styles ?? {};
async function getScoreListByIds(ids) {
let { data } = await sheep.$api.app.scoreShop.ids({ ids });
return data;
}
onMounted(async () => { const { layoutType, btnBuy, activityIds } = props.data || {};
state.scoreList = await getScoreListByIds(goodsIds.join(',')); const { marginLeft, marginRight } = props.styles || {};
if (mode === 1) {
mountMasonry();
}
});
//
let count = 0;
let leftHeight = 0;
let rightHeight = 0;
function mountMasonry(height = 0, where = 'left') {
if (!state.scoreList[count]) return;
if (where === 'left') leftHeight += height;
if (where === 'right') rightHeight += height;
if (leftHeight <= rightHeight) {
state.leftScoreList.push(state.scoreList[count]);
} else {
state.rightScoreList.push(state.scoreList[count]);
}
count++;
}
// //
const buyStyle = computed(() => { const buyStyle = computed(() => {
if (buyNowStyle.mode == 1) { if (btnBuy.type === 'text') {
// button // 线
return { return {
background: `linear-gradient(to right, ${buyNowStyle.color1}, ${buyNowStyle.color2})`, background: `linear-gradient(to right, ${btnBuy.bgBeginColor}, ${btnBuy.bgEndColor})`,
}; };
} }
if (btnBuy.type === 'img') {
if (buyNowStyle.mode == 2) { //
// image
return { return {
width: '54rpx', width: '54rpx',
height: '54rpx', height: '54rpx',
background: `url(${sheep.$url.cdn(buyNowStyle.src)}) no-repeat`, background: `url(${sheep.$url.cdn(btnBuy.imgUrl)}) no-repeat`,
backgroundSize: '100% 100%', backgroundSize: '100% 100%',
}; };
} }
}); });
//region
//
let count = 0;
//
let leftHeight = 0;
//
let rightHeight = 0;
/**
* 计算商品在左列还是右列
* @param height 商品的高度
* @param where 添加到哪一列
*/
function calculateGoodsColumn(height = 0, where = 'left') {
//
if (!state.spuList[count]) return;
//
if (where === 'left') leftHeight += height;
if (where === 'right') rightHeight += height;
//
if (leftHeight <= rightHeight) {
state.leftSpuList.push(state.spuList[count]);
} else {
state.rightSpuList.push(state.spuList[count]);
}
//
count++;
}
//endregion
/**
* 根据商品编号列表获取商品列表
* @param ids 商品编号列表
* @return {Promise<undefined>} 商品列表
*/
async function getPointActivityDetailList(ids) {
const { data } = await PointApi.getPointActivityListByIds(ids);
return data;
}
/**
* 根据商品编号获取商品详情
* @param ids 商品编号列表
* @return {Promise<undefined>} 商品列表
*/
async function getSpuDetail(ids) {
const { data: spu } = await SpuApi.getSpuDetail(ids);
return spu;
}
//
onMounted(async () => {
//
const activityList = await getPointActivityDetailList(activityIds.join(','));
// SPUspuList
for (const activity of activityList) {
state.spuList.push(await getSpuDetail(activity.spuId));
}
//
activityList.forEach((activity) => {
// spu
const spu = state.spuList.find((spu) => activity.spuId === spu.id);
if (spu) {
spu.pointStock = activity.stock
spu.pointTotalStock = activity.totalStock
spu.point = activity.point
spu.pointPrice = activity.price
// ID
spu.activityId = activity.id;
//
spu.activityType = PromotionActivityTypeEnum.POINT.type;
}
});
//
if (layoutType === LayoutTypeEnum.TWO_COL) {
//
calculateGoodsColumn();
}
});
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.goods-md-wrap { .goods-md-wrap {
width: 100%; width: 100%;
@ -168,11 +287,18 @@
.goods-list-box { .goods-list-box {
width: 50%; width: 50%;
box-sizing: border-box; box-sizing: border-box;
.left-list { .left-list {
&:nth-last-child(1) { &:nth-last-child(1) {
margin-bottom: 0 !important; margin-bottom: 0 !important;
} }
} }
.right-list {
&:nth-last-child(1) {
margin-bottom: 0 !important;
}
}
} }
.goods-box { .goods-box {
@ -188,7 +314,7 @@
.cart-btn { .cart-btn {
position: absolute; position: absolute;
bottom: 10rpx; bottom: 18rpx;
right: 20rpx; right: 20rpx;
z-index: 11; z-index: 11;
height: 50rpx; height: 50rpx;

View File

@ -33,78 +33,100 @@ export const getTerminal = () => {
// ========== MALL - 营销模块 ========== // ========== MALL - 营销模块 ==========
import dayjs from "dayjs"; import dayjs from 'dayjs';
/** /**
* 优惠类型枚举 * 优惠类型枚举
*/ */
export const PromotionDiscountTypeEnum = { export const PromotionDiscountTypeEnum = {
PRICE: { PRICE: {
type: 1, type: 1,
name: '满减' name: '满减',
}, },
PERCENT: { PERCENT: {
type: 2, type: 2,
name: '折扣' name: '折扣',
} },
} };
/** /**
* 优惠劵模板的有限期类型的枚举 * 优惠劵模板的有限期类型的枚举
*/ */
export const CouponTemplateValidityTypeEnum = { export const CouponTemplateValidityTypeEnum = {
DATE: { DATE: {
type: 1, type: 1,
name: '固定日期可用' name: '固定日期可用',
}, },
TERM: { TERM: {
type: 2, type: 2,
name: '领取之后可用' name: '领取之后可用',
} },
} };
/** /**
* 营销的商品范围枚举 * 营销的商品范围枚举
*/ */
export const PromotionProductScopeEnum = { export const PromotionProductScopeEnum = {
ALL: { ALL: {
scope: 1, scope: 1,
name: '通用劵' name: '通用劵',
}, },
SPU: { SPU: {
scope: 2, scope: 2,
name: '商品劵' name: '商品劵',
}, },
CATEGORY: { CATEGORY: {
scope: 3, scope: 3,
name: '品类劵' name: '品类劵',
} },
} };
// 时间段的状态枚举 // 时间段的状态枚举
export const TimeStatusEnum = { export const TimeStatusEnum = {
WAIT_START: '即将开始', WAIT_START: '即将开始',
STARTED: '进行中', STARTED: '进行中',
END: '已结束', END: '已结束',
} };
/** /**
* 微信小程序的订阅模版 * 微信小程序的订阅模版
*/ */
export const WxaSubscribeTemplate = { export const WxaSubscribeTemplate = {
TRADE_ORDER_DELIVERY: "订单发货通知", TRADE_ORDER_DELIVERY: '订单发货通知',
PROMOTION_COMBINATION_SUCCESS: "拼团结果通知", PROMOTION_COMBINATION_SUCCESS: '拼团结果通知',
PAY_WALLET_RECHARGER_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,
name: '',
},
};
export const getTimeStatusEnum = (startTime, endTime) => { export const getTimeStatusEnum = (startTime, endTime) => {
const now = dayjs(); const now = dayjs();
if (now.isBefore(startTime)) { if (now.isBefore(startTime)) {
return TimeStatusEnum.WAIT_START; return TimeStatusEnum.WAIT_START;
} else if (now.isAfter(endTime)) { } else if (now.isAfter(endTime)) {
return TimeStatusEnum.END; return TimeStatusEnum.END;
} else { } else {
return TimeStatusEnum.STARTED; return TimeStatusEnum.STARTED;
} }
} };