Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -117,12 +117,22 @@ def catalog():
|
|
| 117 |
max-width: 1200px;
|
| 118 |
margin: 0 auto;
|
| 119 |
}
|
| 120 |
-
|
| 121 |
text-align: center;
|
| 122 |
-
color: #2c3e50;
|
| 123 |
margin-bottom: 40px;
|
| 124 |
-
|
| 125 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 126 |
}
|
| 127 |
.products-grid {
|
| 128 |
display: grid;
|
|
@@ -355,10 +365,12 @@ def catalog():
|
|
| 355 |
max-width: 120px;
|
| 356 |
max-height: 120px;
|
| 357 |
}
|
| 358 |
-
|
| 359 |
-
font-size: 1.8em;
|
| 360 |
margin-bottom: 20px;
|
| 361 |
}
|
|
|
|
|
|
|
|
|
|
| 362 |
.product h2 {
|
| 363 |
font-size: 0.9em;
|
| 364 |
}
|
|
@@ -377,10 +389,12 @@ def catalog():
|
|
| 377 |
</head>
|
| 378 |
<body>
|
| 379 |
<div class="container">
|
| 380 |
-
<
|
| 381 |
-
|
|
|
|
|
|
|
| 382 |
{% for product in products %}
|
| 383 |
-
<div class="product">
|
| 384 |
{% if product.get('photos') and product['photos']|length > 0 %}
|
| 385 |
<div class="product-image">
|
| 386 |
<img src="https://huggingface.co/datasets/{{ repo_id }}/resolve/main/photos/{{ product['photos'][0] }}"
|
|
@@ -389,7 +403,7 @@ def catalog():
|
|
| 389 |
</div>
|
| 390 |
{% endif %}
|
| 391 |
<h2>{{ product['name'] }}</h2>
|
| 392 |
-
<div class="product-price">{{ product['price'] }}
|
| 393 |
<p class="product-description">{{ product['description'][:100] }}{% if product['description']|length > 100 %}...{% endif %}</p>
|
| 394 |
<button class="product-button" onclick="openModal({{ loop.index0 }})">Подробнее</button>
|
| 395 |
<button class="product-button add-to-cart" onclick="openQuantityModal({{ loop.index0 }})">В корзину</button>
|
|
@@ -423,7 +437,7 @@ def catalog():
|
|
| 423 |
<h2>Корзина</h2>
|
| 424 |
<div id="cartContent"></div>
|
| 425 |
<div style="margin-top: 20px; text-align: right;">
|
| 426 |
-
<strong>Итого: <span id="cartTotal">0</span
|
| 427 |
<button class="product-button clear-cart" onclick="clearCart()">Очистить корзину</button>
|
| 428 |
<button class="product-button order-button" onclick="orderViaWhatsApp()">Заказать</button>
|
| 429 |
</div>
|
|
@@ -561,10 +575,10 @@ def catalog():
|
|
| 561 |
` : ''}
|
| 562 |
<div>
|
| 563 |
<strong>${item.name}</strong>
|
| 564 |
-
<p>${item.price}
|
| 565 |
</div>
|
| 566 |
</div>
|
| 567 |
-
<span>${itemTotal}
|
| 568 |
</div>
|
| 569 |
`;
|
| 570 |
}).join('');
|
|
@@ -586,9 +600,9 @@ def catalog():
|
|
| 586 |
cart.forEach((item, index) => {
|
| 587 |
const itemTotal = item.price * item.quantity;
|
| 588 |
total += itemTotal;
|
| 589 |
-
orderText += `${index + 1}. ${item.name} - ${item.price}
|
| 590 |
});
|
| 591 |
-
orderText += `Итого: ${total}
|
| 592 |
|
| 593 |
const whatsappUrl = `https://api.whatsapp.com/send?phone=996500398754&text=${orderText}`;
|
| 594 |
window.open(whatsappUrl, '_blank');
|
|
@@ -609,6 +623,23 @@ def catalog():
|
|
| 609 |
}
|
| 610 |
}
|
| 611 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 612 |
console.log("Инициализация страницы, товары:", products);
|
| 613 |
updateCartButton();
|
| 614 |
</script>
|
|
@@ -647,7 +678,7 @@ def product_detail(index):
|
|
| 647 |
<div class="swiper-button-next"></div>
|
| 648 |
<div class="swiper-button-prev"></div>
|
| 649 |
</div>
|
| 650 |
-
<p><strong>Цена:</strong> {{ product['price'] }}
|
| 651 |
<p><strong>Описание:</strong> {{ product['description'] }}</p>
|
| 652 |
</div>
|
| 653 |
'''
|
|
@@ -876,7 +907,7 @@ def admin():
|
|
| 876 |
{% for product in products %}
|
| 877 |
<div class="product-item">
|
| 878 |
<h3>{{ product['name'] }}</h3>
|
| 879 |
-
<p><strong>Цена:</strong> {{ product['price'] }}
|
| 880 |
<p><strong>Описание:</strong> {{ product['description'] }}</p>
|
| 881 |
{% if product.get('photos') and product['photos']|length > 0 %}
|
| 882 |
<div style="background-color: #fff; width: 100px; height: 100px; display: flex; justify-content: center; align-items: center;">
|
|
|
|
| 117 |
max-width: 1200px;
|
| 118 |
margin: 0 auto;
|
| 119 |
}
|
| 120 |
+
.search-container {
|
| 121 |
text-align: center;
|
|
|
|
| 122 |
margin-bottom: 40px;
|
| 123 |
+
}
|
| 124 |
+
#search-input {
|
| 125 |
+
width: 80%;
|
| 126 |
+
max-width: 500px;
|
| 127 |
+
padding: 10px;
|
| 128 |
+
font-size: 1em;
|
| 129 |
+
border: 1px solid #ddd;
|
| 130 |
+
border-radius: 5px;
|
| 131 |
+
outline: none;
|
| 132 |
+
}
|
| 133 |
+
#search-input:focus {
|
| 134 |
+
border-color: #3498db;
|
| 135 |
+
box-shadow: 0 0 5px rgba(52, 152, 219, 0.5);
|
| 136 |
}
|
| 137 |
.products-grid {
|
| 138 |
display: grid;
|
|
|
|
| 365 |
max-width: 120px;
|
| 366 |
max-height: 120px;
|
| 367 |
}
|
| 368 |
+
.search-container {
|
|
|
|
| 369 |
margin-bottom: 20px;
|
| 370 |
}
|
| 371 |
+
#search-input {
|
| 372 |
+
width: 90%;
|
| 373 |
+
}
|
| 374 |
.product h2 {
|
| 375 |
font-size: 0.9em;
|
| 376 |
}
|
|
|
|
| 389 |
</head>
|
| 390 |
<body>
|
| 391 |
<div class="container">
|
| 392 |
+
<div class="search-container">
|
| 393 |
+
<input type="text" id="search-input" placeholder="Поиск по названию или описанию...">
|
| 394 |
+
</div>
|
| 395 |
+
<div class="products-grid" id="products-grid">
|
| 396 |
{% for product in products %}
|
| 397 |
+
<div class="product" data-name="{{ product['name']|lower }}" data-description="{{ product['description']|lower }}">
|
| 398 |
{% if product.get('photos') and product['photos']|length > 0 %}
|
| 399 |
<div class="product-image">
|
| 400 |
<img src="https://huggingface.co/datasets/{{ repo_id }}/resolve/main/photos/{{ product['photos'][0] }}"
|
|
|
|
| 403 |
</div>
|
| 404 |
{% endif %}
|
| 405 |
<h2>{{ product['name'] }}</h2>
|
| 406 |
+
<div class="product-price">{{ product['price'] }}</div>
|
| 407 |
<p class="product-description">{{ product['description'][:100] }}{% if product['description']|length > 100 %}...{% endif %}</p>
|
| 408 |
<button class="product-button" onclick="openModal({{ loop.index0 }})">Подробнее</button>
|
| 409 |
<button class="product-button add-to-cart" onclick="openQuantityModal({{ loop.index0 }})">В корзину</button>
|
|
|
|
| 437 |
<h2>Корзина</h2>
|
| 438 |
<div id="cartContent"></div>
|
| 439 |
<div style="margin-top: 20px; text-align: right;">
|
| 440 |
+
<strong>Итого: <span id="cartTotal">0</span></strong>
|
| 441 |
<button class="product-button clear-cart" onclick="clearCart()">Очистить корзину</button>
|
| 442 |
<button class="product-button order-button" onclick="orderViaWhatsApp()">Заказать</button>
|
| 443 |
</div>
|
|
|
|
| 575 |
` : ''}
|
| 576 |
<div>
|
| 577 |
<strong>${item.name}</strong>
|
| 578 |
+
<p>${item.price} × ${item.quantity}</p>
|
| 579 |
</div>
|
| 580 |
</div>
|
| 581 |
+
<span>${itemTotal}</span>
|
| 582 |
</div>
|
| 583 |
`;
|
| 584 |
}).join('');
|
|
|
|
| 600 |
cart.forEach((item, index) => {
|
| 601 |
const itemTotal = item.price * item.quantity;
|
| 602 |
total += itemTotal;
|
| 603 |
+
orderText += `${index + 1}. ${item.name} - ${item.price} × ${item.quantity}%0A`;
|
| 604 |
});
|
| 605 |
+
orderText += `Итого: ${total}`;
|
| 606 |
|
| 607 |
const whatsappUrl = `https://api.whatsapp.com/send?phone=996500398754&text=${orderText}`;
|
| 608 |
window.open(whatsappUrl, '_blank');
|
|
|
|
| 623 |
}
|
| 624 |
}
|
| 625 |
|
| 626 |
+
// Поисковая строка
|
| 627 |
+
document.getElementById('search-input').addEventListener('input', function(e) {
|
| 628 |
+
const searchTerm = e.target.value.toLowerCase();
|
| 629 |
+
const productElements = document.querySelectorAll('.product');
|
| 630 |
+
|
| 631 |
+
productElements.forEach(product => {
|
| 632 |
+
const name = product.getAttribute('data-name');
|
| 633 |
+
const description = product.getAttribute('data-description');
|
| 634 |
+
|
| 635 |
+
if (name.includes(searchTerm) || description.includes(searchTerm)) {
|
| 636 |
+
product.style.display = 'flex';
|
| 637 |
+
} else {
|
| 638 |
+
product.style.display = 'none';
|
| 639 |
+
}
|
| 640 |
+
});
|
| 641 |
+
});
|
| 642 |
+
|
| 643 |
console.log("Инициализация страницы, товары:", products);
|
| 644 |
updateCartButton();
|
| 645 |
</script>
|
|
|
|
| 678 |
<div class="swiper-button-next"></div>
|
| 679 |
<div class="swiper-button-prev"></div>
|
| 680 |
</div>
|
| 681 |
+
<p><strong>Цена:</strong> {{ product['price'] }}</p>
|
| 682 |
<p><strong>Описание:</strong> {{ product['description'] }}</p>
|
| 683 |
</div>
|
| 684 |
'''
|
|
|
|
| 907 |
{% for product in products %}
|
| 908 |
<div class="product-item">
|
| 909 |
<h3>{{ product['name'] }}</h3>
|
| 910 |
+
<p><strong>Цена:</strong> {{ product['price'] }}</p>
|
| 911 |
<p><strong>Описание:</strong> {{ product['description'] }}</p>
|
| 912 |
{% if product.get('photos') and product['photos']|length > 0 %}
|
| 913 |
<div style="background-color: #fff; width: 100px; height: 100px; display: flex; justify-content: center; align-items: center;">
|