From 55df50520a21c682ef23230a334f2301e9ed8c59 Mon Sep 17 00:00:00 2001 From: pushuo <229102104@qq.com> Date: Thu, 21 Jul 2022 10:40:12 +0800 Subject: [PATCH] wip --- public/build/beike/shop/default/css/app.css | 8 +++++- resources/beike/shop/default/css/product.scss | 12 ++++++++- themes/default/product.blade.php | 25 ++++++++++++++++--- 3 files changed, 39 insertions(+), 6 deletions(-) diff --git a/public/build/beike/shop/default/css/app.css b/public/build/beike/shop/default/css/app.css index 8da689a5..ddd8d39c 100644 --- a/public/build/beike/shop/default/css/app.css +++ b/public/build/beike/shop/default/css/app.css @@ -393,11 +393,17 @@ body.page-product .variables-wrap .variable-info > div { padding: 0.5rem; cursor: pointer; text-align: center; + font-weight: bold; transition: all 0.1s ease-in-out; } -body.page-product .variables-wrap .variable-info > div:hover, body.page-product .variables-wrap .variable-info > div.active { +body.page-product .variables-wrap .variable-info > div:hover, body.page-product .variables-wrap .variable-info > div.selected { border-color: #222; } +body.page-product .variables-wrap .variable-info > div:not(.selected).disabled { + border: 1px dashed #bfbfbf; + color: #999; + font-weight: initial; +} body.page-product .peoduct-info .rating-wrap { margin-bottom: 2rem; } diff --git a/resources/beike/shop/default/css/product.scss b/resources/beike/shop/default/css/product.scss index 3b6505a3..97790539 100644 --- a/resources/beike/shop/default/css/product.scss +++ b/resources/beike/shop/default/css/product.scss @@ -25,10 +25,20 @@ body.page-product { padding: 0.5rem; cursor: pointer; text-align: center; + font-weight: bold; + // border-radius: 2rem; transition: all .1s ease-in-out; - &:hover, &.active { + &:hover, &.selected { border-color: #222; } + + &:not(.selected) { + &.disabled { + border: 1px dashed #bfbfbf; + color: #999; + font-weight: initial; + } + } } } } diff --git a/themes/default/product.blade.php b/themes/default/product.blade.php index 18717149..24e7b9af 100644 --- a/themes/default/product.blade.php +++ b/themes/default/product.blade.php @@ -47,14 +47,14 @@
-
-

@{{ variable.name }}

+
+

@{{ variable.name }}

+ :class="[value.selected ? 'selected' : '', value.disabled ? 'disabled' : '']"> @{{ value.name }}
@@ -178,6 +178,7 @@ this.checkedVariants() this.getSelectedSku(); + this.updateSelectedVariantsStatus() } }, @@ -189,6 +190,7 @@ this.updateSelectedVariantsIndex(); this.getSelectedSku(); + this.updateSelectedVariantsStatus() }, // 把对应 selectedVariantsIndex 下标选中 variables -> values 的 selected 字段为 true @@ -224,7 +226,22 @@ }) }, - // 根据 skus 中 quantity 字段,对应到 variants 的 每种组合 variables 的 selected 字段 + updateSelectedVariantsStatus() { + // skus 里面 quantity 不为 0 的 sku.variants + const skus = this.source.skus.filter(sku => sku.quantity > 0).map(sku => sku.variants); + this.source.variables.forEach((variable, index) => { + variable.values.forEach((value, value_index) => { + const selectedVariantsIndex = this.selectedVariantsIndex.slice(0); + selectedVariantsIndex[index] = value_index; + const selectedSku = skus.find(sku => sku.toString() == selectedVariantsIndex.toString()); + if (selectedSku) { + value.disabled = false; + } else { + value.disabled = true; + } + }) + }); + }, } })