Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions basket.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Rollerskates</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="wraper">
<div class="header">
<div id="logo">
<img src="image/logo_2.png" alt="logo">
</div>
<div class="main_menu">
<ul class="menulist">
<li><a href="index.html">Главная</a></li>
<li><a href="catalog.html">Каталог</a></li>
<li><a href="contacts.html">Контакты</a></li>
</ul>
</div>
</div>
<hr>
<h1>Ваша корзина</h1>
<div class="basket_container">
<div class="basket_summary">
<p>
Всего товаров: <span class="total_quantity"></span><br>
Общая стоимость: <span class="total_price"></span> руб.
</p>
</div>
<div class="basket_list">

</div>
<a href="#" class="make_order">Перейти к оформлению</a>
</div>
<div class="forfooter"></div>
</div>
<div class="footer">
<hr>
<p><i>Все права защищены &copy;</i></p>
</div>
<script src="basket_script.js" type="text/javascript"></script>
</body>
</html>
91 changes: 91 additions & 0 deletions basket_script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
'use strict'


const buyings = [
{ title: 'Rollerblade Twister Edge', price: 150, quantity: 2, link: 'twister_edge' },
{ title: 'K2 Alexis 80 PRO', price: 50, quantity: 1, link: 'k2_alexis_80_pro' },
];


// класс Элемента корзины
class BasketItem {
constructor(title, price, quantity, link) {
this.title = title;
this.price = price;
this.link = link;
this.quantity = quantity;
}

render() {
return `<div class="basket_record">
<img src="image/${this.link}.jpg" alt="product" height="130px" width="120px">
<span class="product_name">${this.title}</span>
<span class="product_price">${this.price}&nbspруб</span>
<input type="number" name="quantity" min="0" value="${this.quantity}">
<span class="product_cost">${this.quantity*this.price}&nbspруб</span>
<div class="basket_delete">
<a href="#">
удалить
</a>
</div>
</div>`;
}
}


// класс Корзины товаров
class BasketList {
constructor() {
this.buyings = [];
}

_getBuyings() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Смысл понятен, но я думаю, что для этого метода стоит выбрать другое название. Это не просто правила хорошего тона, но и вообще признак профессионализма.

this.buyings = buyings;
}

showSummary() {
let totalPrice = 0;
let totalQuantity = 0;

this.buyings.forEach(({ price, quantity }) => {
totalPrice += price*quantity;
totalQuantity += quantity;
});

document.querySelector('.total_quantity').innerHTML = `<i>${totalQuantity}</i>`;
document.querySelector('.total_price').innerHTML = `<i>${totalPrice}</i>`;
}

render() {
this._getBuyings();
let html = '';

this.buyings.forEach(({ title, price, quantity, link }) => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Отлично.

const basketItem = new BasketItem(title, price, quantity, link);
html += basketItem.render();
});

document.querySelector('.basket_list').innerHTML = html;

this.showSummary();
}

// добавление товара
add() {

}

// удаление товара
delete() {

}

// изменение количества товара внутри корзины
change() {

}
}

const list = new BasketList();

list.render();
47 changes: 47 additions & 0 deletions catalog.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Rollerskates</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="wraper">
<div class="header">
<div id="logo">
<img src="image/logo_2.png" alt="logo">
</div>
<div class="main_menu">
<ul class="menulist">
<li><a href="index.html">Главная</a></li>
<li><a href="#">Каталог</a></li>
<li><a href="contacts.html">Контакты</a></li>
</ul>
<div class="cart">
<a href="basket.html" class = "cart-button" >Корзина</a>
</div>
</div>
</div>
<hr>
<h1>Роликовые коньки</h1>
<div class="catalog-menu">
<ul>
<li class="catalog-menu-list catalog-active"><a href="#" class="catalog-link">ВСЕ</a></li>
<li class="catalog-menu-list"><a href="#" class="catalog-link">ФИТНЕС</a></li>
<li class="catalog-menu-list"><a href="#" class="catalog-link">ФРИСКЕЙТ</a></li>
<li class="catalog-menu-list"><a href="#" class="catalog-link">АГРЕССИВ</a></li>
<li class="catalog-menu-list"><a href="#" class="catalog-link">ДЕТСКИЕ</a></li>
</ul>
</div>
<div class="catalog">

</div>
<div class="forfooter"></div>
</div>
<div class="footer">
<hr>
<p><i>Все права защищены &copy;</i></p>
</div>
<script src="catalog_script.js" type="text/javascript"></script>
</body>
</html>
68 changes: 68 additions & 0 deletions catalog_script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
'use strict'


const products = [
{ title: 'Rollerblade Twister Edge', price: 150, link: 'twister_edge' },
{ title: 'K2 Alexis 80 PRO', price: 50, link: 'k2_alexis_80_pro' },
{ title: 'FRX 80', price: 350, link: 'seba_frx_80' },
{ title: 'Rollerblade Macroblade', price: 250, link: 'rollerblade_macroblade_84W' },
];


class ProductItem {
constructor(title, price, link) {
this.title = title;
this.price = price;
this.link = link;
}

render() {
return `<div class="product_preview">
<div class="preview_image">
<a href="catalog/${this.link}.html">
<img src="image/${this.link}.jpg" alt="" width="120" height="120">
</a>
</div><br>
<a href="catalog/${this.link}.html">${this.title}</a>
<p>${this.price} руб.</p>
</div>`;
}
}


class ProductsList {
constructor() {
this.products = [];
}

_getProducts() {
this.products = products;
}

render() {
this._getProducts();
let html = '';

this.products.forEach(({ title, price, link }) => {
const productItem = new ProductItem(title, price, link);
html += productItem.render();
});

document.querySelector('.catalog').innerHTML = html;
}

total() {
let total = 0;
this.products.forEach(({ price }) => {
total += price;
});

console.log('Сумма всех цен: ', total);
}
}


const list = new ProductsList();

list.render();
list.total();
Binary file added image/heder.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added image/k2_alexis_80_pro.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added image/logo_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added image/rollerblade_macroblade_84W.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added image/seba_frx_80.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added image/twister_edge.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading