карта ПВЗ
All checks were successful
Deploy / build (push) Successful in 2m10s

This commit is contained in:
alsaze
2025-10-17 19:15:10 +03:00
parent 2b8a5e5774
commit 3119ecc2fa
9 changed files with 377 additions and 249 deletions

View File

@@ -0,0 +1,52 @@
<template>
<div>
<UPageCard>
<template #body>
<div>товары {{ `(${cart?.line_items?.length} шт)` }}</div>
<div v-if="cartSum">
итого {{ cartSum }}
</div>
</template>
<template #footer>
<UButton
class="justify-center text-center w-2xs"
size="xl"
:label="pay ? 'оформить заказ' : 'перейти к оформлению'"
@click="pay ? createOrder() : router.push(`/checkout/delivery`)"
/>
</template>
</UPageCard>
</div>
</template>
<script setup lang="ts">
import type { IBspb } from '~/server/shared/types/bspb'
defineProps({
pay: {
type: Boolean,
default: false,
},
})
const router = useRouter()
const { cart, cartSum } = useCart()
const createOrder = async () => {
const { data } = await useFetch<IBspb>('/api/bspb', {
method: 'POST',
body: {
order: {
typeRid: 'Purchase',
amount: cartSum,
currency: 'RUB',
hppRedirectUrl: `${import.meta.env.VITE_BASE_URL}/cart`,
},
},
})
const redirectUrl = `${data?.value?.order?.hppUrl}?orderId=${data?.value?.order?.id}&password=${data.value?.order?.password}`
window.open(redirectUrl, '_blank')
}
</script>

View File

@@ -140,14 +140,14 @@
<script lang="ts" setup>
import { useCheckout } from '../../composables/useCheckout'
const { setContacts, nextStep } = useCheckout()
const { contacts, setContacts, nextStep } = useCheckout()
const { errors, handleSubmit, defineField } = useForm({
initialValues: {
name: '',
surname: '',
phone: '',
email: '',
name: contacts.value.name,
surname: contacts.value.surname,
phone: contacts.value.phone,
email: contacts.value.email,
},
validationSchema: {
name(value: string) {

View File

@@ -18,10 +18,10 @@
<UButton
size="sm"
class="text-muted-foreground"
class="text-muted-foreground mla cursor-pointer"
variant="ghost"
icon="i-ph-pencil-simple-line"
@click="onEditDelivery"
@click="setStep('delivery')"
/>
</h3>
@@ -57,10 +57,10 @@
<UButton
size="sm"
class="text-muted-foreground"
class="text-muted-foreground mla cursor-pointer"
variant="ghost"
icon="i-ph-pencil-simple-line"
@click="onEditContacts"
@click="setStep('contacts')"
/>
</h3>
@@ -81,43 +81,16 @@
</div>
</div>
<div>
<UButton label="СОздать ОредЕр" @click="createOrder" />
</div>
<PayBlock pay />
</div>
</template>
<script setup lang="ts">
import type { IBspb } from '~/server/shared/types/bspb'
import SummaryCartItem from '../../components/cart/SummaryCartItem.vue'
import PayBlock from './PayBlock.vue'
const { cart } = useCart()
const { contacts } = useCheckout()
function onEditDelivery() {
console.log('pizda')
}
function onEditContacts() {
console.log('pizda')
}
const createOrder = async () => {
const { data } = await useFetch<IBspb>('/api/bspb', {
method: 'POST',
body: {
order: {
typeRid: 'Purchase',
amount: 100,
currency: 'RUB',
hppRedirectUrl: `${import.meta.env.VITE_BASE_URL}/cart`,
},
},
})
const redirectUrl = `${data?.value?.order?.hppUrl}?orderId=${data?.value?.order?.id}&password=${data.value?.order?.password}`
window.open(redirectUrl, '_blank')
}
const { contacts, setStep } = useCheckout()
definePageMeta({
layout: 'checkout',