diff --git a/components/productWindow/index.vue b/components/productWindow/index.vue index 1c9c0761..e8a0b38a 100644 --- a/components/productWindow/index.vue +++ b/components/productWindow/index.vue @@ -16,17 +16,17 @@ 限量: {{ attr.productSelect.quota }} - + - + {{ property.name }} + v-for="(value, valueIndex) in property.values" :key="valueIndex" + @click="clickProperty(propertyIndex, valueIndex)"> {{ value.name }} @@ -64,7 +64,7 @@ 已售罄 - + @@ -111,9 +111,9 @@ // TODO 芋艿:【优化】方法名的处理;是否可去掉这个事件,统一处理 this.$emit('iptCartNum', this.attr.productSelect.cart_num); }, - closeAttr: function() { - this.attr.cartAttr = false - }, + close: function() { + this.$emit('close'); + }, CartNumDes: function() { // TODO 芋艿:【优化】方法名的处理;是否可去掉这个事件,统一处理 this.$emit('ChangeCartNum', false); @@ -125,14 +125,14 @@ /** * 选中某个规格属性 * - * @param indexw properties 的下标 - * @param indexn properties 的下标 + * @param propertyIndex properties 的下标 + * @param valueIndex values 的下标 */ - clickProperty: function(indexw, indexn) { - this.$set(this.attr.properties[indexw], 'index', this.attr.properties[indexw].values[indexn].name); + clickProperty: function(propertyIndex, valueIndex) { + this.$set(this.attr.properties[propertyIndex], 'index', this.attr.properties[propertyIndex].values[valueIndex].name); let newSkuKey = this.getCheckedValueNames().join(","); // TODO 芋艿:【优化】修改下 ChangeAttr 名字,改成 selectSku 更合适 - this.$emit("ChangeAttr", newSkuKey); + this.$emit("ChangeAttr", newSkuKey, propertyIndex, valueIndex); }, /** * 获取被选中属性值的数组 diff --git a/pages/goods_details/index.vue b/pages/goods_details/index.vue index b1d6bc5b..aeebde88 100644 --- a/pages/goods_details/index.vue +++ b/pages/goods_details/index.vue @@ -226,6 +226,7 @@ @ChangeAttr="ChangeAttr" @ChangeCartNum="ChangeCartNum" @iptCartNum="iptCartNum" + @close="closeAttr" /> @@ -676,8 +677,11 @@ * 属性变动赋值 * * @param newSkuKey 新的 skuKey + * @param propertyIndex properties 的下标 + * @param valueIndex values 的下标 */ - ChangeAttr: function(newSkuKey) { + ChangeAttr: function(newSkuKey, propertyIndex, valueIndex) { + // SKU let sku = this.skuMap[newSkuKey]; if (!sku) { return; @@ -687,8 +691,16 @@ this.$set(this.attr.productSelect, "price", sku.price); this.$set(this.attr.productSelect, "stock", sku.stock); this.$set(this.attr.productSelect, "cart_num", 1); + // SKU 关联属性 + this.$set(this.attr.properties[propertyIndex], 'index', this.attr.properties[propertyIndex].values[valueIndex].name); this.$set(this, "attrValue", newSkuKey); }, + /** + * 关闭 productWindow 弹窗 + */ + closeAttr: function () { + this.$set(this.attr, "cartAttr", false); + }, /** * 领取完毕移除当前页面领取过的优惠券展示 */