|
|
|
@ -1,15 +1,15 @@ |
|
|
|
<script setup> |
|
|
|
import { onReady } from "@dcloudio/uni-app"; |
|
|
|
import { computed, getCurrentInstance, ref, watch } from "vue"; |
|
|
|
import { computed, getCurrentInstance, ref } from "vue"; |
|
|
|
import { useRect } from "@/libs/utils"; |
|
|
|
import useStore from "@/store"; |
|
|
|
|
|
|
|
const props = defineProps({ |
|
|
|
tabIndex: String | Number, |
|
|
|
cartCount: { |
|
|
|
default: 0, |
|
|
|
type: Number, |
|
|
|
}, |
|
|
|
// cartCount: { |
|
|
|
// default: 0, |
|
|
|
// type: Number, |
|
|
|
// }, |
|
|
|
}); |
|
|
|
|
|
|
|
const store = useStore(); |
|
|
|
@ -30,13 +30,8 @@ const activeColor = "#06CA64"; |
|
|
|
/** |
|
|
|
* 购物车数量 |
|
|
|
*/ |
|
|
|
// const cartCount = computed(() => { |
|
|
|
// return store.cartList.reduce((acc, cur) => acc + cur.quantity, 0); |
|
|
|
// }); |
|
|
|
const cartCount = ref(0); |
|
|
|
|
|
|
|
watch(() => store.cartList, (value) => { |
|
|
|
cartCount.value = value.reduce((acc, cur) => acc + cur.quantity, 0); |
|
|
|
const cartCount = computed(() => { |
|
|
|
return store.cartList.reduce((acc, cur) => acc + cur.quantity, 0); |
|
|
|
}); |
|
|
|
|
|
|
|
/** |
|
|
|
@ -121,10 +116,10 @@ onReady(() => { |
|
|
|
</view> |
|
|
|
|
|
|
|
<template v-if="index === 3"> |
|
|
|
<view v-if="props.cartCount !== 0" class="badge"> |
|
|
|
<!-- <view v-if="props.cartCount !== 0" class="badge"> |
|
|
|
{{ props.cartCount }} |
|
|
|
</view> |
|
|
|
<view v-else-if="cartCount !== 0" class="badge"> |
|
|
|
</view> --> |
|
|
|
<view v-if="cartCount !== 0" class="badge"> |
|
|
|
{{ cartCount }} |
|
|
|
</view> |
|
|
|
</template> |
|
|
|
|