deted non-unique ids

This commit is contained in:
Sergey Yarkov 2019-12-11 21:56:35 +03:00
parent 9d5e785a75
commit 99290c29ca
6 changed files with 23 additions and 24 deletions

View File

@ -27,7 +27,6 @@ document.addEventListener('DOMContentLoaded', function () {
M.Collapsible.init(document.querySelectorAll('.collapsible'));
M.Modal.init(document.querySelectorAll('.modal'));
//- active временно!!!!!
const currentPage = document.querySelector('#currentPage').dataset.current;
const pages = Array.from(document.querySelectorAll('.collapsible li'));
pages.forEach(function (page) {

File diff suppressed because one or more lines are too long

View File

@ -20,17 +20,17 @@
b Сумма к оплате
span
b#totalPrice 0 ₽
form#purchaseInfo.modal-content__purchase.hide
form.modal-content__purchase.hide
span Информация необходимая для оплаты
.email-field
label(for='email') Ваш E-mail
input#email(required='' type='text' name='email')
input(required='' type='text' name='email')
.phone-field
label(for="phone") Номер QIWI
input#phone(required='' type='text' name='phone')
input(required='' type='text' name='phone')
.payment-field
label(for='payment') Способ оплаты
select#payment(name='payment')
select(name='payment')
option(value='qiwi' data-icon='../img/payments-icons/qiwi.svg') QIWI
button.purchase-btn.waves-effect.btn Перейти к оплате
// Cart Modal END

View File

@ -9,20 +9,20 @@
h4.small-title Оплатить товар
span#payClose.cart-close
i.material-icons close
form#purchaseInfo(action='#')
form(action='#')
.modal-content__fields
.title-field
label(for='title') Наименование
input#title(name='title' readonly)
input(name='title' readonly)
.email-field
label(for='email') Ваш E-mail
input#email(required='' type='text' name='email')
input(required='' type='text' name='email')
.phone-field
label(for="phone") Номер QIWI
input#phone(required='' type='text' name='phone')
input(required='' type='text' name='phone')
.payment-field
label(for='payment') Способ оплаты
select#payment(name='payment')
select(name='payment')
option(value='qiwi' data-icon='../img/payments-icons/qiwi.svg') QIWI
.modal-content__purchase
button.purchase-btn.waves-effect.btn(type='submit' href='#') Перейти к оплате

View File

@ -19,7 +19,7 @@ export class CartModal extends Modal {
openHandler() {
this.removeItem != null ? this.list.addEventListener('click', this.removeItem.bind(this)) : false
this.makePay != null ? this.$el.querySelector('#purchaseInfo').addEventListener('submit', this.makePay.bind(this)) : false;
this.makePay != null ? this.$el.querySelector('form').addEventListener('submit', this.makePay.bind(this)) : false;
this.list.innerHTML = '';
this.insertItems(this.list);
}
@ -30,9 +30,9 @@ export class CartModal extends Modal {
if (items.length == 0) {
list.innerHTML = '<p style="text-align:center;padding:15px;">Вы не добавили ни один товар</p>';
this.$el.querySelector('#purchaseInfo').classList.add('hide');
this.$el.querySelector('form').classList.add('hide');
} else {
this.$el.querySelector('#purchaseInfo').classList.remove('hide');
this.$el.querySelector('form').classList.remove('hide');
}
items.forEach(item => this.list.innerHTML += `<div data-id="${item.id}" data-title="${item.title}" data-price="${item.price}" data-count="1" class="modal-content__item"><div class="modal-content__title"><a href="/product/${item.id}"><b>${item.title}</b></a><br><span class="in-stock">В наличии: ${item.count} (шт)</span></div><div class="modal-content__right"><span id="price">${parseFloat(item.price).toFixed(2)}₽</span></div><div class="modal-content__remove"><span><i data-id="${item.id}" class="material-icons" id="removeItem">close</i></span></div></div>`);
@ -77,9 +77,9 @@ export class CartModal extends Modal {
let totalPrice = 0;
payInfo.items.forEach(item => totalPrice += parseFloat(item.price));
payInfo.totalPrice = Math.round(totalPrice * 100) / 100;
payInfo.payMethod = this.$el.querySelector('.payment-field #payment').value;
payInfo.phone = this.$el.querySelector('.phone-field #phone').value;
payInfo.email = this.$el.querySelector('.email-field #email').value;
payInfo.payMethod = this.$el.querySelector('.payment-field input').value;
payInfo.phone = this.$el.querySelector('.phone-field input').value;
payInfo.email = this.$el.querySelector('.email-field input').value;
console.log('Pay info:', payInfo);
}

View File

@ -10,16 +10,16 @@ export class PayModal extends Modal {
}
closeHandler() {
this.$el.querySelector('#purchaseInfo').onsubmit = null;
this.$el.querySelector('form').onsubmit = null;
}
openHandler(e) {
if (e.target.id === 'payOpen') {
const targetInfo = e.target.parentNode.dataset;
this.$el.querySelector('.title-field #title').value = targetInfo.title;
this.$el.querySelector('.title-field input').value = targetInfo.title;
this.show();
this.$el.querySelector('#purchaseInfo').onsubmit = (e) => {
this.$el.querySelector('form').onsubmit = (e) => {
this.makePay(e, targetInfo);
}
} else {
@ -37,9 +37,9 @@ export class PayModal extends Modal {
}],
totalPrice: parseFloat(info.price)
}
payInfo.payMethod = this.$el.querySelector('.payment-field #payment').value;
payInfo.phone = this.$el.querySelector('.phone-field #phone').value;
payInfo.email = this.$el.querySelector('.email-field #email').value;
payInfo.payMethod = this.$el.querySelector('.payment-field input').value;
payInfo.phone = this.$el.querySelector('.phone-field input').value;
payInfo.email = this.$el.querySelector('.email-field input').value;
console.log('Pay info: ', payInfo);
}