From 2b8a5e57742e214b01fa484a446ced17816aa148 Mon Sep 17 00:00:00 2001 From: alsaze Date: Fri, 17 Oct 2025 17:10:14 +0300 Subject: [PATCH] =?UTF-8?q?=D0=BA=D0=B0=D1=80=D1=82=D0=B0=20=D0=9F=D0=92?= =?UTF-8?q?=D0=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 2 + components/cart/SummaryCartItem.vue | 44 +++++ composables/useCheckout.ts | 11 +- nuxt.config.ts | 14 +- package.json | 1 + pages/cart.vue | 1 - pages/checkout/contacts.vue | 250 +++++++++++++++++++--------- pages/checkout/summary.vue | 134 ++++++++++++++- server/api/bspb.ts | 17 +- yarn.lock | 39 ++++- 10 files changed, 418 insertions(+), 95 deletions(-) create mode 100644 components/cart/SummaryCartItem.vue diff --git a/Dockerfile b/Dockerfile index 273f4c9..372cf3f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,6 +15,8 @@ ENV BSPB_MERCHANT_ID=TT00001 ENV BSPB_MERCHANT_PASSWORD=ztTGre1OBZg3 ENV BSPB_API_URL=https://pgtest.bspb.ru:5443 +ENV VITE_BASE_URL=https://paxton.koptilnya.xyz + EXPOSE 80 CMD ["node", "/app/server/index.mjs"] diff --git a/components/cart/SummaryCartItem.vue b/components/cart/SummaryCartItem.vue new file mode 100644 index 0000000..9640fcd --- /dev/null +++ b/components/cart/SummaryCartItem.vue @@ -0,0 +1,44 @@ + + + + + diff --git a/composables/useCheckout.ts b/composables/useCheckout.ts index c571e03..a987f78 100644 --- a/composables/useCheckout.ts +++ b/composables/useCheckout.ts @@ -1,9 +1,15 @@ -import { createSharedComposable } from '@vueuse/core' +import { createSharedComposable, useStorage } from '@vueuse/core' export const useCheckout = createSharedComposable(() => { const router = useRouter() const route = useRoute() + const contacts = useStorage('checkout-contacts', { name: '', surname: '', phone: '', email: '' }) + + const setContacts = (data: { name: string, surname: string, phone: string, email: string }) => { + contacts.value = data + } + const checkoutSteps = [ { step: 1, @@ -41,6 +47,9 @@ export const useCheckout = createSharedComposable(() => { } return { + contacts, + setContacts, + checkoutSteps, currentCheckoutStep, diff --git a/nuxt.config.ts b/nuxt.config.ts index b7f16f7..0c85087 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -3,7 +3,19 @@ export default defineNuxtConfig({ ssr: true, compatibilityDate: '2025-05-15', devtools: { enabled: true }, - modules: ['@nuxt/ui', '@nuxt/image', '@nuxt/icon', '@nuxt/fonts', '@nuxtjs/i18n'], + modules: [ + '@nuxt/ui', + '@nuxt/image', + '@nuxt/icon', + '@nuxt/fonts', + '@nuxtjs/i18n', + [ + '@vee-validate/nuxt', + { + autoImports: true, + }, + ], + ], css: ['~/assets/css/main.css', '~/assets/scss/main.scss'], i18n: { locales: [ diff --git a/package.json b/package.json index fc54018..1dc19ea 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "@nuxtjs/i18n": "^10.0.4", "@tanstack/vue-query": "^5.75.5", "@tanstack/vue-query-devtools": "^5.87.1", + "@vee-validate/nuxt": "^4.15.1", "@vueuse/core": "^13.1.0", "axios": "^1.12.2", "dayjs": "^1.11.13", diff --git a/pages/cart.vue b/pages/cart.vue index dc78e16..1fdd55d 100644 --- a/pages/cart.vue +++ b/pages/cart.vue @@ -1,6 +1,5 @@ - diff --git a/server/api/bspb.ts b/server/api/bspb.ts index 65fbdd3..099e7f9 100644 --- a/server/api/bspb.ts +++ b/server/api/bspb.ts @@ -1,8 +1,8 @@ import https from 'node:https' import axios from 'axios' -import { defineEventHandler } from 'h3' +import { defineEventHandler, readBody } from 'h3' -export default defineEventHandler(async () => { +export default defineEventHandler(async (event) => { const merchantId = process.env.BSPB_MERCHANT_ID! const merchantPassword = process.env.BSPB_MERCHANT_PASSWORD! const apiUrl = process.env.BSPB_API_URL! @@ -18,18 +18,9 @@ export default defineEventHandler(async () => { rejectUnauthorized: false, }) - const data = { - order: { - typeRid: 'Purchase', - amount: 100, - currency: 'RUB', - title: 'Название заказа', - description: 'Описание заказа', - hppRedirectUrl: 'http://localhost:3000/cart', - }, - } + const orderData = await readBody(event) - const response = await axios.post(`${apiUrl}/order`, data, { + const response = await axios.post(`${apiUrl}/order`, orderData, { httpsAgent: agent, headers: { 'Content-Type': 'application/json', diff --git a/yarn.lock b/yarn.lock index 688462b..1deca0c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2500,6 +2500,15 @@ hookable "^5.5.3" unhead "2.0.19" +"@vee-validate/nuxt@^4.15.1": + version "4.15.1" + resolved "https://registry.yarnpkg.com/@vee-validate/nuxt/-/nuxt-4.15.1.tgz#4062be82b364f5b16fa1be31aa3be59c47012ba7" + integrity sha512-vy+BYUmwy7d01js8jg3qApyrE8/nJHbHvPZNYZSe+hTQEblNqyVt+MnD1incyxMCcivED8FX5w4rjxdoUn7iMQ== + dependencies: + "@nuxt/kit" "^3.13.2" + local-pkg "^0.5.0" + vee-validate "4.15.1" + "@vercel/nft@^0.30.2": version "0.30.3" resolved "https://registry.yarnpkg.com/@vercel/nft/-/nft-0.30.3.tgz#ab09a7f22ec7b354fcbe2d79f3d8c0c8adfbcc89" @@ -2645,6 +2654,13 @@ resolved "https://registry.yarnpkg.com/@vue/devtools-api/-/devtools-api-6.6.4.tgz#cbe97fe0162b365edc1dba80e173f90492535343" integrity sha512-sGhTPMuXqZ1rVOk32RylztWkfXTRhuS7vgAKv0zjqk8gbsHkJ7xfFf+jbySxt7tWObEJwyKaHMikV/WGDiQm8g== +"@vue/devtools-api@^7.5.2": + version "7.7.7" + resolved "https://registry.yarnpkg.com/@vue/devtools-api/-/devtools-api-7.7.7.tgz#5ef5f55f60396220725a273548c0d7ee983d5d34" + integrity sha512-lwOnNBH2e7x1fIIbVT7yF5D+YWhqELm55/4ZKf45R9T8r9dE2AIOy8HKjfqzGsoTHFbWbr337O4E0A0QADnjBg== + dependencies: + "@vue/devtools-kit" "^7.7.7" + "@vue/devtools-core@^7.7.7": version "7.7.7" resolved "https://registry.yarnpkg.com/@vue/devtools-core/-/devtools-core-7.7.7.tgz#9885e2ecb7b462cca8e629d9cff0ab00bfd30d63" @@ -5482,6 +5498,14 @@ listhen@^1.5.6, listhen@^1.9.0: untun "^0.1.3" uqr "^0.1.2" +local-pkg@^0.5.0: + version "0.5.1" + resolved "https://registry.yarnpkg.com/local-pkg/-/local-pkg-0.5.1.tgz#69658638d2a95287534d4c2fff757980100dbb6d" + integrity sha512-9rrA30MRRP3gBD3HTGnC6cDFpaE1kVDWxWgqWJUN0RvDNAo+Nz/9GxB+nHOH0ifbVFy0hSA1V6vFDvnx54lTEQ== + dependencies: + mlly "^1.7.3" + pkg-types "^1.2.1" + local-pkg@^1.0.0, local-pkg@^1.1.1, local-pkg@^1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/local-pkg/-/local-pkg-1.1.2.tgz#c03d208787126445303f8161619dc701afa4abb5" @@ -6139,7 +6163,7 @@ mkdirp-classic@^0.5.2, mkdirp-classic@^0.5.3: resolved "https://registry.yarnpkg.com/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz#fa10c9115cc6d8865be221ba47ee9bed78601113" integrity sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A== -mlly@^1.3.0, mlly@^1.7.1, mlly@^1.7.2, mlly@^1.7.4, mlly@^1.8.0: +mlly@^1.3.0, mlly@^1.7.1, mlly@^1.7.2, mlly@^1.7.3, mlly@^1.7.4, mlly@^1.8.0: version "1.8.0" resolved "https://registry.yarnpkg.com/mlly/-/mlly-1.8.0.tgz#e074612b938af8eba1eaf43299cbc89cb72d824e" integrity sha512-l8D9ODSRWLe2KHJSifWGwBqpTZXIXTeo8mlKjY+E2HAakaTeNpqAyBZ8GSqLzHgw4XmHmC8whvpjJNMbFZN7/g== @@ -8197,6 +8221,11 @@ type-check@^0.4.0, type-check@~0.4.0: dependencies: prelude-ls "^1.2.1" +type-fest@^4.8.3: + version "4.41.0" + resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-4.41.0.tgz#6ae1c8e5731273c2bf1f58ad39cbae2c91a46c58" + integrity sha512-TeTSQ6H5YHvpqVwBRcnLDCBnDOHWYu7IvGbHT6N8AOymcr9PJGjc1GTtiWZTYg0NCgYwvnYWEkVChQAr9bjfwA== + type-fest@^5.0.0: version "5.1.0" resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-5.1.0.tgz#30ba6dc2acde4f73732417031f8ac19a0afcb5b7" @@ -8516,6 +8545,14 @@ vaul-vue@0.4.1: reka-ui "^2.0.0" vue "^3.4.5" +vee-validate@4.15.1: + version "4.15.1" + resolved "https://registry.yarnpkg.com/vee-validate/-/vee-validate-4.15.1.tgz#66e787e88916baa05f42e53bc0848e0878d50f91" + integrity sha512-DkFsiTwEKau8VIxyZBGdO6tOudD+QoUBPuHj3e6QFqmbfCRj1ArmYWue9lEp6jLSWBIw4XPlDLjFIZNLdRAMSg== + dependencies: + "@vue/devtools-api" "^7.5.2" + type-fest "^4.8.3" + vite-dev-rpc@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/vite-dev-rpc/-/vite-dev-rpc-1.1.0.tgz#a54be63cc4dbb127bce1360e4b12d9038087c204"