From 9870970d28d44d2f2b745d19eed54a0bf887e613 Mon Sep 17 00:00:00 2001 From: linxi Date: Wed, 30 Jul 2025 14:54:47 +0800 Subject: [PATCH] =?UTF-8?q?Fix=EF=BC=9A3880=20=E3=80=90=E5=95=86=E5=9F=8E?= =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E3=80=91=E6=90=9C=E7=B4=A2=E7=95=8C?= =?UTF-8?q?=E9=9D=A2-=E5=A2=9E=E5=8A=A0=E5=95=86=E5=93=81=E5=88=B0?= =?UTF-8?q?=E8=B4=AD=E7=89=A9=E8=BD=A6=EF=BC=8C=E7=BA=A2=E7=82=B9=E6=8F=90?= =?UTF-8?q?=E7=A4=BA=E6=9C=AA=E5=8F=8A=E6=97=B6=E5=90=8C=E6=AD=A5=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E6=95=B0=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mixins/goCartMixins.js | 16 ++++++++++++++-- pages/shop/GoodsList/index.vue | 13 +------------ 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/mixins/goCartMixins.js b/mixins/goCartMixins.js index 2bc136f..d41ebe0 100644 --- a/mixins/goCartMixins.js +++ b/mixins/goCartMixins.js @@ -33,10 +33,22 @@ export default { unique: '' } }, - cart_num: 1 + cart_num: 1, + CartCount: 0, } }, methods: { + // 获取购物车数量 + getCartCount () { + const isLogin = this.isLogin + if (isLogin) { + getCartCount({ + numType: 0 + }).then(res => { + this.CartCount = res.data.count + }) + } + }, getSkuActiveStatus(selectedSku) { getProductSkuBySelected({ id: this.id, selectedSku }).then(res => { const { success, data } = res @@ -100,7 +112,7 @@ export default { const onlyOne = Object.keys(data.productValue).length === 1 if(onlyOne) { - this.handleOk() + this.handleOk(this.getCartCount()) return } this.attr.cartAttr = !this.isOpen ? true : false diff --git a/pages/shop/GoodsList/index.vue b/pages/shop/GoodsList/index.vue index 8a55008..30308fc 100644 --- a/pages/shop/GoodsList/index.vue +++ b/pages/shop/GoodsList/index.vue @@ -201,7 +201,6 @@ export default { mixins: [goCartMixin], data () { return { - CartCount: 0, webUrl: this.$VUE_APP_RESOURCES_URL, list: [], query: { @@ -232,17 +231,7 @@ export default { !this.loading && this.getList() }, methods: { - // 获取购物车数量 - getCartCount () { - const isLogin = this.isLogin - if (isLogin) { - getCartCount({ - numType: 0 - }).then(res => { - this.CartCount = res.data.count - }) - } - }, + goShoppingCart() { this.$yrouter.switchTab('/pages/cart') },