|
@@ -39,7 +39,8 @@ export default defineComponent({
|
|
|
detailMobileHtml: '',
|
|
|
loading: false,
|
|
|
addGoodsShow: false,
|
|
|
- selectGoodsItem: {}
|
|
|
+ selectGoodsItem: {},
|
|
|
+ cartCount: 0
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
@@ -98,6 +99,7 @@ export default defineComponent({
|
|
|
}
|
|
|
this.detailMobileHtml = result.product.detailMobileHtml
|
|
|
} catch {}
|
|
|
+ this.getCartCount()
|
|
|
},
|
|
|
methods: {
|
|
|
onPreview(index: number) {
|
|
@@ -149,6 +151,16 @@ export default defineComponent({
|
|
|
return Toast('请选择规格')
|
|
|
}
|
|
|
console.log(true)
|
|
|
+ },
|
|
|
+ async getCartCount(){
|
|
|
+ try{
|
|
|
+ let { code, data } = await request.get('/api-mall-portal/cart/list')
|
|
|
+ if (code === 200){
|
|
|
+ this.cartCount = data.length
|
|
|
+ }
|
|
|
+ }catch(err){
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
render() {
|
|
@@ -273,7 +285,11 @@ export default defineComponent({
|
|
|
this.$router.push('/cart')
|
|
|
}}
|
|
|
v-slots={{
|
|
|
- icon: () => <Icon name={iconShopCart} size={30} />
|
|
|
+ icon: () => (
|
|
|
+ <Badge content={this.cartCount} showZero={false}>
|
|
|
+ <Icon name={iconShopCart} size={30} />
|
|
|
+ </Badge>
|
|
|
+ )
|
|
|
}}
|
|
|
/>
|
|
|
<div class={styles.buyGroup}>
|
|
@@ -298,6 +314,7 @@ export default defineComponent({
|
|
|
round
|
|
|
onClose={() => {
|
|
|
this.addGoodsShow = false
|
|
|
+ this.getCartCount()
|
|
|
}}
|
|
|
>
|
|
|
<AddGoodsCart item={this.selectGoodsItem} defaultRadio={this.radio} />
|