Browse Source

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

puhui999 10 months ago
parent
commit
5552236952

+ 83 - 42
sheep/components/s-goods-column/s-goods-column.vue

@@ -39,12 +39,18 @@
           class="xs-goods-price font-OPPOSANS"
           :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-else>
-            {{ isArray(data.price) ? fen2yuan(data.price[0]) : fen2yuan(data.price) }}
+          <text v-if="data.activityType && data.activityType === PromotionActivityTypeEnum.POINT.type">
+            {{ data.point }}积分
+            {{ !data.pointPrice || data.pointPrice === 0 ? '' : `+${fen2yuan(data.pointPrice)}元` }}
           </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>
@@ -87,12 +93,18 @@
           class="sm-goods-price font-OPPOSANS"
           :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-else>
-            {{ isArray(data.price) ? fen2yuan(data.price[0]) : fen2yuan(data.price) }}
+          <text v-if="data.activityType && data.activityType === PromotionActivityTypeEnum.POINT.type">
+            {{ data.point }}积分
+            {{ !data.pointPrice || data.pointPrice === 0 ? '' : `+${fen2yuan(data.pointPrice)}元` }}
           </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>
@@ -149,12 +161,18 @@
             class="md-goods-price ss-m-t-16 font-OPPOSANS ss-m-r-10"
             :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-else>
-              {{ isArray(data.price) ? fen2yuan(data.price[0]) : fen2yuan(data.price) }}
+            <text v-if="data.activityType && data.activityType === PromotionActivityTypeEnum.POINT.type">
+              {{ data.point }}积分
+              {{ !data.pointPrice || data.pointPrice === 0 ? '' : `+${fen2yuan(data.pointPrice)}元` }}
             </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
             v-if="
@@ -253,12 +271,18 @@
               class="goods-origin-price ss-flex ss-col-bottom font-OPPOSANS"
               :style="[{ color: originPriceColor }]"
             >
-              <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 v-if="data.activityType && data.activityType === PromotionActivityTypeEnum.POINT.type">
+                {{ data.point }}积分
+                {{ !data.pointPrice || data.pointPrice === 0 ? '' : `+${fen2yuan(data.pointPrice)}元` }}
               </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 class="ss-m-t-8 ss-flex ss-col-center ss-flex-wrap">
@@ -268,7 +292,7 @@
       </view>
 
       <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>
     </view>
 
@@ -324,12 +348,18 @@
           </view>
           <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 }]">
-              <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 v-if="data.activityType && data.activityType === PromotionActivityTypeEnum.POINT.type">
+                {{ data.point }}积分
+                {{ !data.pointPrice || data.pointPrice === 0 ? '' : `+${fen2yuan(data.pointPrice)}元` }}
               </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
               v-if="
@@ -361,39 +391,41 @@
    * 商品卡片
    *
    * @property {Array} size = [xs | sm | md | lg | sl ] 			 	- 列表数据
-   * @property {String} tag 											- md及以上才有
-   * @property {String} img 											- 图片
-   * @property {String} background 									- 背景色
-   * @property {String} topRadius 									- 上圆角
-   * @property {String} bottomRadius 									- 下圆角
-   * @property {String} title 										- 标题
-   * @property {String} titleColor 									- 标题颜色
+   * @property {String} tag                      - md及以上才有
+   * @property {String} img                      - 图片
+   * @property {String} background                  - 背景色
+   * @property {String} topRadius                  - 上圆角
+   * @property {String} bottomRadius                  - 下圆角
+   * @property {String} title                    - 标题
+   * @property {String} titleColor                  - 标题颜色
    * @property {Number} titleWidth = 0								- 标题宽度,默认0,单位rpx
-   * @property {String} subTitle 										- 副标题
-   * @property {String} subTitleColor									- 副标题颜色
-   * @property {String} subTitleBackground 							- 副标题背景
-   * @property {String | Number} price 								- 价格
-   * @property {String} priceColor 									- 价格颜色
-   * @property {String | Number} originPrice 							- 原价/划线价
-   * @property {String} originPriceColor 								- 原价颜色
-   * @property {String | Number} sales 								- 销售数量
-   * @property {String} salesColor									- 销售数量颜色
+   * @property {String} subTitle                    - 副标题
+   * @property {String} subTitleColor                  - 副标题颜色
+   * @property {String} subTitleBackground              - 副标题背景
+   * @property {String | Number} price                - 价格
+   * @property {String} priceColor                  - 价格颜色
+   * @property {String | Number} originPrice              - 原价/划线价
+   * @property {String} originPriceColor                - 原价颜色
+   * @property {String | Number} sales                - 销售数量
+   * @property {String} salesColor                  - 销售数量颜色
    *
    * @slots activity												 	- 活动插槽
    * @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 {
     fen2yuan,
+    formatExchange,
     formatSales,
+    formatStock,
     getRewardActivityRuleItemDescriptions,
   } from '@/sheep/hooks/useGoods';
-  import { formatStock } from '@/sheep/hooks/useGoods';
   import { isArray } from 'lodash-es';
+  import { PromotionActivityTypeEnum } from '@/sheep/util/const';
 
   // 接收参数
   const props = defineProps({
@@ -520,10 +552,18 @@
   const salesAndStock = computed(() => {
     let text = [];
     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) {
-      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(' | ');
   });
@@ -560,6 +600,7 @@
       });
     }
   }
+
   onMounted(() => {
     nextTick(() => {
       getGoodsPriceCardWH();

+ 208 - 82
sheep/components/s-point-block/s-point-block.vue

@@ -1,104 +1,166 @@
+<!-- 装修商品组件:【积分商城】商品卡片 -->
 <template>
+  <!-- 商品卡片 -->
   <view>
+    <!-- 布局1. 单列大图(上图,下内容)-->
     <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"
     >
       <view class="goods-list-box">
         <view
           class="left-list"
           :style="[{ paddingRight: data.space + 'rpx', marginBottom: data.space + 'px' }]"
-          v-for="item in state.leftScoreList"
+          v-for="item in state.leftSpuList"
           :key="item.id"
         >
-          <s-point-card
+          <s-goods-column
             class="goods-md-box"
             size="md"
-            :goodsFields="goodsFields"
+            :goodsFields="data.fields"
+            :tagStyle="data.badge"
             :data="item"
-            :titleColor="goodsFields.title?.color"
-            :subTitleColor="goodsFields.subtitle.color"
+            :titleColor="data.fields.name?.color"
+            :subTitleColor="data.fields.introduction.color"
             :topRadius="data.borderRadiusTop"
             :bottomRadius="data.borderRadiusBottom"
             :titleWidth="330 - marginLeft - marginRight"
-            @click="sheep.$router.go('/pages/goods/score', { id: item.id })"
-            @getHeight="mountMasonry($event, 'left')"
+            @click="sheep.$router.go('/pages/goods/seckill', { id: item.activityId })"
+            @getHeight="calculateGoodsColumn($event, 'left')"
           >
+            <!-- 购买按钮 -->
             <template v-slot:cart>
               <button class="ss-reset-button cart-btn" :style="[buyStyle]">
-                {{ buyNowStyle.mode === 1 ? buyNowStyle.text : '' }}
+                {{ btnBuy.type === 'text' ? btnBuy.text : '' }}
               </button>
             </template>
-          </s-point-card>
+          </s-goods-column>
         </view>
       </view>
       <view class="goods-list-box">
         <view
           class="right-list"
           :style="[{ paddingLeft: data.space + 'rpx', marginBottom: data.space + 'px' }]"
-          v-for="item in state.rightScoreList"
+          v-for="item in state.rightSpuList"
           :key="item.id"
         >
-          <s-score-card
+          <s-goods-column
             class="goods-md-box"
             size="md"
-            :goodsFields="goodsFields"
+            :goodsFields="data.fields"
+            :tagStyle="data.badge"
             :data="item"
-            :titleColor="goodsFields.title?.color"
-            :subTitleColor="goodsFields.subtitle.color"
+            :titleColor="data.fields.name?.color"
+            :subTitleColor="data.fields.introduction.color"
             :topRadius="data.borderRadiusTop"
             :bottomRadius="data.borderRadiusBottom"
             :titleWidth="330 - marginLeft - marginRight"
-            @click="sheep.$router.go('/pages/goods/score', { id: item.id })"
-            @getHeight="mountMasonry($event, 'right')"
+            @click="sheep.$router.go('/pages/goods/seckill', { id: item.activityId })"
+            @getHeight="calculateGoodsColumn($event, 'right')"
           >
+            <!-- 购买按钮 -->
             <template v-slot:cart>
               <button class="ss-reset-button cart-btn" :style="[buyStyle]">
-                {{ buyNowStyle.mode === 1 ? buyNowStyle.text : '' }}
+                {{ btnBuy.type === 'text' ? btnBuy.text : '' }}
               </button>
             </template>
-          </s-score-card>
+          </s-goods-column>
         </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>
 </template>
+
 <script setup>
-  import { computed, reactive, onMounted } from 'vue';
+  /**
+   * 商品卡片
+   */
+  import { computed, onMounted, reactive, ref } from 'vue';
   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({
-    scoreList: [],
-    leftScoreList: [],
-    rightScoreList: [],
+    spuList: [],
+    leftSpuList: [],
+    rightSpuList: [],
   });
   const props = defineProps({
     data: {
@@ -110,56 +172,113 @@
       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 () => {
-    state.scoreList = await getScoreListByIds(goodsIds.join(','));
-    if (mode === 1) {
-      mountMasonry();
+  const { layoutType, btnBuy, activityIds } = props.data || {};
+  const { marginLeft, marginRight } = props.styles || {};
+
+  // 购买按钮样式
+  const buyStyle = computed(() => {
+    if (btnBuy.type === 'text') {
+      // 文字按钮:线性渐变背景颜色
+      return {
+        background: `linear-gradient(to right, ${btnBuy.bgBeginColor}, ${btnBuy.bgEndColor})`,
+      };
+    }
+    if (btnBuy.type === 'img') {
+      // 图片按钮
+      return {
+        width: '54rpx',
+        height: '54rpx',
+        background: `url(${sheep.$url.cdn(btnBuy.imgUrl)}) no-repeat`,
+        backgroundSize: '100% 100%',
+      };
     }
   });
 
-  // 加载瀑布流
+  //region 商品瀑布流布局
+  // 下一个要处理的商品索引
   let count = 0;
+  // 左列的高度
   let leftHeight = 0;
+  // 右列的高度
   let rightHeight = 0;
 
-  function mountMasonry(height = 0, where = 'left') {
-    if (!state.scoreList[count]) return;
+  /**
+   * 计算商品在左列还是右列
+   * @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.leftScoreList.push(state.scoreList[count]);
+      state.leftSpuList.push(state.spuList[count]);
     } else {
-      state.rightScoreList.push(state.scoreList[count]);
+      state.rightSpuList.push(state.spuList[count]);
     }
+    // 计数
     count++;
   }
-  // 购买按钮样式
-  const buyStyle = computed(() => {
-    if (buyNowStyle.mode == 1) {
-      // button
-      return {
-        background: `linear-gradient(to right, ${buyNowStyle.color1}, ${buyNowStyle.color2})`,
-      };
+
+  //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(','));
+    // 循环获取活动商品SPU详情并添加到spuList
+    for (const activity of activityList) {
+      state.spuList.push(await getSpuDetail(activity.spuId));
     }
 
-    if (buyNowStyle.mode == 2) {
-      // image
-      return {
-        width: '54rpx',
-        height: '54rpx',
-        background: `url(${sheep.$url.cdn(buyNowStyle.src)}) no-repeat`,
-        backgroundSize: '100% 100%',
-      };
+    // 循环活动列表
+    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>
+
 <style lang="scss" scoped>
   .goods-md-wrap {
     width: 100%;
@@ -168,11 +287,18 @@
   .goods-list-box {
     width: 50%;
     box-sizing: border-box;
+
     .left-list {
       &:nth-last-child(1) {
         margin-bottom: 0 !important;
       }
     }
+
+    .right-list {
+      &:nth-last-child(1) {
+        margin-bottom: 0 !important;
+      }
+    }
   }
 
   .goods-box {
@@ -188,7 +314,7 @@
 
     .cart-btn {
       position: absolute;
-      bottom: 10rpx;
+      bottom: 18rpx;
       right: 20rpx;
       z-index: 11;
       height: 50rpx;

+ 71 - 49
sheep/util/const.js

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