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

This commit is contained in:
alsaze 2025-10-08 16:06:53 +03:00
parent 5416df0c2c
commit cb5b80fc6b
5 changed files with 94 additions and 16 deletions

View File

@ -58,7 +58,7 @@ body {
//swiper //swiper
.swiper { .swiper {
width: 100%; width: 100%;
height: 100%; height: calc(100vh - 54px);
} }
.swiper-slide { .swiper-slide {
@ -75,6 +75,12 @@ body {
.swiper-slide img { .swiper-slide img {
display: block; display: block;
width: 100%; width: 100%;
height: 100%; height: calc(100vh - 54px);
object-fit: cover; object-fit: cover;
} }
.swiper-pagination {
position: absolute;
bottom: 200px !important;
--swiper-pagination-bullet-size: 4px
}

View File

@ -2,7 +2,7 @@
<div class="product-description"> <div class="product-description">
<h1>{{ productsData?.name }}</h1> <h1>{{ productsData?.name }}</h1>
<h2>{{ currentVariant?.options[0]?.price }} <Icon name="ph:currency-rub" /></h2> <ProductPrice :price="currentVariant?.options[0]?.price" />
<ProductVariations v-if="colors?.length > 1" /> <ProductVariations v-if="colors?.length > 1" />
@ -47,6 +47,7 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import ProductPrice from '~/components/ProductPrice.vue'
import ProductVariations from '~/components/ProductVariations.vue' import ProductVariations from '~/components/ProductVariations.vue'
import { useCurrentProduct, useProduct } from '~/composables' import { useCurrentProduct, useProduct } from '~/composables'
@ -92,11 +93,12 @@ function addToCartBtn() {
</script> </script>
<style lang="scss"> <style lang="scss">
@use '~/assets/scss/utils' as *;
.product-description { .product-description {
width: 100%; width: 100%;
max-width: 335px; max-width: 335px;
padding-top: 30px; padding: 30px 30px 0;
padding-inline: 30px;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 10px; gap: 10px;
@ -109,6 +111,10 @@ function addToCartBtn() {
max-height: calc(100vh - 80px); max-height: calc(100vh - 80px);
} }
@include mobile {
padding: 0 10px;
}
&__sizes { &__sizes {
display: grid; display: grid;
grid-template-columns: repeat(4, 1fr); grid-template-columns: repeat(4, 1fr);
@ -118,13 +124,5 @@ function addToCartBtn() {
&__size { &__size {
width: 65px; width: 65px;
} }
h2 {
display: flex;
flex-direction: row;
gap: 4px;
align-items: center;
text-align: center;
}
} }
</style> </style>

View File

@ -17,7 +17,7 @@
> >
<SwiperSlide <SwiperSlide
v-for="image in currentVariantImages?.slice(0, 5)" v-for="image in currentVariantImages?.slice(0, 5)"
:key="image?.id" :key="image?.src"
> >
<img width="100%" :src="image?.src" :alt="image?.src"> <img width="100%" :src="image?.src" :alt="image?.src">
</SwiperSlide> </SwiperSlide>

View File

@ -0,0 +1,26 @@
<template>
<div class="product-price">
<h2>{{ price }} <Icon name="ph:currency-rub" /></h2>
</div>
</template>
<script setup lang="ts">
defineProps({
price: {
type: [String, Number],
required: true,
},
})
</script>
<style lang="scss">
.product-price {
h2 {
display: flex;
flex-direction: row;
gap: 4px;
align-items: center;
text-align: center;
}
}
</style>

View File

@ -8,6 +8,30 @@
> >
<ProductImages /> <ProductImages />
<div class="product-info">
<div class="product-info__title">
<ProductPrice :price="currentVariant?.options[0]?.price" />
<div>
фотомодель
</div>
</div>
<h1>
{{ productsData?.name }}
</h1>
<div class="mt20">
<UButton
icon="lucide:shopping-cart"
class="justify-content-center w-100 d-flex"
label="Добавить"
size="xl"
@click="open = !open"
/>
</div>
</div>
<template #body> <template #body>
<ProductDescription /> <ProductDescription />
</template> </template>
@ -22,7 +46,10 @@
import type { UseSwipeDirection } from '@vueuse/core' import type { UseSwipeDirection } from '@vueuse/core'
import { useMediaQuery, useSwipe } from '@vueuse/core' import { useMediaQuery, useSwipe } from '@vueuse/core'
import { computed, shallowRef } from 'vue' import { computed, shallowRef } from 'vue'
import ProductPrice from '~/components/ProductPrice.vue'
import { useCurrentProduct, useProduct } from '~/composables'
const { productsData } = useProduct()
const isMobile = useMediaQuery('(max-width: 1280px)') const isMobile = useMediaQuery('(max-width: 1280px)')
const open = ref(false) const open = ref(false)
const target = shallowRef<HTMLElement | null>(null) const target = shallowRef<HTMLElement | null>(null)
@ -35,25 +62,28 @@ const { isSwiping, lengthY } = useSwipe(
passive: false, passive: false,
onSwipe(e: TouchEvent) { onSwipe(e: TouchEvent) {
if (targetHeight.value) { if (targetHeight.value) {
if (lengthY.value > 200) { if (lengthY.value > 100) {
open.value = true open.value = true
} }
} }
}, },
onSwipeEnd(e: TouchEvent, direction: UseSwipeDirection) { onSwipeEnd(e: TouchEvent, direction: UseSwipeDirection) {
console.log('lengthY.value', lengthY.value) console.log('lengthY.value', lengthY.value)
if (lengthY.value > 200 && targetHeight.value && (Math.abs(lengthY.value) / targetHeight.value) >= 0.5) { if (lengthY.value > 100 && targetHeight.value && (Math.abs(lengthY.value) / targetHeight.value) >= 0.5) {
open.value = true open.value = true
} }
}, },
}, },
) )
const { currentVariant } = useCurrentProduct()
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
@use '~/assets/scss/utils' as *; @use '~/assets/scss/utils' as *;
.product { .product {
position: relative;
width: 100%; width: 100%;
display: flex; display: flex;
flex-direction: row; flex-direction: row;
@ -63,4 +93,22 @@ const { isSwiping, lengthY } = useSwipe(
align-items: center; align-items: center;
} }
} }
.product-info {
padding-inline: 15px;
position: absolute;
bottom: 40px;
z-index: 10;
width: 100vw;
display: flex;
flex-direction: column;
justify-content: center;
gap: 10px;
&__title {
display: flex;
flex-direction: row;
justify-content: space-between;
}
}
</style> </style>