Browse Source

商品详情:默认选中商品规格

Xiao_123 4 months ago
parent
commit
0f94fd484b
1 changed files with 9 additions and 2 deletions
  1. 9 2
      src/views/mall/components/details/s-select-sku.vue

+ 9 - 2
src/views/mall/components/details/s-select-sku.vue

@@ -16,7 +16,7 @@
           size="small"
           label
           density="comfortable"
-          color="primary"
+          color="grey"
           variant="outlined"
           :disabled="value.disabled === true"
           @click="onSelectSku(property.id, value.id)"
@@ -72,6 +72,7 @@ const props = defineProps({
   });
 
   const propertyList = convertProductPropertyList(props.goodsInfo.skus);
+
   // SKU 列表
   const skuList = computed(() => {
     let skuPrices = props.goodsInfo.skus;
@@ -263,7 +264,13 @@ const props = defineProps({
   }
 
   changeDisabled(false);
-  // TODO 芋艿:待讨论的优化点:1)单规格,要不要默认选中;2)默认要不要选中第一个规格
+
+  // 默认选中第一个规格
+  if (propertyList && propertyList.length) {
+    propertyList.forEach((e) => {
+      if (e.values && e.values.length) onSelectSku(e.id, e.values[0].id)
+    })
+  }
 </script>
 
 <style lang="scss" scoped>