From 7f5b1ad45c155efc2421d47a5a2c163049f33439 Mon Sep 17 00:00:00 2001 From: modendeveloper Date: Sun, 26 Jan 2025 20:23:28 +0800 Subject: [PATCH] =?UTF-8?q?Fix=EF=BC=9A3116=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=E5=85=A8=E5=9B=BD=E7=89=B9?= =?UTF-8?q?=E4=BA=A7=EF=BC=8C=E6=90=9C=E7=B4=A2=E9=A1=B5=E9=9D=A2=EF=BC=8C?= =?UTF-8?q?=E5=8F=B3=E4=B8=8A=E8=A7=92=E9=9C=80=E8=A6=81=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E8=B4=AD=E7=89=A9=E8=BD=A6=E6=8C=89=E9=92=AE=EF=BC=8C=E5=8F=B3?= =?UTF-8?q?=E4=B8=8A=E8=A7=92=E7=BA=A2=E7=82=B9=E6=98=BE=E7=A4=BA=E5=BD=93?= =?UTF-8?q?=E5=89=8D=E8=B4=AD=E7=89=A9=E8=BD=A6=E5=95=86=E5=93=81=E6=95=B0?= =?UTF-8?q?=EF=BC=8C=E7=82=B9=E5=87=BB=E8=BF=9B=E5=85=A5=E8=B4=AD=E7=89=A9?= =?UTF-8?q?=E8=BD=A6=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/shop/GoodsList/index.vue | 42 +++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/pages/shop/GoodsList/index.vue b/pages/shop/GoodsList/index.vue index e5a0226..2c5856c 100644 --- a/pages/shop/GoodsList/index.vue +++ b/pages/shop/GoodsList/index.vue @@ -16,6 +16,11 @@ /> + + + {{ CartCount > 99 ? '99+' : CartCount }} + + @@ -182,6 +187,9 @@ import NP from 'number-precision' import NoGoodData from '@/components/good/NoData' import Recommend from '@/components/Recommend' import goCartMixin from '@/mixins/goCartMixins' +import { + getCartCount, +} from '@/api/store' export default { name: 'GoodsList', components: { @@ -192,6 +200,7 @@ export default { mixins: [goCartMixin], data () { return { + CartCount: 0, webUrl: this.$VUE_APP_RESOURCES_URL, list: [], query: { @@ -211,16 +220,31 @@ export default { showSearchTypeLayer: false } }, - computed: mapGetters(['userInfo']), + computed: mapGetters(['isLogin', 'location', 'userInfo']), onLoad(e) { const { s = '' } = this.$yroute.query this.query.keyword = s this.getList() + this.getCartCount() }, onReachBottom() { !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') + }, toggleSearchType(value) { this.showSearchTypeLayer = value }, @@ -311,6 +335,22 @@ export default {