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