diff --git a/sheep/components/s-select-sku/s-select-sku.vue b/sheep/components/s-select-sku/s-select-sku.vue index 7819b900..b3938054 100644 --- a/sheep/components/s-select-sku/s-select-sku.vue +++ b/sheep/components/s-select-sku/s-select-sku.vue @@ -4,7 +4,7 @@ - @@ -38,17 +38,17 @@ - + {{ sku1.name }} - @@ -56,7 +56,7 @@ 购买数量 + v-model="state.selectedSkuPrice.goods_num" @change="onNumberChange($event)" /> @@ -82,7 +82,8 @@ import sheep from '@/sheep'; import { formatStock, - formatPrice + formatPrice, + convertProductPropertyList } from '@/sheep/hooks/useGoods'; import { isEmpty @@ -108,27 +109,32 @@ selectedSkuPrice: {}, currentSkuArray: [], }); - //输入框改变数量 + // 输入框改变数量 function onNumberChange(e) { if (e === 0) return; if (state.selectedSkuPrice.goods_num === e) return; state.selectedSkuPrice.goods_num = e; } + // TODO 芋艿:去除单规格 // 默认单规格 - if (!props.goodsInfo.is_sku) { - state.selectedSkuPrice = props.goodsInfo.sku_prices[0]; - } + // if (!props.goodsInfo.is_sku) { + // state.selectedSkuPrice = props.goodsInfo.sku_prices[0]; + // } - const skuList = props.goodsInfo.skus; + const skuList = convertProductPropertyList(props.goodsInfo.skus); // 可选规格 const skuPrices = computed(() => { - let skuPrices = props.goodsInfo.sku_prices; - if (props.goodsInfo.is_sku) { - skuPrices.forEach((item) => { - item.goods_sku_id_arr = item.goods_sku_ids.split(','); - }); - } + let skuPrices = props.goodsInfo.skus; + // TODO 芋艿:去除单规格 + // if (props.goodsInfo.is_sku) { + // skuPrices.forEach((item) => { + // item.goods_sku_id_arr = item.goods_sku_ids.split(','); + // }); + // } + for (let price of skuPrices) { + price.goods_sku_id_arr = price.properties.map((item) => item.valueId).join(',') + } return skuPrices; }); @@ -143,7 +149,7 @@ ); const goodsPrice = computed(() => { - let price, score; + let price, score; if (isEmpty(state.selectedSkuPrice)) { price = props.goodsInfo.price[0]; score = props.goodsInfo.score || 0; @@ -182,7 +188,7 @@ } // 改变禁用状态 function changeDisabled(isChecked = false, pid = 0, skuId = 0) { - let newPrice = []; // 所有可以选择的 skuPrice + let newPrice = []; // 所有可以选择的 skuPrice if (isChecked) { // 选中规格 @@ -192,6 +198,7 @@ // this.goodsNum 不判断是否大于当前选择数量,在 uni-number-box 判断,并且 取 stock 和 goods_num 的小值 continue; } + console.log(price.goods_sku_id_arr, '=======') if (price.goods_sku_id_arr.indexOf(skuId.toString()) >= 0) { newPrice.push(price); } @@ -262,6 +269,7 @@ } // 当前所选规格下,获取所有有库存的 skuPrice function getCanUseSkuPrice() { + // debugger let newPrice = []; for (let price of skuPrices.value) { @@ -287,6 +295,7 @@ } // 选择规格 function onSelectSku(pid, skuId) { + // debugger // 清空已选择 let isChecked = true; // 选中 or 取消选中 if (state.currentSkuArray[pid] != undefined && state.currentSkuArray[pid] == skuId) { @@ -306,7 +315,7 @@ } }); - // 当前所选规格下,所有可以选择的 skuPric + // 当前所选规格下,所有可以选择的 skuPrice let newPrice = getCanUseSkuPrice(); // 判断所有规格大类是否选择完成 diff --git a/sheep/components/s-wallet-card/s-wallet-card.vue b/sheep/components/s-wallet-card/s-wallet-card.vue index 25d6c1c1..6f0f0163 100644 --- a/sheep/components/s-wallet-card/s-wallet-card.vue +++ b/sheep/components/s-wallet-card/s-wallet-card.vue @@ -1,5 +1,5 @@