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 {