| | |
| | | <!-- Add shopping cart icon here --> |
| | | <div class="flex items-center gap-4" @click="goToCart"> |
| | | <el-badge :value="cartCount" :max="99" class="cart-badge"> |
| | | <el-button class="flex items-center" link > |
| | | <el-icon class="text-xl"><ShoppingCart /></el-icon> |
| | | <el-button class="flex items-center" link> |
| | | <el-icon class="text-lg" style="font-size: 20px;"><ShoppingCart /></el-icon> |
| | | </el-button> |
| | | </el-badge> |
| | | </div> |
| | |
| | | }; |
| | | |
| | | const linkClick = () => { |
| | | router.push('/select-selpara'); |
| | | if (userInfo.value.Token) { |
| | | router.push('/select-selpara'); |
| | | } else { |
| | | loginStore.logOut(); |
| | | router.replace({ |
| | | path: '/login', |
| | | query: { redirectPath: route.fullPath }, |
| | | }); |
| | | } |
| | | }; |
| | | |
| | | // 从 Pinia store 获取购物车数量 |
| | | const cartCount = computed(() => cartStore.cartItemCount); |
| | | |
| | | const goToCart = () => { |
| | | router.push('/cart'); |
| | | if (userInfo.value.Token) { |
| | | router.push('/cart'); |
| | | } else { |
| | | loginStore.logOut(); |
| | | router.replace({ |
| | | path: '/login', |
| | | query: { redirectPath: route.fullPath }, |
| | | }); |
| | | return |
| | | } |
| | | |
| | | }; |
| | | </script> |
| | | |