Commit e582a8c86c722e14aa4b7380708b92aaa9fa34a2
1 parent
4a7c6a26
feedback message info
Showing
2 changed files
with
19 additions
and
6 deletions
Show diff stats
frontend/views/site/index.php
... | ... | @@ -575,7 +575,7 @@ $coordinates['lon'] = empty($settings->lon) ? 0 : $settings->lon; |
575 | 575 | составляет 0.1637 €/кВт∙ч для промышленных станций, установленных на крыше. |
576 | 576 | </div> |
577 | 577 | <form class="modal-form" method="POST" action="/action"> |
578 | - <input type="hidden" name="product_code" value="9000"> | |
578 | + <input type="hidden" id="product-code" name="product_code" value="9000"> | |
579 | 579 | <div class="product-counter"> |
580 | 580 | <label class="kb-input"> |
581 | 581 | <div class="product-counter__label">Количество</div> |
... | ... | @@ -597,7 +597,7 @@ $coordinates['lon'] = empty($settings->lon) ? 0 : $settings->lon; |
597 | 597 | <input type="tel" name="phone_number" autocomplete="off" required> |
598 | 598 | </label> |
599 | 599 | <div class="submit-button-wr"> |
600 | - <button type="submit" class="btn big-yellow">Отправить</button> | |
600 | + <button id="order-product" type="submit" class="btn big-yellow">Отправить</button> | |
601 | 601 | </div> |
602 | 602 | </div> |
603 | 603 | </form> | ... | ... |
frontend/web/js/product.js
1 | 1 | var phoneInput = document.querySelector('#cardProduct [type="tel"]'); |
2 | 2 | var counter = document.querySelector('#cardProduct .product-counter__input'); |
3 | 3 | var price = 0; |
4 | +$('#order-product').click(function (e){ | |
5 | + e.preventDefault(); | |
6 | + var message='Сума: '; | |
7 | + message += $('#cardProduct .product-counter__value').text(); | |
8 | + message +='\nКод товара: ' + $('#product-code').val(); | |
9 | + message +='\nКількість: ' + counter.querySelector('input').value; | |
10 | + console.log(message + phoneInput.value); | |
11 | + var phone = '+38' + phoneInput.value; | |
12 | + if(phone.length===17){ | |
13 | + console.log('good') | |
14 | + } | |
15 | +}) | |
4 | 16 | if (phoneInput) { |
5 | 17 | phoneInput.addEventListener('input', phoneHandleInput); |
6 | 18 | } |
... | ... | @@ -11,12 +23,15 @@ $('#cardProduct').on('show.bs.modal', function (e) { |
11 | 23 | var itemPrice = counter.parentElement.querySelector('.product-counter__value'); |
12 | 24 | itemPrice.innerHTML = `${price} ${itemPrice.dataset.currency}`; |
13 | 25 | counter.querySelector('input').value = 1; |
26 | + var sku = button.data('sku'); | |
27 | + $('#product-code').val(sku); | |
28 | + $('#cardProduct .product-code').text('Код товара ' + sku); | |
14 | 29 | }) |
30 | + | |
15 | 31 | if(counter){ |
16 | 32 | counterFunc(counter); |
17 | 33 | } |
18 | 34 | |
19 | - | |
20 | 35 | function phoneHandleInput(e) { |
21 | 36 | e.target.value = phoneMasks(e.target.value); |
22 | 37 | } |
... | ... | @@ -24,7 +39,7 @@ function phoneHandleInput(e) { |
24 | 39 | function phoneMasks(phone) { |
25 | 40 | return phone.replace(/\D/g, '') |
26 | 41 | .replace(/^(\d)/, '($1') |
27 | - .replace(/^(\(\d{3})(\d)/, '$1) $2') | |
42 | + .replace(/^(\(\d{3})(\d)/, '$1)$2') | |
28 | 43 | .replace(/(\d{3})(\d{1,7})/, '$1-$2') |
29 | 44 | .replace(/(-\d{2})(\d{1,7})/, '$1-$2') |
30 | 45 | .replace(/(-\d{2})\d+?$/, '$1'); |
... | ... | @@ -56,9 +71,7 @@ function counterFunc(counter) { |
56 | 71 | function increment(e) { |
57 | 72 | e.preventDefault(); |
58 | 73 | var value = Number(counter.querySelector('input').value); |
59 | - //console.log(value); | |
60 | 74 | counter.querySelector('input').value = value + 1; |
61 | - console.log(value); | |
62 | 75 | updateSummary(); |
63 | 76 | } |
64 | 77 | ... | ... |