This commit is contained in:
parent
2591d145f8
commit
436f537166
@ -5,8 +5,6 @@ export const useCheckout = createSharedComposable(() => {
|
|||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
|
|
||||||
const isPickupPointSelected = ref(false)
|
|
||||||
|
|
||||||
const checkoutPickupPoint = useStorage<PickupPoint | undefined>(
|
const checkoutPickupPoint = useStorage<PickupPoint | undefined>(
|
||||||
'checkout-pickupPoint',
|
'checkout-pickupPoint',
|
||||||
undefined,
|
undefined,
|
||||||
@ -23,6 +21,8 @@ export const useCheckout = createSharedComposable(() => {
|
|||||||
checkoutPickupPoint.value = point
|
checkoutPickupPoint.value = point
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const isPickupPointSelected = computed(() => !!checkoutPickupPoint.value)
|
||||||
|
|
||||||
const checkoutContacts = useStorage('checkout-contacts', { name: '', surname: '', phone: '', email: '' })
|
const checkoutContacts = useStorage('checkout-contacts', { name: '', surname: '', phone: '', email: '' })
|
||||||
|
|
||||||
const setCheckoutContacts = (data: { name: string, surname: string, phone: string, email: string }) => {
|
const setCheckoutContacts = (data: { name: string, surname: string, phone: string, email: string }) => {
|
||||||
@ -49,7 +49,6 @@ export const useCheckout = createSharedComposable(() => {
|
|||||||
|
|
||||||
function previewStep() {
|
function previewStep() {
|
||||||
if (isPickupPointSelected.value) {
|
if (isPickupPointSelected.value) {
|
||||||
isPickupPointSelected.value = false
|
|
||||||
setCheckoutPickupPoint(undefined)
|
setCheckoutPickupPoint(undefined)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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="selectedPickupPoint = pickupPoint"
|
@click="checkoutPickupPoint = pickupPoint"
|
||||||
>
|
>
|
||||||
<div class="pickup-point-card__content">
|
<div class="pickup-point-card__content">
|
||||||
<h3>Yandex</h3>
|
<h3>Yandex</h3>
|
||||||
@ -42,8 +42,9 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<PvzMap
|
<PvzMap
|
||||||
v-model="selectedPickupPoint"
|
v-model="checkoutPickupPoint"
|
||||||
:pickup-points="filteredPoints"
|
:pickup-points="filteredPoints"
|
||||||
|
@update:model-value="setCheckoutPickupPoint(checkoutPickupPoint)"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@ -56,11 +57,10 @@ 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 { setCheckoutPickupPoint, isPickupPointSelected } = useCheckout()
|
const { setCheckoutPickupPoint, isPickupPointSelected, checkoutPickupPoint } = useCheckout()
|
||||||
const { coords } = useGeolocation()
|
const { coords } = useGeolocation()
|
||||||
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) => {
|
||||||
@ -111,11 +111,6 @@ const filteredPoints = computed<PickupPoint[]>(() => {
|
|||||||
) || []
|
) || []
|
||||||
})
|
})
|
||||||
|
|
||||||
watch(() => selectedPickupPoint.value, (newPickupPoint) => {
|
|
||||||
setCheckoutPickupPoint(newPickupPoint)
|
|
||||||
isPickupPointSelected.value = true
|
|
||||||
})
|
|
||||||
|
|
||||||
definePageMeta({
|
definePageMeta({
|
||||||
layout: 'checkout',
|
layout: 'checkout',
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user