Browse Source

非物流商品不显示数量。默认只购买一份

lifanagju_citu 4 months ago
parent
commit
d8c944e113

+ 15 - 5
src/components/FormUI/su-number-box/su-number-box.vue

@@ -1,12 +1,14 @@
 <template>
   <view class="d-flex align-center">
     <v-btn
+      v-if="showMinus"
       icon="mdi-minus" 
       size="x-small" 
       :disabled="inputValue <= min || disabled" 
       @click="_calcValue('minus')"
     ></v-btn>
     <input
+      v-if="showNumber"
       :disabled="disabled"
       @focus="_onFocus"
       @blur="_onBlur"
@@ -16,12 +18,12 @@
       :style="{ color }"
     />
     <v-btn
+      v-if="showPlus"
       icon="mdi-plus" 
       size="x-small" 
       :disabled="inputValue >= max || disabled" 
       @click="_calcValue('plus')"
     ></v-btn>
-    <div class="ml-3" style="color: #b7b7b7; font-size: 14px;">库存:{{ totalStock }}</div>
   </view>
 </template>
 <script>
@@ -61,10 +63,6 @@
         type: Number,
         default: 100,
       },
-      totalStock: {
-        type: Number,
-        default: 0,
-      },
       step: {
         type: Number,
         default: 1,
@@ -81,6 +79,18 @@
         type: Boolean,
         default: false,
       },
+      showPlus: {
+        type: Boolean,
+        default: true,
+      },
+      showMinus: {
+        type: Boolean,
+        default: true,
+      },
+      showNumber: {
+        type: Boolean,
+        default: true,
+      },
       activity: {
         type: String,
         default: 'none',

+ 3 - 0
src/views/mall/components/details.vue

@@ -53,6 +53,7 @@
           <selectSku
             v-if="showSelectSku"
             class="mb-7"
+            :goodsType="goodsType"
             :goodsInfo="state.goodsInfo"
             @change="onSkuChange"
             @buy="onBuy"
@@ -113,6 +114,7 @@ const carouselHover = ref(false)
 const showSelectedSkuImg = ref(false)
 
 const showPrize = ref(false)
+const goodsType = ref(0)
 const showActivePrices = ref(false) // 下单送房券
 const lotteryId = ref('')
 // 获取商品详情
@@ -124,6 +126,7 @@ const getData = async () => {
   obj.sliderPicUrls = obj.sliderPicUrls || []
   state.skeletonLoading = false;
   state.goodsInfo = obj
+  goodsType.value = obj?.type ? obj.type-0 : 0
   showSelectSku.value = true
 
   // 查询当前商品是否参与抽奖活动

+ 24 - 17
src/views/mall/components/details/s-select-sku.vue

@@ -24,21 +24,24 @@
         </v-chip>
       </span>
     </div>
-    <!-- 购买数量 -->
+    <!-- 购买数量- 库存 -->
     <div class="modal-content">
-      <div>
-        <div class="buyCount mb-10">
+      <!-- 只展示库存 -->
+      <div v-if="props.goodsType === 99" class="parameterColor mb-10"><span class="l-s-10">库存</span>:{{ totalStock }}</div>
+      <div v-else class="d-flex align-center mb-10">
+        <div class="buyCount mr-3">
           <span class="parameterColor"><span class="l-s-10">数量</span>:</span>
           <su-number-box
             :min="1"
             :max="state.selectedSku.stock"
-            :totalStock="totalStock"
             :step="1"
             ref="selectSkuRef"
             v-model="state.selectedSku.goods_num"
             @change="onNumberChange($event)"
           />
         </div>
+        <!-- 数量可加减 库存 -->
+        <span style="color: #b7b7b7; font-size: 14px;">库存:{{ totalStock }}</span>
       </div>
     </div>
     <!-- 操作区 -->
@@ -50,19 +53,23 @@
 </template>
 
 <script setup>
-defineOptions({name: 'wares-s-select-sku'})
-import Snackbar from '@/plugins/snackbar'
-import suNumberBox from '@/components/FormUI/su-number-box/su-number-box.vue'
-import { computed, reactive, watch, ref } from 'vue'
-import { convertProductPropertyList } from '@/views/mall/utils'
-
-const emits = defineEmits(['change', 'addCart', 'buy', 'close']);
-const props = defineProps({
-  goodsInfo: {
-    type: Object,
-    default() {},
-  },
-});
+  defineOptions({name: 'wares-s-select-sku'})
+  import Snackbar from '@/plugins/snackbar'
+  import suNumberBox from '@/components/FormUI/su-number-box/su-number-box.vue'
+  import { computed, reactive, watch, ref } from 'vue'
+  import { convertProductPropertyList } from '@/views/mall/utils'
+
+  const emits = defineEmits(['change', 'addCart', 'buy', 'close']);
+  const props = defineProps({
+    goodsInfo: {
+      type: Object,
+      default() {},
+    },
+    goodsType: {
+      type: Number,
+      default: 0,
+    },
+  });
 
   const totalStock = ref(props.goodsInfo?.stock-0 || 0)
   const state = reactive({