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

This commit is contained in:
alsaze 2025-10-08 14:36:09 +03:00
parent 6a08eebf01
commit 66dd08cf65
9 changed files with 139 additions and 29 deletions

View File

@ -24,6 +24,7 @@ h3 {
@include h3('h3'); @include h3('h3');
} }
//скроллбар
::-webkit-scrollbar { ::-webkit-scrollbar {
width: 8px; width: 8px;
} }
@ -53,3 +54,27 @@ h3 {
body { body {
-ms-overflow-style: -ms-autohiding-scrollbar; -ms-overflow-style: -ms-autohiding-scrollbar;
} }
//swiper
.swiper {
width: 100%;
height: 100%;
}
.swiper-slide {
text-align: center;
font-size: 18px;
background: #444;
/* Center slide text vertically */
display: flex;
justify-content: center;
align-items: center;
}
.swiper-slide img {
display: block;
width: 100%;
height: 100%;
object-fit: cover;
}

View File

@ -95,6 +95,11 @@ function addToCartBtn() {
.product-description { .product-description {
width: 100%; width: 100%;
max-width: 335px; max-width: 335px;
padding-top: 30px;
padding-inline: 30px;
display: flex;
flex-direction: column;
gap: 10px;
@media (min-width: 768px) { @media (min-width: 768px) {
position: sticky; position: sticky;
@ -104,12 +109,6 @@ function addToCartBtn() {
max-height: calc(100vh - 80px); max-height: calc(100vh - 80px);
} }
padding-top: 30px;
padding-inline: 30px;
display: flex;
flex-direction: column;
gap: 10px;
&__sizes { &__sizes {
display: grid; display: grid;
grid-template-columns: repeat(4, 1fr); grid-template-columns: repeat(4, 1fr);

View File

@ -1,5 +1,5 @@
<template> <template>
<div class="product-images"> <div v-if="!isMobile" class="product-images">
<div <div
v-for="image in currentVariantImages?.slice(0, 5)" v-for="image in currentVariantImages?.slice(0, 5)"
:key="image?.id" :key="image?.id"
@ -7,11 +7,33 @@
<img width="100%" :src="image?.src" :alt="image?.src"> <img width="100%" :src="image?.src" :alt="image?.src">
</div> </div>
</div> </div>
<Swiper
v-if="isMobile"
:pagination="true"
:loop="true"
:modules="modules"
class="mySwiper"
>
<SwiperSlide
v-for="image in currentVariantImages?.slice(0, 5)"
:key="image?.id"
>
<img width="100%" :src="image?.src" :alt="image?.src">
</SwiperSlide>
</Swiper>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { useMediaQuery } from '@vueuse/core'
import { Pagination } from 'swiper/modules'
import { Swiper, SwiperSlide } from 'swiper/vue'
import { useCurrentProduct } from '~/composables' import { useCurrentProduct } from '~/composables'
import 'swiper/css'
import 'swiper/css/pagination'
const isMobile = useMediaQuery('(max-width: 1280px)')
const modules = [Pagination]
const { currentVariantImages } = useCurrentProduct() const { currentVariantImages } = useCurrentProduct()
</script> </script>
@ -19,7 +41,7 @@ const { currentVariantImages } = useCurrentProduct()
.product-images { .product-images {
position: relative; position: relative;
width: 100%; width: 100%;
display: flex; display: grid;
flex-direction: column; grid-template-columns: repeat(2, 1fr);
} }
</style> </style>

View File

@ -32,9 +32,9 @@
</UContainer> </UContainer>
</main> </main>
<footer class="footer"> <!-- <footer class="footer"> -->
Footer <!-- Footer -->
</footer> <!-- </footer> -->
</div> </div>
</template> </template>

View File

@ -25,6 +25,7 @@
"dayjs": "^1.11.13", "dayjs": "^1.11.13",
"decimal.js": "^10.5.0", "decimal.js": "^10.5.0",
"nuxt": "^3.17.6", "nuxt": "^3.17.6",
"swiper": "^12.0.2",
"typescript": "^5.6.3", "typescript": "^5.6.3",
"vue": "^3.5.17", "vue": "^3.5.17",
"vue-router": "^4.5.1" "vue-router": "^4.5.1"

View File

@ -9,12 +9,15 @@
</div> </div>
</div> </div>
<div class="cart__create-order"> <div>
<div>{{ `Товары: ${cart?.line_items?.length}` }}</div> <div class="cart__create-order">
<div>{{ `Товары: ${cart?.line_items?.length}` }}</div>
<div>{{ `Сумма: ${cart?.line_items?.length}` }}</div>
<UButton class="w-100 d-flex" @click="createOrder"> <UButton class="w-100 d-flex" @click="createOrder">
Перейти к оформлению Перейти к оформлению
</UButton> </UButton>
</div>
</div> </div>
</div> </div>
</template> </template>
@ -22,6 +25,7 @@
<script setup lang="ts"> <script setup lang="ts">
import type { IBspb } from '~/server/shared/types/bspb' import type { IBspb } from '~/server/shared/types/bspb'
import { usePostOrdersCreate } from '~/api/mutations/wp/usePostOrdersCreate' import { usePostOrdersCreate } from '~/api/mutations/wp/usePostOrdersCreate'
import { useCart } from '~/composables'
const { cart } = useCart() const { cart } = useCart()
const { mutateAsync } = usePostOrdersCreate() const { mutateAsync } = usePostOrdersCreate()
@ -66,7 +70,6 @@ const createOrder = async () => {
display: inline-flex; display: inline-flex;
flex-direction: column; flex-direction: column;
gap: 20px; gap: 20px;
max-height: 100px;
} }
} }
</style> </style>

View File

@ -1,8 +1,6 @@
<template> <template>
<div class="index"> <div class="index">
<div <div class="cards-list">
class="cards-list"
>
<div <div
v-for="product in productCardData" v-for="product in productCardData"
:key="product.id" :key="product.id"
@ -36,26 +34,43 @@ const router = useRouter()
</script> </script>
<style lang="scss"> <style lang="scss">
@use '~/assets/scss/utils' as *;
.cards-list { .cards-list {
padding: 15px; padding: 15px;
display: grid; display: grid;
grid-template-columns: repeat(auto-fit, minmax(350px, 1fr)); grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
gap: 4px; gap: 30px 4px;
@include mobile {
grid-template-columns: repeat(2, 1fr);
gap: 10px;
padding: 10px;
}
} }
.card { .card {
min-width: 300px;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
cursor: pointer; cursor: pointer;
@include mobile {
min-width: auto;
}
&__image { &__image {
width: 100%; width: 100%;
height: auto;
} }
&__description { &__description {
padding-inline: 10px; padding: 10px 5px;
@include mobile {
padding: 8px 4px;
font-size: 14px;
}
} }
} }
</style> </style>

View File

@ -1,14 +1,54 @@
<template> <template>
<div class="product"> <div ref="target" class="product">
<ProductImages /> <UDrawer
<ProductDescription /> v-model:open="open"
title="Drawer with title"
:class="{ animated: !isSwiping }"
:style="{ top }"
>
<ProductImages />
<template #body>
<ProductDescription />
</template>
</UDrawer>
</div> </div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import type { UseSwipeDirection } from '@vueuse/core'
import { useSwipe } from '@vueuse/core'
import { computed, shallowRef } from 'vue'
const open = ref(false)
const target = shallowRef<HTMLElement | null>(null)
const targetHeight = computed(() => target.value?.offsetHeight)
const top = shallowRef('0')
const { isSwiping, lengthY } = useSwipe(
target,
{
passive: false,
onSwipe(e: TouchEvent) {
if (targetHeight.value) {
if (lengthY.value > 200) {
open.value = true
}
}
},
onSwipeEnd(e: TouchEvent, direction: UseSwipeDirection) {
console.log('lengthY.value', lengthY.value)
if (lengthY.value > 200 && targetHeight.value && (Math.abs(lengthY.value) / targetHeight.value) >= 0.5) {
open.value = true
}
},
},
)
</script> </script>
<style lang="scss"> <style scoped lang="scss">
@use '~/assets/scss/utils' as *;
.product { .product {
width: 100%; width: 100%;
display: flex; display: flex;

View File

@ -8660,6 +8660,11 @@ swagger2openapi@^7.0.8:
yaml "^1.10.0" yaml "^1.10.0"
yargs "^17.0.1" yargs "^17.0.1"
swiper@^12.0.2:
version "12.0.2"
resolved "https://registry.yarnpkg.com/swiper/-/swiper-12.0.2.tgz#aa52251d125fc6e9986af09ae3769fe836e68780"
integrity sha512-y8F6fDGXmTVVgwqJj6I00l4FdGuhpFJn0U/9Ucn1MwWOw3NdLV8aH88pZOjyhBgU/6PyBlUx+JuAQ5KMWz906Q==
"synckit@^0.6.2 || ^0.7.3 || ^0.11.5": "synckit@^0.6.2 || ^0.7.3 || ^0.11.5":
version "0.11.11" version "0.11.11"
resolved "https://registry.yarnpkg.com/synckit/-/synckit-0.11.11.tgz#c0b619cf258a97faa209155d9cd1699b5c998cb0" resolved "https://registry.yarnpkg.com/synckit/-/synckit-0.11.11.tgz#c0b619cf258a97faa209155d9cd1699b5c998cb0"