This commit is contained in:
52
pages/checkout/PayBlock.vue
Normal file
52
pages/checkout/PayBlock.vue
Normal 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>
|
||||
@@ -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) {
|
||||
|
||||
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user