From a871ea7a5fce528e5de4fe7af9facae6ab2e9d14 Mon Sep 17 00:00:00 2001 From: taozhengyang Date: Sun, 25 May 2025 18:22:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93=E9=9B=AA=E8=8A=B1?= =?UTF-8?q?=20id=EF=BC=8C=E5=AF=BC=E8=87=B4=E7=9A=84=E5=95=86=E5=93=81?= =?UTF-8?q?=E8=A7=84=E6=A0=BC=E6=97=A0=E6=B3=95=E9=80=89=E6=8B=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../s-select-groupon-sku.vue | 16 ++++++++-------- .../s-select-seckill-sku.vue | 16 ++++++++-------- sheep/components/s-select-sku/s-select-sku.vue | 16 ++++++++-------- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/sheep/components/s-select-groupon-sku/s-select-groupon-sku.vue b/sheep/components/s-select-groupon-sku/s-select-groupon-sku.vue index 1325ddc2..9a1090da 100644 --- a/sheep/components/s-select-groupon-sku/s-select-groupon-sku.vue +++ b/sheep/components/s-select-groupon-sku/s-select-groupon-sku.vue @@ -133,7 +133,7 @@ }); const state = reactive({ selectedSku: {}, // 选中的 SKU - currentPropertyArray: [], // 当前选中的属性,实际是个 Map。key 是 property 编号,value 是 value 编号 + currentPropertyArray: {}, // 当前选中的属性,实际是个 Map。key 是 property 编号,value 是 value 编号 grouponNum: props.grouponNum, }); @@ -212,7 +212,7 @@ noChooseValueIds.splice(index, 1); } else { // 循环去除当前已选择的 value 属性值 id - state.currentPropertyArray.forEach((currentPropertyId) => { + Object.entries(state.currentPropertyArray).forEach(([propertyId, currentPropertyId]) => { if (currentPropertyId.toString() !== '') { return; } @@ -229,8 +229,8 @@ let choosePropertyIds = []; if (!isChecked) { // 当前已选择的 property - state.currentPropertyArray.forEach((currentPropertyId, currentValueId) => { - if (currentPropertyId !== '') { + Object.entries(state.currentPropertyArray).forEach(([propertyId, currentValueId]) => { + if (currentValueId !== '') { // currentPropertyId 为空是反选 填充的 choosePropertyIds.push(currentValueId); } @@ -261,9 +261,9 @@ continue; } let isOk = true; - state.currentPropertyArray.forEach((propertyId) => { - // propertyId 不为空,并且,这个 条 sku 没有被选中,则排除 - if (propertyId.toString() !== '' && sku.value_id_array.indexOf(propertyId) < 0) { + Object.entries(state.currentPropertyArray).forEach(([propertyId, valueId]) => { + // valueId 不为空,并且,这个 条 sku 没有被选中,则排除 + if (valueId.toString() !== '' && sku.value_id_array.indexOf(valueId) < 0) { isOk = false; } }); @@ -292,7 +292,7 @@ // 选中的 property 大类 let choosePropertyId = []; - state.currentPropertyArray.forEach((currentPropertyId) => { + Object.entries(state.currentPropertyArray).forEach(([propertyId, currentPropertyId]) => { if (currentPropertyId !== '') { // currentPropertyId 为空是反选 填充的 choosePropertyId.push(currentPropertyId); diff --git a/sheep/components/s-select-seckill-sku/s-select-seckill-sku.vue b/sheep/components/s-select-seckill-sku/s-select-seckill-sku.vue index a73342ad..ba6f7bfa 100644 --- a/sheep/components/s-select-seckill-sku/s-select-seckill-sku.vue +++ b/sheep/components/s-select-seckill-sku/s-select-seckill-sku.vue @@ -126,7 +126,7 @@ const state = reactive({ goodsInfo: computed(() => props.modelValue), selectedSku: {}, - currentPropertyArray: [], + currentPropertyArray: {}, }); const getShowPriceText = computed(() => { let priceText = `¥${fen2yuan(state.goodsInfo.price)}`; @@ -209,7 +209,7 @@ noChooseValueIds.splice(index, 1); } else { // 循环去除当前已选择的 value 属性值 id - state.currentPropertyArray.forEach((currentPropertyId) => { + Object.entries(state.currentPropertyArray).forEach(([propertyId, currentPropertyId]) => { if (currentPropertyId.toString() !== '') { return; } @@ -226,8 +226,8 @@ let choosePropertyIds = []; if (!isChecked) { // 当前已选择的 property - state.currentPropertyArray.forEach((currentPropertyId, currentValueId) => { - if (currentPropertyId !== '') { + Object.entries(state.currentPropertyArray).forEach(([propertyId, currentValueId]) => { + if (currentValueId !== '') { // currentPropertyId 为空是反选 填充的 choosePropertyIds.push(currentValueId); } @@ -258,9 +258,9 @@ continue; } let isOk = true; - state.currentPropertyArray.forEach((propertyId) => { - // propertyId 不为空,并且,这个 条 sku 没有被选中,则排除 - if (propertyId.toString() !== '' && sku.value_id_array.indexOf(propertyId) < 0) { + Object.entries(state.currentPropertyArray).forEach(([propertyId, valueId]) => { + // valueId 不为空,并且,这个 条 sku 没有被选中,则排除 + if (valueId.toString() !== '' && sku.value_id_array.indexOf(valueId) < 0) { isOk = false; } }); @@ -289,7 +289,7 @@ // 选中的 property 大类 let choosePropertyId = []; - state.currentPropertyArray.forEach((currentPropertyId) => { + Object.entries(state.currentPropertyArray).forEach(([propertyId, currentPropertyId]) => { if (currentPropertyId !== '') { // currentPropertyId 为空是反选 填充的 choosePropertyId.push(currentPropertyId); diff --git a/sheep/components/s-select-sku/s-select-sku.vue b/sheep/components/s-select-sku/s-select-sku.vue index 23b1b43a..7920a90e 100644 --- a/sheep/components/s-select-sku/s-select-sku.vue +++ b/sheep/components/s-select-sku/s-select-sku.vue @@ -111,7 +111,7 @@ const state = reactive({ selectedSku: {}, // 选中的 SKU - currentPropertyArray: [], // 当前选中的属性,实际是个 Map。key 是 property 编号,value 是 value 编号 + currentPropertyArray: {}, // 当前选中的属性,实际是个 Map。key 是 property 编号,value 是 value 编号 }); const propertyList = convertProductPropertyList(props.goodsInfo.skus); @@ -202,7 +202,7 @@ noChooseValueIds.splice(index, 1); } else { // 循环去除当前已选择的 value 属性值 id - state.currentPropertyArray.forEach((currentPropertyId) => { + Object.entries(state.currentPropertyArray).forEach(([propertyId, currentPropertyId]) => { if (currentPropertyId.toString() !== '') { return; } @@ -219,8 +219,8 @@ let choosePropertyIds = []; if (!isChecked) { // 当前已选择的 property - state.currentPropertyArray.forEach((currentPropertyId, currentValueId) => { - if (currentPropertyId !== '') { + Object.entries(state.currentPropertyArray).forEach(([propertyId, currentValueId]) => { + if (currentValueId !== '') { // currentPropertyId 为空是反选 填充的 choosePropertyIds.push(currentValueId); } @@ -251,9 +251,9 @@ continue; } let isOk = true; - state.currentPropertyArray.forEach((propertyId) => { - // propertyId 不为空,并且,这个 条 sku 没有被选中,则排除 - if (propertyId.toString() !== '' && sku.value_id_array.indexOf(propertyId) < 0) { + Object.entries(state.currentPropertyArray).forEach(([propertyId, valueId]) => { + // valueId 不为空,并且,这个 条 sku 没有被选中,则排除 + if (valueId.toString() !== '' && sku.value_id_array.indexOf(valueId) < 0) { isOk = false; } }); @@ -282,7 +282,7 @@ // 选中的 property 大类 let choosePropertyId = []; - state.currentPropertyArray.forEach((currentPropertyId) => { + Object.entries(state.currentPropertyArray).forEach(([propertyId, currentPropertyId]) => { if (currentPropertyId !== '') { // currentPropertyId 为空是反选 填充的 choosePropertyId.push(currentPropertyId); -- Gitee