瀏覽代碼

修改了没有sku规格报错的问题

liuguofeng 6 月之前
父節點
當前提交
57f41c114a
共有 1 個文件被更改,包括 13 次插入9 次删除
  1. 13 9
      pages/product/index.vue

+ 13 - 9
pages/product/index.vue

@@ -855,18 +855,22 @@
 			},
 			//specPopup关闭时重置数据
 			onSpecPopupClose(){
-				let colorSpecAttrList = this.productInfo.product_attr.find((spec) => spec.spec_id === 1).attr_list;
-				let sizeSpecAttrList = this.productInfo.product_attr.find((spec) => spec.spec_id === 2).attr_list;
+				
+				if(this.productInfo.product_attr.length){
+					
+					let colorSpecAttrList = this.productInfo.product_attr.find((spec) => spec.spec_id === 1).attr_list;
+					let sizeSpecAttrList = this.productInfo.product_attr.find((spec) => spec.spec_id === 2).attr_list;
+					for (let i in colorSpecAttrList) {
+						 colorSpecAttrList[i].active = 0;
+					}
+					// 恢复尺寸规格下属性的原始active状态
+					for (let i in sizeSpecAttrList) {
+						 sizeSpecAttrList[i].active = 0;
+					}	
+				}
 				//重置上一次规格全部选中
 				this.hasValidSpecSelected = false;
 				// 恢复颜色分类规格下属性的原始active状态
-				for (let i in colorSpecAttrList) {
-					 colorSpecAttrList[i].active = 0;
-				}
-				// 恢复尺寸规格下属性的原始active状态
-				for (let i in sizeSpecAttrList) {
-					 sizeSpecAttrList[i].active = 0;
-				}		
 				this.$refs.specPopup.close()
 			},
 			//只有一组sku默认规格是否已下架