Commit e582a8c86c722e14aa4b7380708b92aaa9fa34a2

Authored by Volodymyr
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,7 +575,7 @@ $coordinates['lon'] = empty($settings->lon) ? 0 : $settings->lon;
575 составляет 0.1637 €/кВт∙ч для промышленных станций, установленных на крыше. 575 составляет 0.1637 €/кВт∙ч для промышленных станций, установленных на крыше.
576 </div> 576 </div>
577 <form class="modal-form" method="POST" action="/action"> 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 <div class="product-counter"> 579 <div class="product-counter">
580 <label class="kb-input"> 580 <label class="kb-input">
581 <div class="product-counter__label">Количество</div> 581 <div class="product-counter__label">Количество</div>
@@ -597,7 +597,7 @@ $coordinates[&#39;lon&#39;] = empty($settings-&gt;lon) ? 0 : $settings-&gt;lon; @@ -597,7 +597,7 @@ $coordinates[&#39;lon&#39;] = empty($settings-&gt;lon) ? 0 : $settings-&gt;lon;
597 <input type="tel" name="phone_number" autocomplete="off" required> 597 <input type="tel" name="phone_number" autocomplete="off" required>
598 </label> 598 </label>
599 <div class="submit-button-wr"> 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 </div> 601 </div>
602 </div> 602 </div>
603 </form> 603 </form>
frontend/web/js/product.js
1 var phoneInput = document.querySelector('#cardProduct [type="tel"]'); 1 var phoneInput = document.querySelector('#cardProduct [type="tel"]');
2 var counter = document.querySelector('#cardProduct .product-counter__input'); 2 var counter = document.querySelector('#cardProduct .product-counter__input');
3 var price = 0; 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 if (phoneInput) { 16 if (phoneInput) {
5 phoneInput.addEventListener('input', phoneHandleInput); 17 phoneInput.addEventListener('input', phoneHandleInput);
6 } 18 }
@@ -11,12 +23,15 @@ $(&#39;#cardProduct&#39;).on(&#39;show.bs.modal&#39;, function (e) { @@ -11,12 +23,15 @@ $(&#39;#cardProduct&#39;).on(&#39;show.bs.modal&#39;, function (e) {
11 var itemPrice = counter.parentElement.querySelector('.product-counter__value'); 23 var itemPrice = counter.parentElement.querySelector('.product-counter__value');
12 itemPrice.innerHTML = `${price} ${itemPrice.dataset.currency}`; 24 itemPrice.innerHTML = `${price} ${itemPrice.dataset.currency}`;
13 counter.querySelector('input').value = 1; 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 if(counter){ 31 if(counter){
16 counterFunc(counter); 32 counterFunc(counter);
17 } 33 }
18 34
19 -  
20 function phoneHandleInput(e) { 35 function phoneHandleInput(e) {
21 e.target.value = phoneMasks(e.target.value); 36 e.target.value = phoneMasks(e.target.value);
22 } 37 }
@@ -24,7 +39,7 @@ function phoneHandleInput(e) { @@ -24,7 +39,7 @@ function phoneHandleInput(e) {
24 function phoneMasks(phone) { 39 function phoneMasks(phone) {
25 return phone.replace(/\D/g, '') 40 return phone.replace(/\D/g, '')
26 .replace(/^(\d)/, '($1') 41 .replace(/^(\d)/, '($1')
27 - .replace(/^(\(\d{3})(\d)/, '$1) $2') 42 + .replace(/^(\(\d{3})(\d)/, '$1)$2')
28 .replace(/(\d{3})(\d{1,7})/, '$1-$2') 43 .replace(/(\d{3})(\d{1,7})/, '$1-$2')
29 .replace(/(-\d{2})(\d{1,7})/, '$1-$2') 44 .replace(/(-\d{2})(\d{1,7})/, '$1-$2')
30 .replace(/(-\d{2})\d+?$/, '$1'); 45 .replace(/(-\d{2})\d+?$/, '$1');
@@ -56,9 +71,7 @@ function counterFunc(counter) { @@ -56,9 +71,7 @@ function counterFunc(counter) {
56 function increment(e) { 71 function increment(e) {
57 e.preventDefault(); 72 e.preventDefault();
58 var value = Number(counter.querySelector('input').value); 73 var value = Number(counter.querySelector('input').value);
59 - //console.log(value);  
60 counter.querySelector('input').value = value + 1; 74 counter.querySelector('input').value = value + 1;
61 - console.log(value);  
62 updateSummary(); 75 updateSummary();
63 } 76 }
64 77