Jelajahi Sumber

fix: 阶梯拼团\创建拼团\参与拼团选择团人数修复

ldh 2 tahun lalu
induk
melakukan
582c995ff6

+ 5 - 4
pages/goods/groupon.vue

@@ -116,7 +116,7 @@
           :show="state.showSelectSku"
           :show="state.showSelectSku"
           :goodsInfo="state.goodsInfo"
           :goodsInfo="state.goodsInfo"
           :grouponAction="state.grouponAction"
           :grouponAction="state.grouponAction"
-          :grouponNum="state.defaultGrouponNum"
+          :grouponNum="state.grouponNum"
           @buy="onBuy"
           @buy="onBuy"
           @ladder="onLadder"
           @ladder="onLadder"
           @change="onSkuChange"
           @change="onSkuChange"
@@ -208,7 +208,6 @@
     selectedSkuPrice: {},   // 选中的规格价格
     selectedSkuPrice: {},   // 选中的规格价格
     grouponId: 0,           // 团购ID
     grouponId: 0,           // 团购ID
     grouponType: '',        // 团购类型
     grouponType: '',        // 团购类型
-    defaultGrouponNum: 0,   // 默认团购人数
     grouponNum: 0,          // 团购人数
     grouponNum: 0,          // 团购人数
     grouponAction: 'create',  // 团购操作  
     grouponAction: 'create',  // 团购操作  
   });
   });
@@ -242,7 +241,11 @@
 
 
   // 阶梯变更
   // 阶梯变更
   function onLadder(e) {
   function onLadder(e) {
+    state.showSelectSku = false;
     state.grouponNum = e
     state.grouponNum = e
+    setTimeout(() => {
+      state.showSelectSku = true;
+    }, 80);
   }
   }
 
 
   function onSkuClose() {
   function onSkuClose() {
@@ -260,7 +263,6 @@
   function onJoinGroupon(groupon) {
   function onJoinGroupon(groupon) {
     state.grouponAction = 'join';
     state.grouponAction = 'join';
     state.grouponId = groupon.id;
     state.grouponId = groupon.id;
-    state.defaultGrouponNum = groupon.num;
     state.grouponNum = groupon.num;
     state.grouponNum = groupon.num;
     state.showSelectSku = true;
     state.showSelectSku = true;
   }
   }
@@ -323,7 +325,6 @@
       state.goodsInfo = data;
       state.goodsInfo = data;
       state.grouponType = state.goodsInfo.activity_type;
       state.grouponType = state.goodsInfo.activity_type;
       if (state.grouponType === 'groupon') {
       if (state.grouponType === 'groupon') {
-        state.defaultGrouponNum = state.goodsInfo.activity.rules.team_num;
         state.grouponNum = state.goodsInfo.activity.rules.team_num;
         state.grouponNum = state.goodsInfo.activity.rules.team_num;
       }
       }
       state.goodsSwiper = formatGoodsSwiper(state.goodsInfo.images);
       state.goodsSwiper = formatGoodsSwiper(state.goodsInfo.images);

+ 6 - 9
sheep/components/s-select-groupon-sku/s-select-groupon-sku.vue

@@ -49,7 +49,7 @@
                 class="ss-reset-button spec-btn"
                 class="ss-reset-button spec-btn"
                 :class="[
                 :class="[
                   {
                   {
-                    'checked-btn': state.grouponNum == ladder,
+                    'checked-btn': grouponNum == ladder,
                   },
                   },
                 ]"
                 ]"
                 @tap="onSelectLadder(ladder)"
                 @tap="onSelectLadder(ladder)"
@@ -97,7 +97,7 @@
           <view class="ss-flex">
           <view class="ss-flex">
             <button class="ss-reset-button origin-price-btn ss-flex-col">
             <button class="ss-reset-button origin-price-btn ss-flex-col">
               <view class="btn-title">{{
               <view class="btn-title">{{
-                state.grouponNum === 0 ? '阶梯团' : state.grouponNum + '人团'
+                grouponNum === 0 ? '阶梯团' : grouponNum + '人团'
               }}</view>
               }}</view>
             </button>
             </button>
             <button class="ss-reset-button btn-tox ss-flex-col" @tap="onBuy">
             <button class="ss-reset-button btn-tox ss-flex-col" @tap="onBuy">
@@ -184,11 +184,9 @@
   // 规格价格
   // 规格价格
   const goodsPrice = computed(() => {
   const goodsPrice = computed(() => {
     if (isEmpty(state.selectedSkuPrice)) {
     if (isEmpty(state.selectedSkuPrice)) {
-      console.log(222);
       return formatPrice(props.goodsInfo.price);
       return formatPrice(props.goodsInfo.price);
     }
     }
-    if (state.grouponNum === 0 && activityType === 'groupon_ladder') {
-      console.log(1111);
+    if (props.grouponNum === 0 && activityType === 'groupon_ladder') {
       return formatPrice(props.goodsInfo.price);
       return formatPrice(props.goodsInfo.price);
     }
     }
 
 
@@ -208,7 +206,7 @@
       return formatPrice(props.goodsInfo.price);
       return formatPrice(props.goodsInfo.price);
     }
     }
 
 
-    if (state.grouponNum === 0 && activityType === 'groupon_ladder') {
+    if (props.grouponNum === 0 && activityType === 'groupon_ladder') {
       return formatPrice(props.goodsInfo.price);
       return formatPrice(props.goodsInfo.price);
     }
     }
 
 
@@ -223,7 +221,7 @@
 
 
   // 获取阶梯价
   // 获取阶梯价
   function getSkuPriceByLadder() {
   function getSkuPriceByLadder() {
-    return state.selectedSkuPrice.ladders.find((item) => item.ladder == state.grouponNum);
+    return state.selectedSkuPrice.ladders.find((item) => item.ladder == props.grouponNum);
   }
   }
 
 
   watch(
   watch(
@@ -359,14 +357,13 @@
 
 
   // 选择阶梯拼团人数
   // 选择阶梯拼团人数
   function onSelectLadder(ladder) {
   function onSelectLadder(ladder) {
-    state.grouponNum = ladder;
     emits('ladder', ladder);
     emits('ladder', ladder);
   }
   }
 
 
   // 选择规格
   // 选择规格
   function onSelectSku(pid, skuId) {
   function onSelectSku(pid, skuId) {
     // 清空已选择
     // 清空已选择
-    if (activityType === 'groupon_ladder' && state.grouponNum == 0) {
+    if (activityType === 'groupon_ladder' && props.grouponNum == 0) {
       sheep.$helper.toast('请选择拼团人数');
       sheep.$helper.toast('请选择拼团人数');
       return;
       return;
     }
     }