Explorar o código

fix:规格弹框,手动输入数量无法改变数量问题修复

kele %!s(int64=2) %!d(string=hai) anos
pai
achega
9b89863c96

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

@@ -87,6 +87,7 @@
               :max="state.selectedSkuPrice.stock"
               :max="state.selectedSkuPrice.stock"
               :step="1"
               :step="1"
               v-model="state.selectedSkuPrice.goods_num"
               v-model="state.selectedSkuPrice.goods_num"
+              @change="onNumberChange($event)"
               activity="groupon"
               activity="groupon"
             ></su-number-box>
             ></su-number-box>
           </view>
           </view>
@@ -96,9 +97,7 @@
         <view class="buy-box ss-flex ss-col-center ss-flex ss-col-center ss-row-center">
         <view class="buy-box ss-flex ss-col-center ss-flex ss-col-center ss-row-center">
           <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">{{
-                grouponNum === 0 ? '阶梯团' : grouponNum + '人团'
-              }}</view>
+              <view class="btn-title">{{ grouponNum === 0 ? '阶梯团' : grouponNum + '人团' }}</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">
               <view class="btn-price">
               <view class="btn-price">
@@ -160,6 +159,13 @@
     currentSkuArray: [],
     currentSkuArray: [],
     grouponNum: props.grouponNum,
     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) {
   if (!props.goodsInfo.is_sku) {
     state.selectedSkuPrice = props.goodsInfo.sku_prices[0];
     state.selectedSkuPrice = props.goodsInfo.sku_prices[0];

+ 7 - 0
sheep/components/s-select-seckill-sku/s-select-seckill-sku.vue

@@ -60,6 +60,7 @@
               :max="state.selectedSkuPrice.stock"
               :max="state.selectedSkuPrice.stock"
               :step="1"
               :step="1"
               v-model="state.selectedSkuPrice.goods_num"
               v-model="state.selectedSkuPrice.goods_num"
+              @change="onNumberChange($event)"
               activity="seckill"
               activity="seckill"
             ></su-number-box>
             ></su-number-box>
           </view>
           </view>
@@ -151,6 +152,12 @@
       sheep.$helper.toast('请选择规格');
       sheep.$helper.toast('请选择规格');
     }
     }
   };
   };
+  //输入框改变数量
+  function onNumberChange(e) {
+	if (e === 0) return;
+    if (state.selectedSkuPrice.goods_num === e) return;
+    state.selectedSkuPrice.goods_num = e;
+  }
   // 改变禁用状态
   // 改变禁用状态
   const changeDisabled = (isChecked = false, pid = 0, skuId = 0) => {
   const changeDisabled = (isChecked = false, pid = 0, skuId = 0) => {
     let newPrice = []; // 所有可以选择的 skuPrice
     let newPrice = []; // 所有可以选择的 skuPrice

+ 21 - 5
sheep/components/s-select-sku/s-select-sku.vue

@@ -21,13 +21,14 @@
                 <view
                 <view
                   v-if="goodsPrice.price > 0 && goodsPrice.score > 0"
                   v-if="goodsPrice.price > 0 && goodsPrice.score > 0"
                   class="score-text ss-m-l-4"
                   class="score-text ss-m-l-4"
-                  >+</view
-                >
+                  >+
+                </view>
                 <image
                 <image
                   v-if="goodsPrice.score > 0"
                   v-if="goodsPrice.score > 0"
                   :src="sheep.$url.static('/static/img/shop/goods/score1.svg')"
                   :src="sheep.$url.static('/static/img/shop/goods/score1.svg')"
                   class="score-img"
                   class="score-img"
-                ></image>
+                >
+                </image>
                 <view v-if="goodsPrice.score > 0" class="score-text">
                 <view v-if="goodsPrice.score > 0" class="score-text">
                   {{ goodsPrice.score }}
                   {{ goodsPrice.score }}
                 </view>
                 </view>
@@ -75,6 +76,7 @@
               :max="state.selectedSkuPrice.stock"
               :max="state.selectedSkuPrice.stock"
               :step="1"
               :step="1"
               v-model="state.selectedSkuPrice.goods_num"
               v-model="state.selectedSkuPrice.goods_num"
+              @change="onNumberChange($event)"
             ></su-number-box>
             ></su-number-box>
           </view>
           </view>
         </scroll-view>
         </scroll-view>
@@ -123,7 +125,12 @@
     selectedSkuPrice: {},
     selectedSkuPrice: {},
     currentSkuArray: [],
     currentSkuArray: [],
   });
   });
-
+  //输入框改变数量
+  function onNumberChange(e) {
+    if (e === 0) return;
+    if (state.selectedSkuPrice.goods_num === e) return;
+    state.selectedSkuPrice.goods_num = e;
+  }
   // 默认单规格
   // 默认单规格
   if (!props.goodsInfo.is_sku) {
   if (!props.goodsInfo.is_sku) {
     state.selectedSkuPrice = props.goodsInfo.sku_prices[0];
     state.selectedSkuPrice = props.goodsInfo.sku_prices[0];
@@ -162,7 +169,10 @@
       price = state.selectedSkuPrice.price;
       price = state.selectedSkuPrice.price;
       score = state.selectedSkuPrice.score || 0;
       score = state.selectedSkuPrice.score || 0;
     }
     }
-    return { price, score };
+    return {
+      price,
+      score,
+    };
   });
   });
 
 
   function onAddCart() {
   function onAddCart() {
@@ -352,6 +362,7 @@
       background: linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
       background: linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
       color: #fff;
       color: #fff;
     }
     }
+
     .score-btn {
     .score-btn {
       width: 100%;
       width: 100%;
       margin: 0 20rpx;
       margin: 0 20rpx;
@@ -393,22 +404,26 @@
         font-weight: 500;
         font-weight: 500;
         line-height: 42rpx;
         line-height: 42rpx;
       }
       }
+
       .score-img {
       .score-img {
         width: 36rpx;
         width: 36rpx;
         height: 36rpx;
         height: 36rpx;
         margin: 0 4rpx;
         margin: 0 4rpx;
       }
       }
+
       .score-text {
       .score-text {
         font-size: 30rpx;
         font-size: 30rpx;
         font-weight: 500;
         font-weight: 500;
         color: $red;
         color: $red;
         font-family: OPPOSANS;
         font-family: OPPOSANS;
       }
       }
+
       .price-text {
       .price-text {
         font-size: 30rpx;
         font-size: 30rpx;
         font-weight: 500;
         font-weight: 500;
         color: $red;
         color: $red;
         font-family: OPPOSANS;
         font-family: OPPOSANS;
+
         &::before {
         &::before {
           content: '¥';
           content: '¥';
           font-size: 30rpx;
           font-size: 30rpx;
@@ -449,6 +464,7 @@
           margin-right: 10rpx;
           margin-right: 10rpx;
           margin-bottom: 10rpx;
           margin-bottom: 10rpx;
         }
         }
+
         .disabled-btn {
         .disabled-btn {
           font-weight: 400;
           font-weight: 400;
           color: #c6c6c6;
           color: #c6c6c6;