создаю телегу товаров
All checks were successful
Deploy / build (push) Successful in 47s

This commit is contained in:
alsaze 2025-10-01 16:35:25 +03:00
parent 83d2a56e52
commit bb195777c3
5 changed files with 69 additions and 27 deletions

View File

@ -5283,7 +5283,7 @@ export class Api<
method: "POST", method: "POST",
body: data, body: data,
secure: true, secure: true,
type: ContentType.UrlEncoded, type: ContentType.Json,
...params, ...params,
}), }),

View File

@ -42,10 +42,6 @@
@click="addToCartBtn()" @click="addToCartBtn()"
/> />
currentSize
<pre>
{{ currentSize }}
</pre>
<UAccordion :items="items" /> <UAccordion :items="items" />
</div> </div>
</template> </template>

View File

@ -8,10 +8,6 @@
> >
</NuxtLink> </NuxtLink>
<pre>
{{ variations }}
</pre>
<div> <div>
{{ productsData?.name }} {{ productsData?.name }}
@ -21,9 +17,8 @@
</div> </div>
<div class="cart-item__attributes"> <div class="cart-item__attributes">
{{ t(`colors.${color}`) }} <div>{{ t(`colors.${color}`) }} {{ t(`materials.${material}`) }}</div>
{{ t(`materials.${material}`) }} <div>{{ `размер ${size}` }}</div>
{{ `размер ${size}` }}
</div> </div>
<div> <div>
@ -67,7 +62,7 @@ const deleteItem = (item) => {
&__attributes { &__attributes {
display: flex; display: flex;
flex-direction: row; flex-direction: column;
justify-content: space-between; justify-content: space-between;
} }
} }

View File

@ -11,11 +11,18 @@
PAXTON PAXTON
</h1> </h1>
<Icon <div
name="lucide:shopping-cart" class="header__cart"
class="cursor-pointer mr20 w-6 h-6 text-gray-700"
@click="router.push(`/cart`)" @click="router.push(`/cart`)"
/> >
<Icon
name="lucide:shopping-cart"
class="cursor-pointer w-6 h-6 text-gray-700"
/>
<div v-if="cart?.line_items?.length" class="header__cart-count">
{{ cart.line_items.length }}
</div>
</div>
</div> </div>
</header> </header>
@ -33,6 +40,7 @@
<script setup lang="ts"> <script setup lang="ts">
const router = useRouter() const router = useRouter()
const { cart } = useCart()
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@ -45,7 +53,6 @@ const router = useRouter()
.container { .container {
--ui-container: 100%; --ui-container: 100%;
max-width: 100%; max-width: 100%;
margin: 0; margin: 0;
padding: 0; padding: 0;
} }
@ -67,16 +74,36 @@ const router = useRouter()
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
text-align: center; text-align: center;
padding: 0 16px;
} }
&__headline { &__headline {
display: flex;
align-items: center;
height: 100%;
font-size: 32px; font-size: 32px;
color: black; color: black;
cursor: pointer; cursor: pointer;
} }
&__cart {
position: relative;
display: inline-block;
}
&__cart-count {
cursor: pointer;
position: absolute;
top: -6px;
right: -6px;
background: red;
color: white;
font-size: 12px;
font-weight: bold;
border-radius: 50%;
width: 18px;
height: 18px;
display: flex;
align-items: center;
justify-content: center;
}
} }
.main { .main {

View File

@ -8,12 +8,14 @@
<CartItem :cart-item="cartItem" /> <CartItem :cart-item="cartItem" />
</div> </div>
</div> </div>
</div>
<div> <div class="cart__create-order">
<UButton @click="createOrder"> <div>{{ `Товары: ${cart?.line_items?.length}` }}</div>
Оформить заказ
</UButton> <UButton class="w-100 d-flex" @click="createOrder">
Перейти к оформлению
</UButton>
</div>
</div> </div>
</template> </template>
@ -24,19 +26,41 @@ const { cart } = useCart()
const { mutateAsync } = usePostOrdersCreate() const { mutateAsync } = usePostOrdersCreate()
const createOrder = () => { const createOrder = () => {
mutateAsync(cart) mutateAsync({ line_items: cart.value.line_items })
} }
</script> </script>
<style lang="scss"> <style lang="scss">
@use '~/assets/scss/utils' as *;
.cart { .cart {
margin-top: 120px;
margin-inline: auto;
max-width: 1200px;
display: flex; display: flex;
flex-direction: row; flex-direction: row;
justify-content: space-between; justify-content: space-between;
@include mobile {
margin-top: 20px;
flex-direction: column;
}
&__items { &__items {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
} }
&__create-order {
box-shadow: 1px 1px 8px 0 black;
border-radius: 10px;
padding: 10px;
max-width: 360px;
display: inline-flex;
flex-direction: column;
gap: 20px;
max-height: 100px;
}
} }
</style> </style>