From 523b8a3e7ca4fe8fe9837e8dab89f33cf8c6d25f Mon Sep 17 00:00:00 2001 From: pushuo Date: Thu, 8 Jun 2023 07:48:00 +0000 Subject: [PATCH] =?UTF-8?q?!122=20When=20entering=20the=20product=20detail?= =?UTF-8?q?s=20for=20the=20first=20time,=20only=20the=20SPU=20image=20will?= =?UTF-8?q?=20be=20displayed=20*=20When=20entering=20the=20product=20detai?= =?UTF-8?q?ls=20for=20the=20first=20time,=20only=20the=20SPU=20ima?= =?UTF-8?q?=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- themes/default/product.blade.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/themes/default/product.blade.php b/themes/default/product.blade.php index 0f1511cf..b3ef84e7 100644 --- a/themes/default/product.blade.php +++ b/themes/default/product.blade.php @@ -261,9 +261,6 @@ } }, - computed: { - }, - beforeMount () { const skus = JSON.parse(JSON.stringify(this.source.skus)); const skuDefault = skus.find(e => e.is_default) @@ -279,7 +276,7 @@ }) this.checkedVariants() - this.getSelectedSku(); + this.getSelectedSku(false); this.updateSelectedVariantsStatus() } else { // 如果没有默认的sku,则取第一个sku的第一个变量的第一个值 @@ -307,12 +304,17 @@ }) }, - getSelectedSku() { + getSelectedSku(reload = true) { // 通过 selectedVariantsIndex 的值比对 skus 的 variables const sku = this.source.skus.find(sku => sku.variants.toString() == this.selectedVariantsIndex.toString()) - const spuImages = @json($product['images'] ?? []); - this.images = [...sku.images, ...spuImages] + this.images = @json($product['images'] ?? []) + + if (reload) { + this.images.unshift(...sku.images) + } + this.product = sku; + if (swiperMobile) { swiperMobile.slideTo(0, 0, false) }