карты пвз

This commit is contained in:
alsaze
2025-11-11 20:10:11 +03:00
parent 55103d3778
commit e5420edc64
6 changed files with 133 additions and 53 deletions

View File

@@ -48,6 +48,8 @@ const searchTerm = ref('')
</script>
<style lang="scss">
@use '~/assets/scss/utils' as *;
.pickup-point-card {
position: relative;
width: 100%;
@@ -62,6 +64,10 @@ const searchTerm = ref('')
height: calc(100dvh - 54px - 40px - 24px);
overflow-y: auto;
flex-shrink: 0;
@include mobile {
height: calc(100dvh - 72px - 40px - 32px);
}
}
&__content {

View File

@@ -0,0 +1,21 @@
<template>
<div class="control">
<UCheckbox
v-model="modelValue"
size="xl"
label="с примеркой"
/>
</div>
</template>
<script setup lang="ts">
const modelValue = defineModel<boolean>({ required: true })
</script>
<style scoped lang="scss">
.control {
background: var(--ui-bg-elevated);
padding: 8px 18px;
border-radius: 10px;
}
</style>

View File

@@ -0,0 +1,36 @@
<template>
<UTabs v-model="activeTab" :content="false" :items="tabs">
<template #map>
{{ activeTab === '0' ? 'Карта' : activeTab === '1' ? 'Список' : 'Другое' }}
</template>
</UTabs>
</template>
<script setup lang="ts">
import type { TabsItem } from '@nuxt/ui'
import { IPvzMapTabs } from '#shared/types'
import { computed } from 'vue'
const activeTab = defineModel('activeTab', { type: String, default: IPvzMapTabs.MAP })
const tabs = computed<TabsItem[]>(() =>
[
{
value: IPvzMapTabs.MAP,
label: activeTab.value === 'map' ? 'Карта' : '',
icon: 'lucide:map-pin',
slot: 'map' as const,
},
{
value: IPvzMapTabs.LIST,
label: activeTab.value === 'list' ? 'Список' : '',
icon: 'i-lucide-list',
slot: 'list' as const,
},
],
)
</script>
<style scoped lang="scss">
</style>

View File

@@ -40,36 +40,24 @@
<YandexMapControls :settings="{ position: 'bottom left', orientation: 'vertical' }">
<YandexMapControl>
<div
class="control"
>
<UCheckbox
v-model="isFitting"
size="xl"
label="с примеркой"
/>
</div>
<MapControlFitting v-model="isFitting" />
</YandexMapControl>
</YandexMapControls>
<YandexMapControls :settings="{ position: 'bottom right', orientation: 'vertical' }">
<YandexMapControl>
<UTabs v-model="activeTab" :content="false" :items="tabs">
<template #map>
{{ activeTab === '0' ? 'Карта' : activeTab === '1' ? 'Список' : 'Другое' }}
</template>
</UTabs>
<MapControlTabs v-model="activeTab" />
</YandexMapControl>
</YandexMapControls>
</YandexMap>
</template>
<script setup lang="ts">
import type { TabsItem } from '@nuxt/ui'
import type { LngLatBounds, YMap } from '@yandex/ymaps3-types'
import type { YMapLocationRequest } from '@yandex/ymaps3-types/imperative/YMap'
import type { YMapClusterer } from '@yandex/ymaps3-types/packages/clusterer'
import type { PickupPoint } from '~/server/shared/types/yandex_pvz'
import { IPvzMapTabs } from '#shared/types'
import { useGeolocation } from '@vueuse/core'
import { computed, shallowRef } from 'vue'
import {
@@ -81,38 +69,23 @@ import {
YandexMapDefaultSchemeLayer,
YandexMapMarker,
} from 'vue-yandex-maps'
import MapControlFitting from '~/components/MapControlFitting.vue'
import MapControlTabs from '~/components/MapControlTabs.vue'
const props = defineProps<{ modelValue: PickupPoint, pickupPoints: PickupPoint[] }>()
const emit = defineEmits<{
defineEmits<{
(e: 'update:modelValue', value: PickupPoint | undefined): void
(e: 'activeTab', value: string): void
}>()
const activeTab = defineModel('activeTab', { type: String, default: IPvzMapTabs.MAP })
const isFitting = defineModel('isFitting', { type: Boolean, default: false })
const { coords } = useGeolocation()
const clusterer = shallowRef<YMapClusterer | null>(null)
const trueBounds = ref<LngLatBounds>([[0, 0], [0, 0]])
const map = shallowRef<null | YMap>(null)
const isFitting = ref(false)
const activeTab = ref('map')
const tabs = computed<TabsItem[]>(() =>
[
{
value: 'map',
label: activeTab.value === 'map' ? 'Карта' : '',
icon: 'lucide:map-pin',
slot: 'map' as const,
},
{
value: 'list',
label: activeTab.value === 'list' ? 'Список' : '',
icon: 'i-lucide-list',
slot: 'list' as const,
},
],
)
const hasCoords = computed(() => coords.value?.latitude !== Infinity && coords.value?.longitude !== Infinity)
const location = ref<YMapLocationRequest>({
@@ -136,10 +109,6 @@ watch(() => props.modelValue, (newPickupPoint) => {
duration: 500,
}
})
watch(() => activeTab.value, (newActiveTab) => {
emit('activeTab', newActiveTab)
})
</script>
<style lang="scss" scoped>
@@ -207,10 +176,4 @@ watch(() => activeTab.value, (newActiveTab) => {
background-color: #1e293b;
}
}
.control {
background: var(--ui-bg-elevated);
padding: 8px 18px;
border-radius: 10px;
}
</style>