owen 1 год назад
Родитель
Сommit
07601aec09

+ 64 - 76
pages/activity/groupon/detail.vue

@@ -4,7 +4,7 @@
     <view v-if="state.data && !state.loading">
       <view
         class="recharge-box"
-        v-if="state.data.goods"
+        v-if="state.data.headRecord"
         :style="[
           {
             marginTop: '-' + Number(statusBarHeight + 88) + 'rpx',
@@ -14,29 +14,28 @@
       >
         <s-goods-item
           class="goods-box"
-          :img="state.data.goods.image"
-          :title="state.data.goods.title"
-          :price="state.data.goods.price[0]"
+          :img="state.data.headRecord.picUrl"
+          :title="state.data.headRecord.spuName"
+          :price="state.data.headRecord.combinationPrice"
           priceColor="#E1212B"
           @tap="
             sheep.$router.go('/pages/goods/groupon', {
-              id: state.data.goods.id,
-              activity_id: state.data.goods.activity.id,
+              id: state.data.headRecord.activityId
             })
           "
           :style="[{ top: Number(statusBarHeight + 108) + 'rpx' }]"
         >
           <template #groupon>
             <view class="ss-flex">
-              <view class="sales-title">{{ state.data.num }}人团</view>
-              <view class="num-title ss-m-l-20">已拼{{ state.data.goods.sales }}件</view>
+              <view class="sales-title">{{ state.data.headRecord.userSize }}人团</view>
+              <view class="num-title ss-m-l-20">已拼{{ state.data.headRecord.userCount }}件</view>
             </view>
           </template>
         </s-goods-item>
       </view>
       <view class="countdown-box detail-card ss-p-t-44 ss-flex-col ss-col-center">
-        <view v-if="state.data.status === 'finish' || state.data.status === 'finish_fictitious'">
-          <view v-if="state.data.my">
+        <view v-if="state.activity.status === 1">
+          <view v-if="state.data.orderId">
             <view class="countdown-title ss-flex">
               <text class="cicon-check-round"></text>
               恭喜您~拼团成功
@@ -49,24 +48,23 @@
             </view>
           </view>
         </view>
-        <view v-if="state.data.status === 'invalid'">
+        <view v-if="state.activity.status === 2">
           <view class="countdown-title ss-flex">
             <text class="cicon-info"></text>
-            {{ state.data.my ? '拼团超时,已自动退款' : '该团已解散' }}
+            {{ state.data.orderId ? '拼团超时,已自动退款' : '该团已解散' }}
           </view>
         </view>
-        <view v-if="state.data.status === 'ing'">
-          <!-- TODO: 拼团进行中+活动结束-->
-          <view v-if="state.data.activity_status === 'ended'">
+        <view v-if="state.activity.status === 0">
+          <view v-if="state.data.headRecord.expireTime <= new Date().getTime()">
             <view class="countdown-title ss-flex">
               <text class="cicon-info"></text>
               拼团已结束,请关注下次活动
             </view>
           </view>
 
-          <view class="countdown-title ss-flex" v-if="state.data.activity_status === 'ing'">
+          <view class="countdown-title ss-flex" v-else>
             还差
-            <view class="num">{{ state.data.num - state.data.current_num }}人</view>
+            <view class="num">{{ state.data.headRecord.userSize - state.data.headRecord.userCount }}人</view>
             拼团成功
             <view class="ss-flex countdown-time">
               <view class="countdown-h ss-flex ss-row-center">{{ endTime.h }}</view>
@@ -83,9 +81,15 @@
         </view>
 
         <view class="ss-m-t-60 ss-flex ss-flex-wrap ss-row-center">
+          <!-- 团长 -->
+          <view class="header-avatar ss-m-r-24 ss-m-b-20">
+            <image :src="sheep.$url.cdn(state.data.headRecord.avatar)" class="avatar-img"></image>
+            <view class="header-tag ss-flex ss-col-center ss-row-center">团长</view>
+          </view>
+          <!-- 团员 -->
           <view
             class="header-avatar ss-m-r-24 ss-m-b-20"
-            v-for="item in state.data.groupon_logs"
+            v-for="item in state.data.memberRecords"
             :key="item.id"
           >
             <image :src="sheep.$url.cdn(item.avatar)" class="avatar-img"></image>
@@ -96,74 +100,53 @@
               团长
             </view>
           </view>
-          <view class="default-avatar ss-m-r-24 ss-m-b-20" v-for="item in state.number" :key="item">
+          <!-- 还有几个坑位 -->
+          <view class="default-avatar ss-m-r-24 ss-m-b-20" v-for="item in state.remainNumber" :key="item">
             <image
               :src="sheep.$url.static('/static/img/shop/avatar/unknown.png')"
               class="avatar-img"
             ></image>
           </view>
         </view>
-        <view
-          class="detail-cell-wrap ss-flex ss-col-center ss-row-between"
-          v-if="state.data.activity?.richtext_id > 0"
-          @tap="
-            sheep.$router.go('/pages/public/richtext', {
-              id: state.data.activity.richtext_id,
-              title: state.data.activity.richtext_title,
-            })
-          "
-        >
-          <view class="label-text">玩法</view>
-          <view class="ss-flex">
-            <view class="cell-content ss-line-1 ss-flex-1">
-              {{ state.data.activity?.richtext_title }}
-            </view>
-            <button class="ss-reset-button">
-              <text class="_icon-forward right-forwrad-icon"></text>
-            </button>
-          </view>
-        </view>
       </view>
       <view
-        v-if="
-          state.data.status == 'finish' ||
-          state.data.status == 'finish_fictitious' ||
-          state.data.status == 'invalid'
-        "
+        v-if="state.activity.status === 1 || state.activity.status === 2"
         class="ss-m-t-40 ss-flex ss-row-center"
       >
         <button
           class="ss-reset-button order-btn"
-          v-if="state.data.my"
-          @tap="onDetail(state.data.my.order_id)"
+          v-if="state.data.orderId"
+          @tap="onDetail(state.data.orderId)"
         >
           查看订单
         </button>
         <button class="ss-reset-button join-btn" v-else @tap="onCreateGroupon"> 我要开团 </button>
       </view>
-      <view v-if="state.data.status === 'ing'" class="ss-m-t-40 ss-flex ss-row-center">
-        <view v-if="state.data.activity_status === 'ended'">
+      <!-- 处于进入中时,查看订单或参加或邀请好友或参加 -->
+      <view v-if="state.activity.status === 0" class="ss-m-t-40 ss-flex ss-row-center">
+        <view v-if="state.data.headRecord.expireTime <= new Date().getTime()">
           <button
             class="ss-reset-button join-btn"
-            v-if="state.data.my"
-            @tap="onDetail(state.data.my.order_id)"
+            v-if="state.data.orderId"
+            @tap="onDetail(state.data.orderId)"
           >
             查看订单
           </button>
+          <!-- 待确认 -->
           <button
             class="ss-reset-button disabled-btn"
             v-else
             disabled
-            @tap="onDetail(state.data.my.order_id)"
+            @tap="onDetail(state.data.orderId)"
           >
             去参团
           </button>
         </view>
         <view v-else class="ss-flex ss-row-center">
-          <view v-if="state.data.my">
+          <view v-if="state.data.orderId">
             <button
               class="ss-reset-button join-btn"
-              :disabled="state.data.activity_status === 'ing' && endTime.ms <= 0"
+              :disabled="endTime.ms <= 0"
               @tap="onShare"
             >
               邀请好友来拼团
@@ -172,7 +155,7 @@
           <view v-else>
             <button
               class="ss-reset-button join-btn"
-              :disabled="state.data.activity_status === 'ing' && endTime.ms <= 0"
+              :disabled="endTime.ms <= 0"
               @tap="onJoinGroupon()"
             >
               立即参团
@@ -204,6 +187,7 @@
   import { useDurationTime } from '@/sheep/hooks/useGoods';
   import { showShareModal } from '@/sheep/hooks/useModal';
   import { isEmpty } from 'lodash';
+  import CombinationApi from "@/sheep/api/promotion/combination";
 
   const headerBg = sheep.$url.css('/static/img/shop/user/withdraw_bg.png');
   const statusBarHeight = sheep.$platform.device.statusBarHeight * 2;
@@ -214,15 +198,17 @@
     showSelectSku: false,
     grouponNum: 0,
     number: 0,
+    activity: {},
+    combinationHeadId: null, // 拼团团长编号
   });
 
   const shareInfo = computed(() => {
     if (isEmpty(state.data)) return {};
     return sheep.$platform.share.getShareInfo(
       {
-        title: state.data.goods.title,
-        image: sheep.$url.cdn(state.data.goods.image),
-        desc: state.data.goods.subtitle,
+        title: state.data.headRecord.spuName,
+        image: sheep.$url.cdn(state.data.headRecord.picUrl),
+        desc: state.data.goods?.subtitle,
         params: {
           page: '5',
           query: state.data.id,
@@ -230,10 +216,10 @@
       },
       {
         type: 'groupon', // 邀请拼团海报
-        title: state.data.goods.title, // 商品标题
-        image: sheep.$url.cdn(state.data.goods.image), // 商品主图
-        price: state.data.goods.price[0], // 商品价格
-        original_price: state.data.goods.original_price, // 商品原价
+        title: state.data.headRecord.spuName, // 商品标题
+        image: sheep.$url.cdn(state.data.headRecord.picUrl), // 商品主图
+        price: state.data.goods?.price, // 商品价格
+        original_price: state.data.goods?.original_price, // 商品原价
       },
     );
   });
@@ -260,25 +246,23 @@
   // 立即参团
   function onJoinGroupon() {
     state.grouponAction = 'join';
-    state.grouponId = state.data.id;
+    state.grouponId = state.data.activityId;
+    state.combinationHeadId = state.data.id;
     state.grouponNum = state.data.num;
     state.showSelectSku = true;
   }
 
   // 立即购买
-  function onBuy(e) {
+  function onBuy(sku) {
     sheep.$router.go('/pages/order/confirm', {
       data: JSON.stringify({
         order_type: 'goods',
-        buy_type: 'groupon',
-        activity_id: state.data.activity.id,
-        groupon_id: state.grouponId,
-        groupon_num: state.grouponNum,
-        goods_list: [
+        combinationActivityId: state.data.activity.id,
+        combinationHeadId: state.combinationHeadId,
+        items: [
           {
-            goods_id: e.goods_id,
-            goods_num: e.goods_num,
-            goods_sku_price_id: e.id,
+            skuId: sku.id,
+            count: sku.count,
           },
         ],
       }),
@@ -286,16 +270,20 @@
   }
 
   const endTime = computed(() => {
-    return useDurationTime(state.data.expire_time);
+    return useDurationTime(state.data.headRecord.expireTime);
   });
 
   // 获取拼团团队详情
   async function getGrouponDetail(id) {
-    const { error, data } = await sheep.$api.activity.grouponDetail(id);
-    if (error === 0) {
+    const { code, data } = await CombinationApi.getCombinationRecordDetail(id);
+    if (code === 0) {
       state.data = data;
-      let number = Number(state.data.num - state.data.current_num);
-      state.number = number > 0 ? number : 0;
+      const remainNumber = Number(state.data.headRecord.userSize - state.data.headRecord.userCount);
+      state.remainNumber = remainNumber > 0 ? remainNumber : 0;
+
+      // 获取活动信息
+      const { data: activity } = await CombinationApi.getCombinationActivity(data.headRecord.activityId);
+      state.activity = activity;
     } else {
       state.data = null;
     }

+ 88 - 124
pages/activity/groupon/list.vue

@@ -5,23 +5,17 @@
       :style="[{ marginTop: '-' + Number(statusBarHeight + 88) + 'rpx' }]"
     ></view>
     <view class="list-content">
+      <!-- 参团会员统计 -->
       <view class="content-header ss-flex-col ss-col-center ss-row-center">
-        <view class="content-header-title ss-m-b-22 ss-flex ss-row-center">
-          <view>{{ state.activityInfo.title }}</view>
-          <!-- <view class="more">更多</view> -->
-        </view>
-        <view class="content-header-box ss-flex ss-row-center">
-          <view class="countdown-box ss-flex" v-if="endTime?.ms > 0 && state.activityInfo">
-            <view class="countdown-title ss-m-r-12">距结束</view>
-            <view class="ss-flex countdown-time">
-              <view class="ss-flex countdown-h">{{ endTime.h }}</view>
-              <view class="ss-m-x-4">:</view>
-              <view class="countdown-num ss-flex ss-row-center">{{ endTime.m }}</view>
-              <view class="ss-m-x-4">:</view>
-              <view class="countdown-num ss-flex ss-row-center">{{ endTime.s }}</view>
-            </view>
+        <view class="content-header-title ss-flex ss-row-center">
+          <view v-for="(item, index) in state.summaryData.avatars" :key="index" class="picture"
+                :style='index === 6 ? "position: relative" : "position: static"'>
+            <span class="avatar" :style='`background-image: url(${item})`'></span>
+            <span v-if="index === 6 && state.summaryData.avatars.length > 3" class="mengceng">
+              <i>···</i>
+            </span>
           </view>
-          <view class="" v-if="endTime?.ms < 0 && state.activityInfo"> 活动已结束 </view>
+          <text class="pic_count">{{ state.summaryData.userCount || 0 }}人参与</text>
         </view>
       </view>
       <scroll-view
@@ -37,12 +31,7 @@
             size="lg"
             :data="item"
             :grouponTag="true"
-            @click="
-              sheep.$router.go('/pages/goods/groupon', {
-                id: item.id,
-                activity_id: state.activityId,
-              })
-            "
+            @click="sheep.$router.go('/pages/goods/groupon', { id: item.id })"
           >
             <template v-slot:cart>
               <button class="ss-reset-button cart-btn">去拼团</button>
@@ -55,92 +44,67 @@
           :content-text="{
             contentdown: '上拉加载更多',
           }"
-          @tap="loadmore"
+          @tap="loadMore"
         />
       </scroll-view>
     </view>
   </s-layout>
 </template>
 <script setup>
-  import { reactive, computed } from 'vue';
+  import { reactive } from 'vue';
   import { onLoad, onReachBottom } from '@dcloudio/uni-app';
   import sheep from '@/sheep';
-  import _ from 'lodash';
-  import { useDurationTime } from '@/sheep/hooks/useGoods';
+  import CombinationApi from "@/sheep/api/promotion/combination";
 
-  const { screenHeight, safeAreaInsets, screenWidth, safeArea } = sheep.$platform.device;
-  const sys_navBar = sheep.$platform.navbar;
+  const { safeAreaInsets, safeArea } = sheep.$platform.device;
+  const sysNavBar = sheep.$platform.navbar;
   const statusBarHeight = sheep.$platform.device.statusBarHeight * 2;
-  const pageHeight =
-    (safeArea.height + safeAreaInsets.bottom) * 2 + statusBarHeight - sys_navBar - 350;
+  const pageHeight = (safeArea.height + safeAreaInsets.bottom) * 2 + statusBarHeight - sysNavBar - 350;
   const headerBg = sheep.$url.css('/static/img/shop/goods/groupon-header.png');
 
   const state = reactive({
-    activityId: 0,
     pagination: {
       data: [],
-      current_page: 1,
+      pageNo: 1,
       total: 1,
-      last_page: 1,
     },
     loadStatus: '',
-    activityInfo: {},
-  });
-  // 倒计时
-  const endTime = computed(() => {
-    if (state.activityInfo.end_time) {
-      return useDurationTime(state.activityInfo.end_time);
-    }
+    summaryData: {}
   });
 
-  async function getList(activityId, page = 1, list_rows = 4) {
+  // 加载统计数据
+  const getSummary = async () => {
+    const { data } = await CombinationApi.getCombinationRecordSummary()
+    state.summaryData = data
+  }
+
+  // 加载活动列表
+  async function getList(pageNo = 1, pageSize = 10) {
     state.loadStatus = 'loading';
-    const res = await sheep.$api.goods.activityList({
-      list_rows,
-      activity_id: activityId,
-      page,
+    const { data } = await CombinationApi.getCombinationActivityPage({
+      pageNo,
+      pageSize,
     });
-    if (res.error === 0) {
-      if (page >= 2) {
-        let couponList = _.concat(state.pagination.data, res.data.data);
-        state.pagination = {
-          ...res.data,
-          data: couponList,
-        };
-      } else {
-        state.pagination = res.data;
-      }
-      if (state.pagination.current_page < state.pagination.last_page) {
-        state.loadStatus = 'more';
-      } else {
-        state.loadStatus = 'noMore';
-      }
-    }
+    data.list.forEach(activity => {
+      state.pagination.data.push({...activity, price: activity.combinationPrice})
+    })
+    state.pagination.total = data.total;
+    state.pagination.pageNo = pageNo;
+    state.loadStatus = state.pagination.data.length < state.pagination.total ? 'more' : 'noMore';
   }
-  async function getActivity(id) {}
+
   // 加载更多
-  function loadmore() {
+  function loadMore() {
     if (state.loadStatus !== 'noMore') {
-      getList(state.activityId, state.pagination.current_page + 1);
+      getList(state.pagination.pageNo + 1);
     }
   }
   // 上拉加载更多
-  onReachBottom(() => {
-    loadmore();
-  });
-  onLoad(async (options) => {
-    if (!options.id) {
-      state.activityInfo = null;
-      return;
-    }
-    state.activityId = options.id;
-    getList(state.activityId);
-    const { error, data } = await sheep.$api.activity.activity(options.id);
-    if (error === 0) {
-      state.activityInfo = data;
-    } else {
-      state.activityInfo = null;
-    }
+  onReachBottom(() => loadMore());
+  // 页面初始化
+  onLoad( () => {
+    getSummary();
+    getList();
   });
 </script>
 <style lang="scss" scoped>
@@ -160,7 +124,7 @@
     .content-header {
       width: 100%;
       border-radius: 20rpx 20rpx 0 0;
-      height: 150rpx;
+      height: 100rpx;
       background: linear-gradient(180deg, #fff4f7, #ffe4d1);
       .content-header-title {
         width: 100%;
@@ -178,55 +142,55 @@
           color: #999999;
           line-height: 30rpx;
         }
-      }
-      .content-header-box {
-        width: 678rpx;
-        height: 64rpx;
-        background: rgba($color: #fff, $alpha: 0.66);
-        border-radius: 32px;
-        .num {
-          font-size: 24rpx;
-          font-family: OPPOSANS;
-          font-weight: 500;
-          color: #f51c11;
-          line-height: 30rpx;
+
+        .picture {
+          display: inline-table;
         }
-        .title {
-          font-size: 24rpx;
-          font-weight: 400;
-          font-family: OPPOSANS;
-          color: #333;
-          line-height: 30rpx;
+
+        .avatar {
+          width: 38rpx;
+          height: 38rpx;
+          display: inline-table;
+          vertical-align: middle;
+          -webkit-user-select: none;
+          -moz-user-select: none;
+          -ms-user-select: none;
+          user-select: none;
+          border-radius: 50%;
+          background-repeat: no-repeat;
+          background-size: cover;
+          background-position: 0 0;
+          margin-right: -10rpx;
+          box-shadow: 0 0 0 1px #fe832a;
         }
-        .countdown-title {
-          font-size: 28rpx;
+
+        .pic_count {
+          margin-left: 30rpx;
+          font-size: 22rpx;
           font-weight: 500;
-          color: #333333;
-          line-height: 28rpx;
+          width: auto;
+          height: auto;
+          background: linear-gradient(90deg, #ff6600 0%, #fe832a 100%);
+          color: #FFFFFF;
+          border-radius: 19rpx;
+          padding: 4rpx 14rpx;
         }
 
-        .countdown-time {
-          font-size: 28rpx;
-          color: rgba(#ed3c30, 0.23);
-          .countdown-h {
-            font-size: 24rpx;
-            font-family: OPPOSANS;
-            font-weight: 500;
-            color: #ffffff;
-            padding: 0 4rpx;
-            height: 40rpx;
-            background: rgba(#ed3c30, 0.23);
-            border-radius: 6rpx;
-          }
-          .countdown-num {
-            font-size: 24rpx;
-            font-family: OPPOSANS;
-            font-weight: 500;
-            color: #ffffff;
-            width: 40rpx;
-            height: 40rpx;
-            background: rgba(#ed3c30, 0.23);
-            border-radius: 6rpx;
+        .mengceng {
+          width: 40rpx;
+          height: 40rpx;
+          line-height: 36rpx;
+          background: rgba(51, 51, 51, 0.6);
+          text-align: center;
+          border-radius: 50%;
+          opacity: 1;
+          position: absolute;
+          left: -2rpx;
+          color: #FFF;
+          top: 2rpx;
+          i{
+            font-style: normal;
+            font-size: 20rpx;
           }
         }
       }

+ 1 - 2
pages/goods/components/detail/detail-activity-tip.vue

@@ -51,8 +51,7 @@
     const typePath = type === 1 ? 'seckill' :
       type === 2 ? 'TODO 拼团' : 'groupon';
     sheep.$router.go(`/pages/goods/${typePath}`, {
-      id: activity.spuId,
-      activity_id: activity.id,
+      id: activity.id,
     });
   }
 </script>

+ 1 - 1
pages/goods/components/detail/detail-cell-sku.vue

@@ -19,7 +19,7 @@
     }
   });
   const value = computed(() => {
-    if (!props.sku.id) {
+    if (!props.sku?.id) {
       return '请选择商品规格';
     }
     let str = '';

+ 20 - 17
pages/goods/components/groupon/groupon-card-list.vue

@@ -1,30 +1,32 @@
+<!-- 拼团活动参团记录卡片 -->
 <template>
   <view v-if="state.list.length > 0" class="groupon-list detail-card ss-p-x-20">
     <view class="join-activity ss-flex ss-row-between ss-m-t-30">
-      <view class="">已有{{ modelValue.sales }}人参与活动</view>
+      <!-- todo: 接口缺少总数 -->
+      <view class="">已有{{ state.list.length }}人参与活动</view>
       <text class="cicon-forward"></text>
     </view>
     <view
-      v-for="(item, index) in state.list"
-      @tap="sheep.$router.go('/pages/activity/groupon/detail', { id: item.id })"
+      v-for="(record, index) in state.list"
+      @tap="sheep.$router.go('/pages/activity/groupon/detail', { id: record.id })"
       :key="index"
       class="ss-m-t-40 ss-flex ss-row-between border-bottom ss-p-b-30"
     >
       <view class="ss-flex ss-col-center">
-        <image :src="sheep.$url.cdn(item.leader.avatar)" class="user-avatar"></image>
-        <view class="user-nickname ss-m-l-20 ss-line-1">{{ item.leader.nickname }}</view>
+        <image :src="sheep.$url.cdn(record.avatar)" class="user-avatar"></image>
+        <view class="user-nickname ss-m-l-20 ss-line-1">{{ record.nickname }}</view>
       </view>
       <view class="ss-flex ss-col-center">
         <view class="ss-flex-col ss-col-bottom ss-m-r-20">
           <view class="title ss-flex ss-m-b-14">
             还差
-            <view class="num">{{ item.num - item.current_num }}人</view>
+            <view class="num">{{ record.userSize - record.userCount }}人</view>
             成团
           </view>
-          <view class="end-time">{{ endTime(item.expire_time) }}</view>
+          <view class="end-time">{{ endTime(record.expireTime) }}</view>
         </view>
         <view class="">
-          <button class="ss-reset-button go-btn" @tap.stop="onJoinGroupon(item)"> 去参团 </button>
+          <button class="ss-reset-button go-btn" @tap.stop="onJoinGroupon(record)"> 去参团 </button>
         </view>
       </view>
     </view>
@@ -35,6 +37,7 @@
   import { onMounted, reactive } from 'vue';
   import sheep from '@/sheep';
   import { useDurationTime } from '@/sheep/hooks/useGoods';
+  import CombinationApi from "@/sheep/api/promotion/combination";
 
   const props = defineProps({
     modelValue: {
@@ -45,13 +48,14 @@
   const state = reactive({
     list: [],
   });
-  const emits = defineEmits(['join']);
 
-  function onJoinGroupon(groupon) {
-    emits('join', groupon);
+  // 去参团
+  const emits = defineEmits(['join']);
+  function onJoinGroupon(record) {
+    emits('join', record);
   }
 
-  // 倒计时
+  // 结束时间或状态
   function endTime(time) {
     const durationTime = useDurationTime(time);
 
@@ -66,12 +70,11 @@
     return timeText;
   }
 
+  // 初始化
   onMounted(async () => {
-    const { data } = await sheep.$api.activity.getGrouponList({
-      goods_id: props.modelValue.id,
-      activity_id: props.modelValue.activity.id,
-    });
-    state.list = data.data;
+    // 查询参团记录
+    const { data } = await CombinationApi.getHeadCombinationRecordList(props.modelValue.id, 1 , 10);
+    state.list = data;
   });
 </script>
 

+ 64 - 123
pages/goods/groupon.vue

@@ -4,17 +4,14 @@
     <detailNavbar />
     <!-- 骨架屏 -->
     <detailSkeleton v-if="state.skeletonLoading" />
-    <!-- 空置页 -->
+    <!-- 下架/售罄提醒 -->
     <s-empty
-      v-else-if="
-        state.goodsInfo === null ||
-        !['groupon', 'groupon_ladder'].includes(state.goodsInfo.activity_type)
-      "
-      text="活动不存在或已结束"
-      icon="/static/soldout-empty.png"
-      showAction
-      actionText="返回上一页"
-      @clickAction="sheep.$router.back()"
+        v-else-if="state.goodsInfo === null || state.activity.status !== 0 || state.activity.endTime < new Date().getTime()"
+        text="活动不存在或已结束"
+        icon="/static/soldout-empty.png"
+        showAction
+        actionText="返回上一页"
+        @clickAction="sheep.$router.back()"
     />
     <block v-else>
       <view class="detail-swiper-selector">
@@ -35,7 +32,7 @@
             <view>
               <view class="price-box ss-flex ss-col-bottom ss-m-b-18">
                 <view class="price-text ss-m-r-16">
-                  {{ goodsPrice }}
+                  {{ fen2yuan(state.activity.price || state.goodsInfo.price) }}
                 </view>
                 <view class="tig ss-flex ss-col-center">
                   <view class="tig-icon ss-flex ss-col-center ss-row-center">
@@ -51,11 +48,11 @@
               <view class="ss-flex ss-row-between">
                 <view
                   class="origin-price ss-flex ss-col-center"
-                  v-if="state.goodsInfo.original_price"
+                  v-if="state.goodsInfo.price"
                 >
                   单买价:
                   <view class="origin-price-text">
-                    {{ state.goodsInfo.original_goods_price[0] || state.goodsInfo.original_price }}
+                    {{ fen2yuan(state.goodsInfo.price) }}
                   </view>
                 </view>
               </view>
@@ -74,38 +71,18 @@
             <view class="countdown-title" v-else> 活动已结束 </view>
           </view>
 
-          <view class="title-text ss-line-2 ss-m-b-6">{{ state.goodsInfo.title }}</view>
-          <view class="subtitle-text ss-line-1">{{ state.goodsInfo.subtitle }}</view>
+          <view class="title-text ss-line-2 ss-m-b-6">{{ state.goodsInfo.name }}</view>
+          <view class="subtitle-text ss-line-1">{{ state.goodsInfo.introduction }}</view>
         </view>
 
         <!-- 功能卡片 -->
         <view class="detail-cell-card detail-card ss-flex-col">
           <!-- 规格 -->
-          <detail-cell-sku
-            v-model="state.selectedSkuPrice.goods_sku_text"
-            :skus="state.goodsInfo.skus"
-            @tap="state.showSelectSku = true"
-          />
-          <!-- 玩法 -->
-          <detail-cell
-            v-if="state.goodsInfo.activity.richtext_id > 0"
-            label="玩法"
-            :value="state.goodsInfo.activity.richtext_title"
-            @click="
-              sheep.$router.go('/pages/public/richtext', {
-                id: state.goodsInfo.activity.richtext_id,
-                title: state.goodsInfo.activity.richtext_title,
-              })
-            "
-          />
+          <detail-cell-sku :sku="state.selectedSkuPrice" @tap="state.showSelectSku = true" />
         </view>
 
         <!-- 参团列表 -->
-        <groupon-card-list
-          v-if="state.goodsInfo.activity.rules.is_team_card === '1'"
-          v-model="state.goodsInfo"
-          @join="onJoinGroupon"
-        />
+        <groupon-card-list v-model="state.activity" @join="onJoinGroupon" />
 
         <!-- 规格与数量弹框 -->
         <s-select-groupon-sku
@@ -114,7 +91,6 @@
           :grouponAction="state.grouponAction"
           :grouponNum="state.grouponNum"
           @buy="onBuy"
-          @ladder="onLadder"
           @change="onSkuChange"
           @close="onSkuClose"
         />
@@ -123,43 +99,36 @@
       <!-- 评价 -->
       <detail-comment-card class="detail-comment-selector" :goodsId="state.goodsId" />
       <!-- 详情 -->
-      <detail-content-card class="detail-content-selector" :content="state.goodsInfo.content" />
+      <detail-content-card class="detail-content-selector" :content="state.goodsInfo.description" />
 
       <!-- 商品tabbar -->
       <!-- TODO: 已售罄、预热 判断 设计-->
       <detail-tabbar v-model="state.goodsInfo">
         <view class="buy-box ss-flex ss-col-center ss-p-r-20">
           <button
-            v-if="state.goodsInfo.activity.rules.is_alone == 1"
             class="ss-reset-button origin-price-btn ss-flex-col"
             @tap="sheep.$router.go('/pages/goods/index', { id: state.goodsInfo.id })"
           >
-            <view class="btn-price">{{
-              state.goodsInfo.original_goods_price[0] || state.goodsInfo.original_price
-            }}</view>
+            <view class="btn-price">{{ fen2yuan(state.goodsInfo.marketPrice) }}</view>
             <view>原价购买</view>
           </button>
-          <button v-else class="ss-reset-button origin-price-btn ss-flex-col">
-            <view class="btn-title">{{
-              state.grouponNum == 0 ? '阶梯团' : state.grouponNum + '人团'
-            }}</view>
-          </button>
           <button
             class="ss-reset-button btn-tox ss-flex-col"
             @tap="onCreateGroupon"
             :class="
-              state.goodsInfo.activity.status === 'ing' && state.goodsInfo.stock != 0
+              state.activity.status === 0 && state.goodsInfo.stock !== 0
                 ? 'check-btn-box'
                 : 'disabled-btn-box'
             "
-            :disabled="state.goodsInfo.stock === 0 || state.goodsInfo.activity.status != 'ing'"
+            :disabled="state.goodsInfo.stock === 0 || state.activity.status !== 0"
           >
-            <view class="btn-price">{{ goodsPrice }}</view>
-            <view v-if="state.goodsInfo.activity.status === 'ing'">
+            <view class="btn-price">{{ fen2yuan(state.activity.price || state.goodsInfo.price) }}</view>
+            <view v-if="state.activity.startTime > new Date().getTime()">未开始</view>
+            <view v-else-if="state.activity.endTime <= new Date().getTime()">已结束</view>
+            <view v-else>
               <view v-if="state.goodsInfo.stock === 0">已售罄</view>
               <view v-else>立即开团</view>
             </view>
-            <view v-else>{{ state.goodsInfo.activity.status_text }}</view>
           </button>
         </view>
       </detail-tabbar>
@@ -169,19 +138,20 @@
 </template>
 
 <script setup>
-  import { reactive, computed, ref } from 'vue';
+  import { reactive, computed } from 'vue';
   import { onLoad, onPageScroll } from '@dcloudio/uni-app';
   import sheep from '@/sheep';
   import { isEmpty } from 'lodash';
   import detailNavbar from './components/detail/detail-navbar.vue';
-  import detailCell from './components/detail/detail-cell.vue';
   import detailCellSku from './components/detail/detail-cell-sku.vue';
   import detailTabbar from './components/detail/detail-tabbar.vue';
   import detailSkeleton from './components/detail/detail-skeleton.vue';
   import detailCommentCard from './components/detail/detail-comment-card.vue';
   import detailContentCard from './components/detail/detail-content-card.vue';
   import grouponCardList from './components/groupon/groupon-card-list.vue';
-  import { useDurationTime, formatPrice, formatGoodsSwiper } from '@/sheep/hooks/useGoods';
+  import {useDurationTime, formatGoodsSwiper, fen2yuan} from '@/sheep/hooks/useGoods';
+  import CombinationApi from "@/sheep/api/promotion/combination";
+  import SpuApi from "@/sheep/api/product/spu";
 
 
   const headerBg = sheep.$url.css('/static/img/shop/goods/groupon-bg.png');
@@ -189,7 +159,6 @@
   const disabledBtnBg = sheep.$url.css(
     '/static/img/shop/goods/activity-btn-disabled.png',
   );
-  const seckillBg = sheep.$url.css('/static/img/shop/goods/seckill-tip-bg.png');
   const grouponBg = sheep.$url.css('/static/img/shop/goods/groupon-tip-bg.png');
 
   onPageScroll(() => {});
@@ -200,32 +169,16 @@
     goodsSwiper: [],        // 商品轮播图
     showSelectSku: false,   // 显示规格弹框
     selectedSkuPrice: {},   // 选中的规格价格
+    activity: {},           // 团购活动
     grouponId: 0,           // 团购ID
-    grouponType: '',        // 团购类型
     grouponNum: 0,          // 团购人数
     grouponAction: 'create',  // 团购操作
-  });
-
-  // 商品主价格
-  const goodsPrice = computed(() => {
-    if (isEmpty(state.selectedSkuPrice)) {
-      return formatPrice(state.goodsInfo.price);
-    }
-	if(state.grouponNum === 0 && state.grouponType === 'groupon_ladder') {
-		return formatPrice(state.goodsInfo.price)
-	}
-    if (state.grouponType === 'groupon') {
-      return state.selectedSkuPrice.groupon_price;
-    }
-    if (state.grouponType === 'groupon_ladder') {
-      return state.selectedSkuPrice.ladder_price;
-    }
-    return '';
+    combinationHeadId: null, // 拼团团长编号
   });
 
   // 倒计时
   const endTime = computed(() => {
-    return useDurationTime(state.goodsInfo.activity.end_time);
+    return useDurationTime(state.activity.endTime);
   });
 
   // 规格变更
@@ -233,15 +186,6 @@
     state.selectedSkuPrice = e;
   }
 
-  // 阶梯变更
-  function onLadder(e) {
-    state.showSelectSku = false;
-    state.grouponNum = e
-    setTimeout(() => {
-      state.showSelectSku = true;
-    }, 80);
-  }
-
   function onSkuClose() {
     state.showSelectSku = false;
   }
@@ -253,51 +197,53 @@
     state.showSelectSku = true;
   }
 
-  // 点击参团
-  function onJoinGroupon(groupon) {
+  /**
+   * 去参团
+   * @param record 团长的团购记录
+   */
+  function onJoinGroupon(record) {
     state.grouponAction = 'join';
-    state.grouponId = groupon.id;
-    state.grouponNum = groupon.num;
+    state.grouponId = record.activityId;
+    state.combinationHeadId = record.id;
+    state.grouponNum = record.userSize;
     state.showSelectSku = true;
   }
 
   // 立即购买
-  function onBuy(e) {
+  function onBuy(sku) {
     sheep.$router.go('/pages/order/confirm', {
       data: JSON.stringify({
         order_type: 'goods',
-        buy_type: 'groupon',
-        activity_id: state.goodsInfo.activity.id,
-        groupon_id: state.grouponId,
-        groupon_num: state.grouponNum,
-        goods_list: [
+        combinationActivityId: state.activity.id,
+        combinationHeadId: state.combinationHeadId,
+        items: [
           {
-            goods_id: e.goods_id,
-            goods_num: e.goods_num,
-            goods_sku_price_id: e.id,
+            skuId: sku.id,
+            count: sku.count,
           },
         ],
       }),
     });
   }
 
+  // 分享信息
   const shareInfo = computed(() => {
-    if (isEmpty(state.goodsInfo?.activity)) return {};
+    if (isEmpty(state.activity)) return {};
     return sheep.$platform.share.getShareInfo(
       {
-        title: state.goodsInfo.title,
-        image: sheep.$url.cdn(state.goodsInfo.image),
+        title: state.activity.name,
+        image: sheep.$url.cdn(state.goodsInfo.picUrl),
         params: {
           page: '3',
-          query: state.goodsInfo.id + ',' + state.goodsInfo.activity.id,
+          query: state.activity.id,
         },
       },
       {
         type: 'goods', // 商品海报
-        title: state.goodsInfo.title, // 商品标题
-        image: sheep.$url.cdn(state.goodsInfo.image), // 商品主图
-        price: state.goodsInfo.price[0], // 商品价格
-        original_price: state.goodsInfo.original_price, // 商品原价
+        title: state.activity.name, // 商品标题
+        image: sheep.$url.cdn(state.goodsInfo.picUrl), // 商品主图
+        price: fen2yuan(state.goodsInfo.price), // 商品价格
+        marketPrice: fen2yuan(state.goodsInfo.marketPrice), // 商品原价
       },
     );
   });
@@ -308,20 +254,22 @@
       state.goodsInfo = null;
       return;
     }
-    state.goodsId = options.id;
+    state.grouponId = options.id;
+    // 加载活动信息
+    const { code, data: activity } = await CombinationApi.getCombinationActivity(state.grouponId);
+    state.activity = activity;
     // 加载商品信息
-    const { error, data } = await sheep.$api.goods.detail(options.id, {
-      activity_id: options.activity_id,
+    const { data: spu } = await SpuApi.getSpuDetail(activity.spuId);
+    state.goodsId = spu.id;
+    activity.products.forEach(product => {
+      spu.price = Math.min(spu.price, product.combinationPrice); // 设置 SPU 的最低价格
     });
     // 关闭骨架屏
     state.skeletonLoading = false;
-    if (error === 0) {
-      state.goodsInfo = data;
-      state.grouponType = state.goodsInfo.activity_type;
-      if (state.grouponType === 'groupon') {
-        state.grouponNum = state.goodsInfo.activity.rules.team_num;
-      }
-      state.goodsSwiper = formatGoodsSwiper(state.goodsInfo.images);
+    if (code === 0) {
+      state.goodsInfo = spu;
+      state.grouponNum = activity.userSize;
+      state.goodsSwiper = formatGoodsSwiper(state.goodsInfo.sliderPicUrls);
     } else {
       // 未找到商品
       state.goodsInfo = null;
@@ -526,13 +474,6 @@
     }
   }
 
-  //秒杀卡片
-  .seckill-box {
-    background: v-bind(seckillBg)
-      no-repeat;
-    background-size: 100% 100%;
-  }
-
   .groupon-box {
     background: v-bind(grouponBg)
       no-repeat;

+ 6 - 6
sheep/api/promotion/combination.js

@@ -5,7 +5,7 @@ const CombinationApi = {
     // 获得拼团活动列表
     getCombinationActivityList: (count) => {
         return request({
-            url: "promotion/combination-activity/list",
+            url: "/app-api/promotion/combination-activity/list",
             method: 'GET',
             params: {count}
         });
@@ -14,7 +14,7 @@ const CombinationApi = {
     // 获得拼团活动分页
     getCombinationActivityPage: (params) => {
         return request({
-            url: "promotion/combination-activity/page",
+            url: "/app-api/promotion/combination-activity/page",
             method: 'GET',
             params
         });
@@ -23,7 +23,7 @@ const CombinationApi = {
     // 获得拼团活动明细
     getCombinationActivity: (id) => {
         return request({
-            url: "promotion/combination-activity/get-detail",
+            url: "/app-api/promotion/combination-activity/get-detail",
             method: 'GET',
             params: {
                 id
@@ -34,7 +34,7 @@ const CombinationApi = {
     // 获得最近 n 条拼团记录(团长发起的)
     getHeadCombinationRecordList: (activityId, status, count) => {
         return request({
-            url: "promotion/combination-record/get-head-list",
+            url: "/app-api/promotion/combination-record/get-head-list",
             method: 'GET',
             params: {
                 activityId,
@@ -47,7 +47,7 @@ const CombinationApi = {
     // 获得拼团记录明细
     getCombinationRecordDetail: (id) => {
         return request({
-            url: "promotion/combination-record/get-detail",
+            url: "/app-api/promotion/combination-record/get-detail",
             method: 'GET',
             params: {
                 id
@@ -58,7 +58,7 @@ const CombinationApi = {
     // 获得拼团记录的概要信息
     getCombinationRecordSummary: () => {
         return request({
-            url: "promotion/combination-record/get-summary",
+            url: "/app-api/promotion/combination-record/get-summary",
             method: 'GET',
         });
     }

+ 14 - 1
sheep/api/promotion/coupon.js

@@ -67,7 +67,20 @@ const CouponApi = {
         auth: true,
       },
     });
+  },
+  // 获得匹配指定商品的优惠劵列表
+  getMatchCouponList: (price, spuIds, skuIds, categoryIds) => {
+    return request({
+      url: '/app-api/promotion/coupon/match-list',
+      method: 'GET',
+      params: {
+        price,
+        spuIds: spuIds.join(','),
+        skuIds: skuIds.join(','),
+        categoryIds: categoryIds.join(','),
+      },
+    });
   }
 };
 
-export default CouponApi;
+export default CouponApi;

+ 119 - 245
sheep/components/s-select-groupon-sku/s-select-groupon-sku.vue

@@ -1,124 +1,70 @@
 <template>
   <!-- 拼团商品规格弹窗 -->
   <su-popup :show="show" round="10" @close="emits('close')">
+    <!-- SKU 信息 -->
     <view class="ss-modal-box bg-white ss-flex-col">
       <view class="modal-header ss-flex ss-col-center">
         <view class="header-left ss-m-r-30">
-          <image
-            class="sku-image"
-            :src="sheep.$url.cdn(state.selectedSkuPrice.image || goodsInfo.image)"
-            mode="aspectFill"
-          >
-          </image>
+          <image class="sku-image" :src="sheep.$url.cdn(state.selectedSku.picUrl || goodsInfo.picUrl)" mode="aspectFill" />
         </view>
         <view class="header-right ss-flex-col ss-row-between ss-flex-1">
           <view class="goods-title ss-line-2">
             <view class="tig ss-flex ss-col-center">
               <view class="tig-icon ss-flex ss-col-center ss-row-center">
                 <view class="groupon-tag">
-                  <image :src="sheep.$url.static('/static/img/shop/goods/groupon-tag-white.png')">
-                  </image>
+                  <image :src="sheep.$url.static('/static/img/shop/goods/groupon-tag-white.png')" />
                 </view>
               </view>
               <view class="tig-title">拼团价</view>
             </view>
             <view class="info-title">
-              {{ goodsInfo.title }}
+              {{ goodsInfo.name }}
             </view>
           </view>
           <view class="header-right-bottom ss-flex ss-col-center ss-row-between">
-            <view class="price-text"> {{ goodsPrice }}</view>
+            <view class="price-text"> {{ fen2yuan(goodsInfo.price) }}</view>
 
             <view class="stock-text ss-m-l-20">
-              库存{{ state.selectedSkuPrice.stock || goodsInfo.stock }}件
+              库存{{ state.selectedSku.stock || goodsInfo.stock }}件
             </view>
           </view>
         </view>
       </view>
       <view class="modal-content ss-flex-1">
         <scroll-view scroll-y="true" class="modal-content-scroll">
-          <view
-            v-if="grouponAction === 'create' && activityType === 'groupon_ladder'"
-            class="sku-item ss-m-b-20"
-          >
-            <view class="label-text ss-m-b-20">拼团人数</view>
+          <view class="sku-item ss-m-b-20" v-for="property in propertyList" :key="property.id">
+            <view class="label-text ss-m-b-20">{{ property.name }}</view>
             <view class="ss-flex ss-col-center ss-flex-wrap">
-              <button
-                v-for="(ladder, key) in goodsInfo.activity.rules.ladders"
-                :key="key"
-                class="ss-reset-button spec-btn"
-                :class="[
+              <button class="ss-reset-button spec-btn" v-for="value in property.values" :class="[
                   {
-                    'checked-btn': grouponNum == ladder,
+                    'checked-btn': state.currentPropertyArray[property.id] === value.id,
                   },
-                ]"
-                @tap="onSelectLadder(ladder)"
-              >
-                {{ ladder }}人团
-              </button>
-            </view>
-          </view>
-          <view class="sku-item ss-m-b-20" v-for="sku1 in goodsInfo.skus" :key="sku1.id">
-            <view class="label-text ss-m-b-20">{{ sku1.name }}</view>
-            <view class="ss-flex ss-col-center ss-flex-wrap">
-              <button
-                class="ss-reset-button spec-btn"
-                v-for="sku2 in sku1.children"
-                :class="[
                   {
-                    'checked-btn': state.currentSkuArray[sku2.parent_id] == sku2.id,
+                    'disabled-btn': value.disabled === true,
                   },
-                  {
-                    'disabled-btn': sku2.disabled == true,
-                  },
-                ]"
-                :key="sku2.id"
-                :disabled="sku2.disabled == true"
-                @tap="onSelectSku(sku2.parent_id, sku2.id)"
-              >
-                {{ sku2.name }}
+                ]" :key="value.id" :disabled="value.disabled === true" @tap="onSelectSku(property.id, value.id)">
+                {{ value.name }}
               </button>
             </view>
           </view>
           <view class="buy-num-box ss-flex ss-col-center ss-row-between">
             <view class="label-text">购买数量</view>
-            <su-number-box
-              :min="1"
-              :max="state.selectedSkuPrice.stock"
-              :step="1"
-              v-model="state.selectedSkuPrice.goods_num"
-              @change="onNumberChange($event)"
-              activity="groupon"
-            ></su-number-box>
+            <su-number-box :min="1" :max="state.selectedSku.stock" :step="1"
+                           v-model="state.selectedSku.count" @change="onNumberChange($event)" activity="groupon" />
           </view>
         </scroll-view>
       </view>
+
+      <!-- 操作区 -->
       <view class="modal-footer ss-p-y-20">
         <view class="buy-box ss-flex ss-col-center ss-flex ss-col-center ss-row-center">
           <view class="ss-flex">
             <button class="ss-reset-button origin-price-btn ss-flex-col">
-              <view class="btn-title">{{ grouponNum === 0 ? '阶梯团' : grouponNum + '人团' }}</view>
+              <view class="btn-title">{{ grouponNum + '人团' }}</view>
             </button>
             <button class="ss-reset-button btn-tox ss-flex-col" @tap="onBuy">
-              <view class="btn-price">
-                {{
-                  grouponAction === 'create' && goodsInfo.activity.rules.is_leader_discount == 1
-                    ? leaderPrice
-                    : goodsPrice
-                }}
-              </view>
-              <view
-                v-if="
-                  grouponAction === 'create' && goodsInfo.activity.rules.is_leader_discount == 0
-                "
-                >立即开团</view
-              >
-              <view
-                v-else-if="
-                  grouponAction === 'create' && goodsInfo.activity.rules.is_leader_discount == 1
-                "
-                >团长立减价</view
-              >
+              <view class="btn-price">{{ fen2yuan(goodsInfo.price) }}</view>
+              <view v-if="grouponAction === 'create'">立即开团</view>
               <view v-else-if="grouponAction === 'join'">参与拼团</view>
             </button>
           </view>
@@ -131,8 +77,7 @@
 <script setup>
   import { computed, reactive, watch } from 'vue';
   import sheep from '@/sheep';
-  import { formatPrice } from '@/sheep/hooks/useGoods';
-  import { isEmpty } from 'lodash';
+  import {convertProductPropertyList, fen2yuan} from '@/sheep/hooks/useGoods';
 
   const headerBg = sheep.$url.css('/static/img/shop/goods/groupon-btn-long.png');
   const emits = defineEmits(['change', 'addCart', 'buy', 'close', 'ladder']);
@@ -143,7 +88,7 @@
     },
     goodsInfo: {
       type: Object,
-      default() {},
+      default () {},
     },
     grouponAction: {
       type: String,
@@ -155,257 +100,186 @@
     },
   });
   const state = reactive({
-    selectedSkuPrice: {},
-    currentSkuArray: [],
+    selectedSku: {}, // 选中的 SKU
+    currentPropertyArray: [], // 当前选中的属性,实际是个 Map。key 是 property 编号,value 是 value 编号
     grouponNum: props.grouponNum,
   });
-  //输入框改变数量
-  function onNumberChange(e) {
-    if(e === 0) return;
-    if (state.selectedSkuPrice.goods_num === e) return;
-    state.selectedSkuPrice.goods_num = e;
-  }
 
-  // 默认单规格
-  if (!props.goodsInfo.is_sku) {
-    state.selectedSkuPrice = props.goodsInfo.sku_prices[0];
-  }
-
-  // 活动类型
-  const activityType = props.goodsInfo.activity_type;
+  const propertyList = convertProductPropertyList(props.goodsInfo.skus);
 
-  // 可选规格
-  const skuPrices = computed(() => {
-    let skuPrices = props.goodsInfo.sku_prices;
-    if (props.goodsInfo.is_sku) {
-      skuPrices.forEach((item) => {
-        item.goods_sku_id_arr = item.goods_sku_ids.split(',');
-      });
+  // SKU 列表
+  const skuList = computed(() => {
+    let skuPrices = props.goodsInfo.skus;
+    for (let price of skuPrices) {
+      price.value_id_array = price.properties.map((item) => item.valueId)
     }
     return skuPrices;
   });
 
-  const skuList = props.goodsInfo.skus;
-
-  // 规格价格
-  const goodsPrice = computed(() => {
-    if (isEmpty(state.selectedSkuPrice)) {
-      return formatPrice(props.goodsInfo.price);
-    }
-    if (props.grouponNum === 0 && activityType === 'groupon_ladder') {
-      return formatPrice(props.goodsInfo.price);
-    }
-
-    if (activityType === 'groupon') {
-      return state.selectedSkuPrice.groupon_price;
-    }
-    if (activityType === 'groupon_ladder') {
-      const ladder = getSkuPriceByLadder();
-      state.selectedSkuPrice.ladder_price = ladder.ladder_price;
-      return ladder.ladder_price;
-    }
-  });
-
-  // 团长优惠
-  const leaderPrice = computed(() => {
-    if (isEmpty(state.selectedSkuPrice)) {
-      return formatPrice(props.goodsInfo.price);
-    }
-
-    if (props.grouponNum === 0 && activityType === 'groupon_ladder') {
-      return formatPrice(props.goodsInfo.price);
-    }
-
-    if (activityType === 'groupon') {
-      return state.selectedSkuPrice.leader_price;
-    }
-    if (activityType === 'groupon_ladder') {
-      const ladder = getSkuPriceByLadder();
-      return ladder.leader_ladder_price;
-    }
-  });
-
-  // 获取阶梯价
-  function getSkuPriceByLadder() {
-    return state.selectedSkuPrice.ladders.find((item) => item.ladder == props.grouponNum);
-  }
-
   watch(
-    () => state.selectedSkuPrice,
+    () => state.selectedSku,
     (newVal) => {
       emits('change', newVal);
-    },
-    {
+    }, {
       immediate: true, // 立即执行
       deep: true, // 深度监听
     },
   );
 
+  // 输入框改变数量
+  function onNumberChange(e) {
+    if (e === 0) return;
+    if (state.selectedSku.count === e) return;
+    state.selectedSku.count = e;
+  }
+
   // 点击购买
   function onBuy() {
-    if (!state.selectedSkuPrice.goods_id) {
+    if (!state.selectedSku.id || state.selectedSku.id <= 0) {
       sheep.$helper.toast('请选择规格');
       return;
     }
-    if (state.selectedSkuPrice.stock <= 0) {
+    if (state.selectedSku.stock <= 0) {
       sheep.$helper.toast('库存不足');
       return;
     }
-    emits('buy', state.selectedSkuPrice);
+    emits('buy', state.selectedSku);
   }
 
-  // 改变禁用状态
-  function changeDisabled(isChecked = false, pid = 0, skuId = 0) {
-    let newPrice = []; // 所有可以选择的 skuPrice
-
+  // 改变禁用状态:计算每个 property 属性值的按钮,是否禁用
+  function changeDisabled(isChecked = false, propertyId = 0, valueId = 0) {
+    let newSkus = []; // 所有可以选择的 sku 数组
     if (isChecked) {
-      // 选中规格
-      // 当前点击选中规格下的 所有可用 skuPrice
-      for (let price of skuPrices.value) {
+      // 情况一:选中 property
+      // 获得当前点击选中 property 的、所有可用 SKU
+      for (let price of skuList.value) {
         if (price.stock <= 0) {
-          // this.goodsNum 不判断是否大于当前选择数量,在 uni-number-box 判断,并且 取 stock 和 goods_num 的小值
           continue;
         }
-        if (price.goods_sku_id_arr.indexOf(skuId.toString()) >= 0) {
-          newPrice.push(price);
+        if (price.value_id_array.indexOf(valueId) >= 0) {
+          newSkus.push(price);
         }
       }
     } else {
-      // 取消选中
-      // 当前所选规格下,所有可以选择的 skuPrice
-      newPrice = getCanUseSkuPrice();
+      // 情况二:取消选中 property
+      // 当前所选 property 下,所有可以选择的 SKU
+      newSkus = getCanUseSkuList();
     }
 
-    // 所有存在并且有库存未选择的规格项 的 子项 id
-    let noChooseSkuIds = [];
-    for (let price of newPrice) {
-      noChooseSkuIds = noChooseSkuIds.concat(price.goods_sku_id_arr);
+    // 所有存在并且有库存未选择的 SKU 的 value 属性值 id
+    let noChooseValueIds = [];
+    for (let price of newSkus) {
+      noChooseValueIds = noChooseValueIds.concat(price.value_id_array);
     }
-
-    // 去重
-    noChooseSkuIds = Array.from(new Set(noChooseSkuIds));
+    noChooseValueIds = Array.from(new Set(noChooseValueIds)); // 去重
 
     if (isChecked) {
-      // 去除当前选中的规格项
-      let index = noChooseSkuIds.indexOf(skuId.toString());
-      noChooseSkuIds.splice(index, 1);
+      // 去除当前选中的 value 属性值 id
+      let index = noChooseValueIds.indexOf(valueId);
+      noChooseValueIds.splice(index, 1);
     } else {
-      // 循环去除当前已选择的规格项
-      state.currentSkuArray.forEach((sku) => {
-        if (sku.toString() != '') {
-          // sku 为空是反选 填充的
-          let index = noChooseSkuIds.indexOf(sku.toString());
-          if (index >= 0) {
-            // sku 存在于 noChooseSkuIds
-            noChooseSkuIds.splice(index, 1);
-          }
+      // 循环去除当前已选择的 value 属性值 id
+      state.currentPropertyArray.forEach((currentPropertyId) => {
+        if (currentPropertyId.toString() !== '') {
+          return;
+        }
+        // currentPropertyId 为空是反选 填充的
+        let index = noChooseValueIds.indexOf(currentPropertyId);
+        if (index >= 0) {
+          // currentPropertyId 存在于 noChooseValueIds
+          noChooseValueIds.splice(index, 1);
         }
       });
     }
 
-    // 当前已选择的规格大类
-    let chooseSkuKey = [];
+    // 当前已选择的 property 数组
+    let choosePropertyIds = [];
     if (!isChecked) {
-      // 当前已选择的规格大类
-      state.currentSkuArray.forEach((sku, key) => {
-        if (sku != '') {
-          // sku 为空是反选 填充的
-          chooseSkuKey.push(key);
+      // 当前已选择的 property
+      state.currentPropertyArray.forEach((currentPropertyId, currentValueId) => {
+        if (currentPropertyId !== '') {
+          // currentPropertyId 为空是反选 填充的
+          choosePropertyIds.push(currentValueId);
         }
       });
     } else {
-      // 当前点击选择的规格大类
-      chooseSkuKey = [pid];
+      // 当前点击选择的 property
+      choosePropertyIds = [propertyId];
     }
 
-    for (let i in skuList) {
-      // 当前点击的规格,或者取消选择时候 已选中的规格 不进行处理
-      if (chooseSkuKey.indexOf(skuList[i]['id']) >= 0) {
+    for (let propertyIndex in propertyList) {
+      // 当前点击的 property、或者取消选择时候,已选中的 property 不进行处理
+      if (choosePropertyIds.indexOf(propertyList[propertyIndex]['id']) >= 0) {
         continue;
       }
-
-      for (let j in skuList[i]['children']) {
-        // 如果当前规格项 id 不存在于有库存的规格项中,则禁用
-        if (noChooseSkuIds.indexOf(skuList[i]['children'][j]['id'].toString()) >= 0) {
-          skuList[i]['children'][j]['disabled'] = false;
-        } else {
-          skuList[i]['children'][j]['disabled'] = true;
-        }
+      // 如果当前 property id 不存在于有库存的 SKU 中,则禁用
+      for (let valueIndex in propertyList[propertyIndex]['values']) {
+        propertyList[propertyIndex]['values'][valueIndex]['disabled'] =
+            noChooseValueIds.indexOf(propertyList[propertyIndex]['values'][valueIndex]['id']) < 0; // true 禁用 or false 不禁用
       }
     }
   }
 
-  // 当前所选规格下,获取所有有库存的 skuPrice
-  function getCanUseSkuPrice() {
-    let newPrice = [];
-
-    for (let price of skuPrices.value) {
-      if (price.stock <= 0) {
-        // || price.stock < this.goodsNum		不判断是否大于当前选择数量,在 uni-number-box 判断,并且 取 stock 和 goods_num 的小值
+  // 当前所选属性下,获取所有有库存的 SKU 们
+  function getCanUseSkuList() {
+    let newSkus = [];
+    for (let sku of skuList.value) {
+      if (sku.stock <= 0) {
         continue;
       }
-      var isOk = true;
-
-      state.currentSkuArray.forEach((sku) => {
-        // sku 不为空,并且,这个 条 skuPrice 没有被选中,则排除
-        if (sku.toString() != '' && price.goods_sku_id_arr.indexOf(sku.toString()) < 0) {
+      let isOk = true;
+      state.currentPropertyArray.forEach((propertyId) => {
+        // propertyId 不为空,并且,这个 条 sku 没有被选中,则排除
+        if (propertyId.toString() !== '' && sku.value_id_array.indexOf(propertyId) < 0) {
           isOk = false;
         }
       });
-
       if (isOk) {
-        newPrice.push(price);
+        newSkus.push(sku);
       }
     }
-
-    return newPrice;
-  }
-
-  // 选择阶梯拼团人数
-  function onSelectLadder(ladder) {
-    emits('ladder', ladder);
+    return newSkus;
   }
 
   // 选择规格
-  function onSelectSku(pid, skuId) {
+  function onSelectSku(propertyId, valueId) {
     // 清空已选择
-    if (activityType === 'groupon_ladder' && props.grouponNum == 0) {
-      sheep.$helper.toast('请选择拼团人数');
-      return;
-    }
     let isChecked = true; // 选中 or 取消选中
-    if (state.currentSkuArray[pid] != undefined && state.currentSkuArray[pid] == skuId) {
+    if (state.currentPropertyArray[propertyId] !== undefined && state.currentPropertyArray[propertyId] === valueId) {
       // 点击已被选中的,删除并填充 ''
       isChecked = false;
-      state.currentSkuArray.splice(pid, 1, '');
+      state.currentPropertyArray.splice(propertyId, 1, '');
     } else {
       // 选中
-      state.currentSkuArray[pid] = skuId;
+      state.currentPropertyArray[propertyId] = valueId;
     }
 
-    let chooseSkuId = []; // 选中的规格大类
-    state.currentSkuArray.forEach((sku) => {
-      if (sku != '') {
-        // sku 为空是反选 填充的
-        chooseSkuId.push(sku);
+    // 选中的 property 大类
+    let choosePropertyId = [];
+    state.currentPropertyArray.forEach((currentPropertyId) => {
+      if (currentPropertyId !== '') {
+        // currentPropertyId 为空是反选 填充的
+        choosePropertyId.push(currentPropertyId);
       }
     });
 
-    // 当前所选规格下,所有可以选择的 skuPric
-    let newPrice = getCanUseSkuPrice();
-    // 判断所有规格大类是否选择完成
-    if (chooseSkuId.length == skuList.length && newPrice.length) {
-      newPrice[0].goods_num = state.selectedSkuPrice.goods_num || 1;
-      state.selectedSkuPrice = newPrice[0];
+    // 当前所选 property 下,所有可以选择的 SKU 们
+    let newSkuList = getCanUseSkuList();
+
+    // 判断所有 property 大类是否选择完成
+    if (choosePropertyId.length === propertyList.length && newSkuList.length) {
+      newSkuList[0].count = state.selectedSku.count || 1;
+      state.selectedSku = newSkuList[0];
     } else {
-      state.selectedSkuPrice = {};
+      state.selectedSku = {};
     }
 
-    // 改变规格项禁用状态
-    changeDisabled(isChecked, pid, skuId);
+    // 改变 property 禁用状态
+    changeDisabled(isChecked, propertyId, valueId);
   }
 
   changeDisabled(false);
+  // TODO 芋艿:待讨论的优化点:1)单规格,要不要默认选中;2)默认要不要选中第一个规格
 </script>
 
 <style lang="scss" scoped>

+ 1 - 1
sheep/hooks/useGoods.js

@@ -384,4 +384,4 @@ export function formatRewardActivityRule(activity, rule) {
     return `满 ${rule.limit} 件减 ${fen2yuan(rule.discountPrice)} 元`;
   }
   return '';
-}
+}

+ 1 - 0
sheep/platform/share.js

@@ -67,6 +67,7 @@ const buildSpmQuery = (params) => {
   let shareId = '0'; // 设置分享者用户ID
   if (typeof params.shareId === 'undefined') {
     if (user.isLogin) {
+      // todo @芋艿 id为空
       shareId = user.userInfo.id;
     }
   }

+ 4 - 4
sheep/ui/su-number-box/su-number-box.vue

@@ -9,8 +9,8 @@
       class="cicon-move-round"
       :class="{
         'uni-numbox--disabled': inputValue <= min || disabled,
-        'groupon-btn': activity == 'groupon',
-        'seckill-btn': activity == 'seckill',
+        'groupon-btn': activity === 'groupon',
+        'seckill-btn': activity === 'seckill',
       }"
       @click="_calcValue('minus')"
     ></text>
@@ -31,8 +31,8 @@
       class="cicon-add-round"
       :class="{
         'uni-numbox--disabled': inputValue >= max || disabled,
-        'groupon-btn': activity == 'groupon',
-        'seckill-btn': activity == 'seckill',
+        'groupon-btn': activity === 'groupon',
+        'seckill-btn': activity === 'seckill',
       }"
       @click="_calcValue('plus')"
     ></text>