diff --git a/components/FeedbackForm.vue b/components/FeedbackForm.vue index 19731d0..49dc66e 100644 --- a/components/FeedbackForm.vue +++ b/components/FeedbackForm.vue @@ -4,65 +4,30 @@
-

- Запрос стоимости услуг -

+

Запрос стоимости услуг

-
+
- +
- +
- +
- +

Отправляя эту форму вы соглашаетесь на обработку ваших @@ -71,13 +36,7 @@

- +
@@ -97,36 +56,40 @@ import { BFormInput } from 'bootstrap-vue' export default { components: { - BFormInput + BFormInput, // BFormTextarea }, props: { id: { type: String, - default: 'feedback-form' + default: 'feedback-form', }, isSubmitted: { type: Boolean, - default: false - } + default: false, + }, }, - data () { + data() { return { name: '', subject: '', contact: '', - text: '' + text: '', } }, computed: { - submitDisabled () { - return this.name.length < 1 || this.subject.length < 3 || this.contact.length < 6 + submitDisabled() { + return ( + this.name.length < 1 || + this.subject.length < 3 || + this.contact.length < 6 + ) }, - utm () { + utm() { const { query } = this.$route const res = {} @@ -136,14 +99,74 @@ export default { } } return res - } + }, }, methods: { - onSubmit () { - // eslint-disable-next-line no-undef - ym(45245817, 'reachGoal', 'zayavka') - } + handleSubmit(evt) { + evt.preventDefault(); + + const form = evt.target; + const data = new FormData(form); + s + leadgets('lead', data, (response) => { + if (response.status === 1) { + ym(45245817, 'reachGoal', 'zayavka'); + + this.name = ''; + this.subject = ''; + this.contact = ''; + this.text = ''; + + this.isSubmitted = true; + + } + }); + }, + }, + + mounted() { + // Подключение сервиса leadgets + (function () { + const leadgets = window.leadgets = window.leadgets || function () { + (leadgets.q = leadgets.q || []).push(arguments); + }; + const cdnUrl = 'https://cdn.leadgets.ru/'; + const scriptVersion = 'v1.js'; + + const elements = { + link: [{ + href: cdnUrl, + rel: "dns-prefetch" + }, + { + href: cdnUrl, + rel: "preconnect" + }, + { + href: cdnUrl + scriptVersion, + as: "script", + rel: "preload" + } + ], + script: [{ + src: cdnUrl + scriptVersion, + async: true + }] + }; + + for (const [tagName, tagValues] of Object.entries(elements)) { + for (const tagAttributes of tagValues) { + const element = document.createElement(tagName); + for (const [attribute, value] of Object.entries(tagAttributes)) { + element.setAttribute(attribute, value); + } + document.head.appendChild(element); + } + } + + leadgets('init', '9d0984a073794a76b3b6c13fbed6cd67'); + })(); } } @@ -161,11 +184,9 @@ export default { overflow: hidden; &::before { - background-image: linear-gradient( - to right, - $link-color 0%, - $dark-blue 100% - ); + background-image: linear-gradient(to right, + $link-color 0%, + $dark-blue 100%); content: ''; display: block; position: absolute; @@ -211,4 +232,4 @@ export default { width: 100%; display: block; } - + \ No newline at end of file diff --git a/components/FeedbackFormInline.vue b/components/FeedbackFormInline.vue index da19979..4a403e0 100644 --- a/components/FeedbackFormInline.vue +++ b/components/FeedbackFormInline.vue @@ -7,55 +7,22 @@

Оставить заявку

-
+
- +
- +
- +
- +
- +

@@ -97,7 +64,7 @@ export default { } }, - data () { + data() { return { name: '', email: '', @@ -107,11 +74,11 @@ export default { }, computed: { - submitDisabled () { + submitDisabled() { return this.name.length < 1 || this.contact.length < 6 }, - utm () { + utm() { const { query } = this.$route const res = {} @@ -125,10 +92,69 @@ export default { }, methods: { - onSubmit () { - // eslint-disable-next-line no-undef - ym(45245817, 'reachGoal', 'zayavka') + handleSubmit(evt) { + evt.preventDefault(); + + const form = evt.target; + const data = new FormData(form); + + leadgets('lead', data, (response) => { + if (response.status === 1) { + ym(45245817, 'reachGoal', 'zayavka'); + + this.name = ''; + this.email = ''; + this.contact = ''; + this.text = ''; + + this.isSubmitted = true; + } + }); } + }, + + mounted() { + // Подключение сервиса leadgets + (function () { + const leadgets = window.leadgets = window.leadgets || function () { + (leadgets.q = leadgets.q || []).push(arguments); + }; + const cdnUrl = 'https://cdn.leadgets.ru/'; + const scriptVersion = 'v1.js'; + + const elements = { + link: [{ + href: cdnUrl, + rel: "dns-prefetch" + }, + { + href: cdnUrl, + rel: "preconnect" + }, + { + href: cdnUrl + scriptVersion, + as: "script", + rel: "preload" + } + ], + script: [{ + src: cdnUrl + scriptVersion, + async: true + }] + }; + + for (const [tagName, tagValues] of Object.entries(elements)) { + for (const tagAttributes of tagValues) { + const element = document.createElement(tagName); + for (const [attribute, value] of Object.entries(tagAttributes)) { + element.setAttribute(attribute, value); + } + document.head.appendChild(element); + } + } + + leadgets('init', '9d0984a073794a76b3b6c13fbed6cd67'); + })(); } } @@ -146,11 +172,9 @@ export default { overflow: hidden; &::before { - background-image: linear-gradient( - to right, - $link-color 0%, - $dark-blue 100% - ); + background-image: linear-gradient(to right, + $link-color 0%, + $dark-blue 100%); content: ''; display: block; position: absolute; @@ -207,4 +231,4 @@ export default { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); } } - + \ No newline at end of file