diff --git "a/app.py" "b/app.py" --- "a/app.py" +++ "b/app.py" @@ -282,6 +282,13 @@ def catalog(): display: block; margin-top: 5px; } + .product-price .discount { + font-size: 0.9rem; + color: #2ecc71; + font-weight: 500; + display: block; + margin-top: 5px; + } .product-description { font-size: 0.85rem; color: #666; @@ -322,6 +329,23 @@ def catalog(): background-color: #27ae60; box-shadow: 0 4px 15px rgba(46, 204, 113, 0.4); } + .favorite-button { + position: absolute; + top: 10px; + left: 10px; + background: none; + border: none; + font-size: 1.5rem; + cursor: pointer; + color: #666; + transition: color 0.3s ease; + } + .favorite-button.favorited { + color: #e63946; + } + .favorite-button:hover { + color: #e63946; + } #cart-button { position: fixed; bottom: 80px; @@ -474,6 +498,17 @@ def catalog(): font-size: 0.75rem; font-weight: 500; } + .discount-badge { + position: absolute; + top: 40px; + right: 10px; + background-color: #2ecc71; + color: white; + padding: 5px 10px; + border-radius: 15px; + font-size: 0.75rem; + font-weight: 500; + } @@ -500,6 +535,9 @@ def catalog(): data-name="{{ product['name']|lower }}" data-description="{{ product['description']|lower }}" data-category="{{ product.get('category', 'Без категории') }}"> + {% if product.get('photos') and product['photos']|length > 0 %}
Опт от {{ product['min_wholesale'] }} {% endif %} + {% if product.get('discount') %} + Скидка {{ product['discount'] }}% + {% endif %}

{{ product['name'] }}

+ {% if product.get('discount') %} + {{ product['price'] }} с + {{ (product['price'] * (1 - product['discount'] / 100))|round(2) }} с + Скидка: {{ product['discount'] }}% + {% else %} {{ product['price'] }} с + {% endif %} {% if product.get('wholesale_price') and product.get('min_wholesale') %} Опт: {{ product['wholesale_price'] }} с {% endif %} @@ -557,6 +604,15 @@ def catalog():
+ + + @@ -569,6 +625,18 @@ def catalog(): Каталог + + + Избранное + + + + Скидки + + + + Адрес + WhatsApp @@ -661,11 +729,17 @@ def catalog(): const cartItemId = `${product.name}-${color}`; const existingItem = cart.find(item => item.id === cartItemId); - const priceToUse = (product.min_wholesale && quantity >= product.min_wholesale) ? product.wholesale_price : product.price; + let priceToUse = product.price; + if (product.discount) { + priceToUse = product.price * (1 - product.discount / 100); + } + if (product.min_wholesale && quantity >= product.min_wholesale) { + priceToUse = product.wholesale_price; + } if (existingItem) { existingItem.quantity += quantity; - existingItem.price = (existingItem.quantity >= product.min_wholesale) ? product.wholesale_price : product.price; + existingItem.price = (existingItem.quantity >= product.min_wholesale) ? product.wholesale_price : (product.discount ? product.price * (1 - product.discount / 100) : product.price); } else { cart.push({ id: cartItemId, @@ -674,6 +748,7 @@ def catalog(): retail_price: product.price, wholesale_price: product.wholesale_price, min_wholesale: product.min_wholesale, + discount: product.discount, photo: product.photos && product.photos.length > 0 ? product.photos[0] : '', quantity: quantity, color: color @@ -705,7 +780,7 @@ def catalog():
${item.name}

${item.price} с × ${item.quantity} (Цвет: ${item.color})

-

${item.quantity >= item.min_wholesale ? 'Оптовая цена' : 'Розничная цена'}

+

${item.quantity >= item.min_wholesale ? 'Оптовая цена' : (item.discount ? 'Скидка ' + item.discount + '%' : 'Розничная цена')}

${itemTotal} с @@ -740,6 +815,34 @@ def catalog(): updateCartButton(); } + function toggleFavorite(index) { + let favorites = JSON.parse(localStorage.getItem('favorites') || '[]'); + const productId = index.toString(); + const favoriteButton = document.querySelector(`.favorite-button[onclick="event.stopPropagation(); toggleFavorite(${index})"]`); + if (favorites.includes(productId)) { + favorites = favorites.filter(id => id !== productId); + favoriteButton.classList.remove('favorited'); + } else { + favorites.push(productId); + favoriteButton.classList.add('favorited'); + } + localStorage.setItem('favorites', JSON.stringify(favorites)); + } + + function loadFavorites() { + const favorites = JSON.parse(localStorage.getItem('favorites') || '[]'); + document.querySelectorAll('.favorite-button').forEach(button => { + const index = button.getAttribute('onclick').match(/\d+/)[0]; + if (favorites.includes(index)) { + button.classList.add('favorited'); + } + }); + } + + function openAddressModal() { + document.getElementById('addressModal').style.display = 'block'; + } + window.onclick = function(event) { if (event.target.className === 'modal') event.target.style.display = "none"; } @@ -767,6 +870,7 @@ def catalog(): } updateCartButton(); + loadFavorites(); @@ -931,6 +1035,15 @@ def categories_page(): + + +