From be617c0e3435b69ebf9e3cda446e9f3b3be7c42a Mon Sep 17 00:00:00 2001 From: dy-hu Date: Fri, 21 Jun 2024 15:15:44 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E5=9F=8EPC=E7=AB=AF=E5=A4=9A=E7=BB=84?= =?UTF-8?q?=E8=A7=84=E6=A0=BC=E5=88=87=E6=8D=A2=E5=BA=93=E5=AD=98=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E5=BC=82=E5=B8=B8=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/product/productDetail.vue | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/views/product/productDetail.vue b/src/views/product/productDetail.vue index 8cc6173..5707d3e 100644 --- a/src/views/product/productDetail.vue +++ b/src/views/product/productDetail.vue @@ -807,6 +807,8 @@ export default { }, // 选择规格sku selectSku (o, list) { + console.log('o-->', o) + console.log('list-->', list) const temp = this.productDetailData.names this.productNumber = 1 if (list.values.length > 1) { @@ -826,9 +828,10 @@ export default { } }) }) + let select = selectOption.toString() for (let key in this.skuMap) { - if (key === select) { + if (this.isEqual(key, select)) { this.currentProductData = this.skuMap[key] this.productOption = this.skuMap[key] this.ifEnable = this.skuMap[key].ifEnable @@ -845,6 +848,27 @@ export default { } } }, + + //有逗号分隔的字符串,不分先后顺序判断 + isEqual(a, b) { + let c = a.split(','), d = b.split(',') + if (c.length != d.length) { + return false + } + for (let i = 0; i < c.length; i++) { + let isMatch = false + for (let j = 0; j < d.length; j++) { + if (c[i] == d[j]) { + isMatch = true + break + } + } + if (!isMatch) { + return false + } + } + return true + }, // 获取skuId // getSkuId () { // const temp = this.productOption