From 16b6a37074a984425d4e66647bcf9bc8c88cd376 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Thu, 8 Jun 2023 00:06:16 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E8=AE=A2=E5=8D=95=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E3=80=91=201.=20=E4=BF=AE=E5=A4=8D=E5=BE=AE=E4=BF=A1=E5=B0=8F?= =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E7=9A=84=E5=85=BC=E5=AE=B9=E6=80=A7=EF=BC=8C?= =?UTF-8?q?=E4=B8=BB=E8=A6=81=20productWindow=20=E5=AD=90=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E4=B8=8D=E5=85=81=E8=AE=B8=E4=BF=AE=E6=94=B9=20props?= =?UTF-8?q?=20=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/productWindow/index.vue | 26 +++++++++++++------------- pages/goods_details/index.vue | 14 +++++++++++++- 2 files changed, 26 insertions(+), 14 deletions(-) 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); + }, /** * 领取完毕移除当前页面领取过的优惠券展示 */