This commit is contained in:
parent
bff6833781
commit
2591d145f8
@ -24,7 +24,7 @@
|
|||||||
:key="pickupPoint.id"
|
:key="pickupPoint.id"
|
||||||
position="top-center left-center"
|
position="top-center left-center"
|
||||||
:settings="{ coordinates: [pickupPoint.position.longitude, pickupPoint.position.latitude] }"
|
:settings="{ coordinates: [pickupPoint.position.longitude, pickupPoint.position.latitude] }"
|
||||||
@click="centerMap(pickupPoint)"
|
@click="$emit('update:modelValue', pickupPoint)"
|
||||||
>
|
>
|
||||||
<div class="marker">
|
<div class="marker">
|
||||||
<Icon name="i-lucide-map-pin" class="marker__icon" />
|
<Icon name="i-lucide-map-pin" class="marker__icon" />
|
||||||
@ -54,11 +54,13 @@ import {
|
|||||||
YandexMapDefaultSchemeLayer,
|
YandexMapDefaultSchemeLayer,
|
||||||
YandexMapMarker,
|
YandexMapMarker,
|
||||||
} from 'vue-yandex-maps'
|
} from 'vue-yandex-maps'
|
||||||
import { useCheckout } from '~/composables/useCheckout'
|
|
||||||
|
|
||||||
defineProps<{ pickupPoints: PickupPoint[] }>()
|
const props = defineProps<{ modelValue: PickupPoint, pickupPoints: PickupPoint[] }>()
|
||||||
|
|
||||||
|
defineEmits<{
|
||||||
|
(e: 'update:modelValue', value: PickupPoint | undefined): void
|
||||||
|
}>()
|
||||||
|
|
||||||
const { setCheckoutPickupPoint, isPickupPointSelected } = useCheckout()
|
|
||||||
const { coords } = useGeolocation()
|
const { coords } = useGeolocation()
|
||||||
const clusterer = shallowRef<YMapClusterer | null>(null)
|
const clusterer = shallowRef<YMapClusterer | null>(null)
|
||||||
const trueBounds = ref<LngLatBounds>([[0, 0], [0, 0]])
|
const trueBounds = ref<LngLatBounds>([[0, 0], [0, 0]])
|
||||||
@ -70,17 +72,6 @@ const location = ref<YMapLocationRequest>({
|
|||||||
zoom: 2,
|
zoom: 2,
|
||||||
})
|
})
|
||||||
|
|
||||||
function centerMap(pickupPoint: PickupPoint) {
|
|
||||||
location.value = {
|
|
||||||
center: [pickupPoint.position.longitude, pickupPoint.position.latitude],
|
|
||||||
zoom: 18,
|
|
||||||
duration: 500,
|
|
||||||
}
|
|
||||||
|
|
||||||
setCheckoutPickupPoint(pickupPoint)
|
|
||||||
isPickupPointSelected.value = true
|
|
||||||
}
|
|
||||||
|
|
||||||
watch(coords, (newCoords) => {
|
watch(coords, (newCoords) => {
|
||||||
if (newCoords && hasCoords.value) {
|
if (newCoords && hasCoords.value) {
|
||||||
location.value = {
|
location.value = {
|
||||||
@ -91,7 +82,13 @@ watch(coords, (newCoords) => {
|
|||||||
}
|
}
|
||||||
}, { once: true })
|
}, { once: true })
|
||||||
|
|
||||||
defineExpose({ centerMap, location })
|
watch(() => props.modelValue, (newPickupPoint) => {
|
||||||
|
location.value = {
|
||||||
|
center: [newPickupPoint.position.longitude, newPickupPoint.position.latitude],
|
||||||
|
zoom: 18,
|
||||||
|
duration: 500,
|
||||||
|
}
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|||||||
@ -28,7 +28,7 @@
|
|||||||
v-for="pickupPoint in filteredPoints"
|
v-for="pickupPoint in filteredPoints"
|
||||||
:key="pickupPoint.id"
|
:key="pickupPoint.id"
|
||||||
class="pickup-point-card"
|
class="pickup-point-card"
|
||||||
@click="centerMap(pickupPoint)"
|
@click="selectedPickupPoint = pickupPoint"
|
||||||
>
|
>
|
||||||
<div class="pickup-point-card__content">
|
<div class="pickup-point-card__content">
|
||||||
<h3>Yandex</h3>
|
<h3>Yandex</h3>
|
||||||
@ -41,7 +41,10 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<PvzMap ref="mapRef" :pickup-points="filteredPoints" />
|
<PvzMap
|
||||||
|
v-model="selectedPickupPoint"
|
||||||
|
:pickup-points="filteredPoints"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -53,11 +56,11 @@ import DeliveryInfo from '~/components/DeliveryInfo.vue'
|
|||||||
import PvzMap from '~/components/PvzMap.vue'
|
import PvzMap from '~/components/PvzMap.vue'
|
||||||
import { useCheckout } from '~/composables/useCheckout'
|
import { useCheckout } from '~/composables/useCheckout'
|
||||||
|
|
||||||
const { isPickupPointSelected } = useCheckout()
|
const { setCheckoutPickupPoint, isPickupPointSelected } = useCheckout()
|
||||||
const { coords } = useGeolocation()
|
const { coords } = useGeolocation()
|
||||||
const mapRef = ref<InstanceType<typeof PvzMap> | null>(null)
|
|
||||||
const yandexPvz = ref<YandexPvzResponse>()
|
const yandexPvz = ref<YandexPvzResponse>()
|
||||||
const searchTerm = ref('')
|
const searchTerm = ref('')
|
||||||
|
const selectedPickupPoint = ref<PickupPoint | undefined>()
|
||||||
|
|
||||||
const waitForCoords = () =>
|
const waitForCoords = () =>
|
||||||
new Promise<void>((resolve) => {
|
new Promise<void>((resolve) => {
|
||||||
@ -108,9 +111,10 @@ const filteredPoints = computed<PickupPoint[]>(() => {
|
|||||||
) || []
|
) || []
|
||||||
})
|
})
|
||||||
|
|
||||||
const centerMap = (point: any) => {
|
watch(() => selectedPickupPoint.value, (newPickupPoint) => {
|
||||||
mapRef.value?.centerMap(point)
|
setCheckoutPickupPoint(newPickupPoint)
|
||||||
}
|
isPickupPointSelected.value = true
|
||||||
|
})
|
||||||
|
|
||||||
definePageMeta({
|
definePageMeta({
|
||||||
layout: 'checkout',
|
layout: 'checkout',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user