Fix: Add Lưu, Đơn hàng buttons + Thêm giỏ in AI search results
Browse files- index.html +40 -3
index.html
CHANGED
|
@@ -744,6 +744,8 @@ textarea.form-input{height:120px;resize:vertical}
|
|
| 744 |
</div>
|
| 745 |
|
| 746 |
<div class="quote-actions">
|
|
|
|
|
|
|
| 747 |
<button class="quote-btn" onclick="shareQuoteImage()" style="background:#25D366"><i class="fas fa-share-alt"></i> Chia sẻ ảnh</button>
|
| 748 |
<button class="quote-btn" onclick="shareQuoteLink()" style="background:#0068FF"><i class="fas fa-share-alt"></i> Chia sẻ báo giá</button>
|
| 749 |
<button class="quote-btn quote-btn-excel" onclick="exportExcel()"><i class="fas fa-file-excel"></i> Xuất Excel</button>
|
|
@@ -2601,11 +2603,14 @@ function _renderAIResultsToDiv(aiResult, container, query) {
|
|
| 2601 |
html += items.map(function(r, i) {
|
| 2602 |
var p = r.p, idx = r.idx;
|
| 2603 |
var brandColor = p.brand === 'Eurogold' ? '#c8102e' : (p.brand === 'Grob' ? '#2e7d32' : '#003f62');
|
| 2604 |
-
return '<div
|
|
|
|
| 2605 |
'<div class="pi" style="height:150px"><img src="' + (p.image || '') + '" alt="' + p.name + '" loading="lazy" onerror="this.style.display=\'none\'">' +
|
| 2606 |
'<span class="pi-badge">' + (p.cat || '') + '</span>' +
|
| 2607 |
'<span style="position:absolute;top:8px;right:8px;background:' + brandColor + ';color:#fff;padding:3px 7px;border-radius:5px;font-size:.55rem">' + (p.brand || '') + '</span></div>' +
|
| 2608 |
-
'<div class="pb"><div class="pn" style="font-size:.76rem">' + p.name + '</div><div class="pp">' + (p.price || 'Liên he') + '</div></div></div>'
|
|
|
|
|
|
|
| 2609 |
}).join('') + '</div>';
|
| 2610 |
}
|
| 2611 |
container.innerHTML = html;
|
|
@@ -2676,7 +2681,39 @@ window._vaiAddOrder = function(slug, btn) {
|
|
| 2676 |
if (!product) { var t = document.createElement('div'); t.style.cssText = 'position:fixed;bottom:24px;right:24px;background:#dc2626;color:#fff;padding:10px;border-radius:8px;z-index:9999'; t.textContent = 'SP "' + slug + '" khong tim thay'; document.body.appendChild(t); setTimeout(function(){t.remove();},2500); return; }
|
| 2677 |
if (window._showOrderPicker) { window._showOrderPicker(product, function(r) { if (r === 'ok') { btn.textContent = '✓ Da them'; btn.style.background = '#059669'; } setTimeout(function() { btn.textContent = '+ Don'; btn.style.background = '#003f62'; }, 2500); }); }
|
| 2678 |
};
|
| 2679 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2680 |
</html
|
| 2681 |
|
| 2682 |
</script><a href="https://bot.zaloplatforms.com/bots/4013442364902370344" target="_blank" rel="noopener" class="zalo-fab" title="Tư vấn qua Zalo"><img src="https://huggingface.co/spaces/bep40/V.AISTUDIO/resolve/main/logo/zalo-bot.png" alt="Zalo Bot"></a>
|
|
|
|
| 744 |
</div>
|
| 745 |
|
| 746 |
<div class="quote-actions">
|
| 747 |
+
<button class="quote-btn" onclick="saveQuote()" style="background:#059669"><i class="fas fa-save"></i> Lưu</button>
|
| 748 |
+
<button class="quote-btn" onclick="createOrder()" style="background:#0068FF"><i class="fas fa-shopping-cart"></i> Đơn hàng</button>
|
| 749 |
<button class="quote-btn" onclick="shareQuoteImage()" style="background:#25D366"><i class="fas fa-share-alt"></i> Chia sẻ ảnh</button>
|
| 750 |
<button class="quote-btn" onclick="shareQuoteLink()" style="background:#0068FF"><i class="fas fa-share-alt"></i> Chia sẻ báo giá</button>
|
| 751 |
<button class="quote-btn quote-btn-excel" onclick="exportExcel()"><i class="fas fa-file-excel"></i> Xuất Excel</button>
|
|
|
|
| 2603 |
html += items.map(function(r, i) {
|
| 2604 |
var p = r.p, idx = r.idx;
|
| 2605 |
var brandColor = p.brand === 'Eurogold' ? '#c8102e' : (p.brand === 'Grob' ? '#2e7d32' : '#003f62');
|
| 2606 |
+
return '<div style="position:relative" onclick="showDetail(' + idx + ')">' +
|
| 2607 |
+
'<div class="pc fade" style="cursor:pointer;transition-delay:' + Math.min(i * 20, 300) + 'ms">' +
|
| 2608 |
'<div class="pi" style="height:150px"><img src="' + (p.image || '') + '" alt="' + p.name + '" loading="lazy" onerror="this.style.display=\'none\'">' +
|
| 2609 |
'<span class="pi-badge">' + (p.cat || '') + '</span>' +
|
| 2610 |
'<span style="position:absolute;top:8px;right:8px;background:' + brandColor + ';color:#fff;padding:3px 7px;border-radius:5px;font-size:.55rem">' + (p.brand || '') + '</span></div>' +
|
| 2611 |
+
'<div class="pb"><div class="pn" style="font-size:.76rem">' + p.name + '</div><div class="pp">' + (p.price || 'Liên he') + '</div></div></div>' +
|
| 2612 |
+
'<button onclick="event.stopPropagation();addToCart(' + idx + ');" style="position:absolute;top:8px;left:8px;background:var(--a);color:#fff;border:none;width:28px;height:28px;border-radius:50%;display:flex;align-items:center;justify-content:center;cursor:pointer;font-size:.7rem;z-index:2;box-shadow:0 2px 6px rgba(0,0,0,.2)"><i class="fas fa-cart-plus"></i></button>' +
|
| 2613 |
+
'</div>';
|
| 2614 |
}).join('') + '</div>';
|
| 2615 |
}
|
| 2616 |
container.innerHTML = html;
|
|
|
|
| 2681 |
if (!product) { var t = document.createElement('div'); t.style.cssText = 'position:fixed;bottom:24px;right:24px;background:#dc2626;color:#fff;padding:10px;border-radius:8px;z-index:9999'; t.textContent = 'SP "' + slug + '" khong tim thay'; document.body.appendChild(t); setTimeout(function(){t.remove();},2500); return; }
|
| 2682 |
if (window._showOrderPicker) { window._showOrderPicker(product, function(r) { if (r === 'ok') { btn.textContent = '✓ Da them'; btn.style.background = '#059669'; } setTimeout(function() { btn.textContent = '+ Don'; btn.style.background = '#003f62'; }, 2500); }); }
|
| 2683 |
};
|
| 2684 |
+
|
| 2685 |
+
/** Save and create order functions */
|
| 2686 |
+
window.saveQuote = function() {
|
| 2687 |
+
if (!window.cart || !window.cart.length) { alert('Gio hang trong.'); return; }
|
| 2688 |
+
var D = window.D || [];
|
| 2689 |
+
var orderData = {
|
| 2690 |
+
customer: {
|
| 2691 |
+
name: document.getElementById('qcName').value || '',
|
| 2692 |
+
phone: document.getElementById('qcPhone').value || '',
|
| 2693 |
+
email: document.getElementById('qcEmail').value || '',
|
| 2694 |
+
addr: document.getElementById('qcAddr').value || '',
|
| 2695 |
+
orderCode: document.getElementById('qcCompany').value || ''
|
| 2696 |
+
},
|
| 2697 |
+
items: window.cart.map(function(c) { return { idx: c.idx, name: c.name, qty: c.qty, price: c.price, priceNum: c.priceNum }; }),
|
| 2698 |
+
total: window.cart.reduce(function(s,c) { return s + (c.priceNum || 0) * (c.qty || 1); }, 0),
|
| 2699 |
+
date: document.getElementById('qcDate').value || new Date().toISOString().split('T')[0]
|
| 2700 |
+
};
|
| 2701 |
+
localStorage.setItem('vai_quote_saved', JSON.stringify(orderData));
|
| 2702 |
+
showToast('Da luu bao gia!');
|
| 2703 |
+
};
|
| 2704 |
+
|
| 2705 |
+
window.createOrder = function() {
|
| 2706 |
+
if (!window.cart || !window.cart.length) { alert('Gio hang trong.'); return; }
|
| 2707 |
+
var name = document.getElementById('qcName').value;
|
| 2708 |
+
var phone = document.getElementById('qcPhone').value;
|
| 2709 |
+
var addr = document.getElementById('qcAddr').value;
|
| 2710 |
+
if (!name || !phone || !addr) { alert('Vui long dien day du thong tin.'); return; }
|
| 2711 |
+
showToast('Tao don hang thanh cong! Ma don: ' + (document.getElementById('qcCompany').value || 'N/A'));
|
| 2712 |
+
window.cart = [];
|
| 2713 |
+
localStorage.setItem('malloca_cart', JSON.stringify(window.cart));
|
| 2714 |
+
if (typeof updateCartBadge === 'function') updateCartBadge();
|
| 2715 |
+
closeQuotation();
|
| 2716 |
+
};
|
| 2717 |
</html
|
| 2718 |
|
| 2719 |
</script><a href="https://bot.zaloplatforms.com/bots/4013442364902370344" target="_blank" rel="noopener" class="zalo-fab" title="Tư vấn qua Zalo"><img src="https://huggingface.co/spaces/bep40/V.AISTUDIO/resolve/main/logo/zalo-bot.png" alt="Zalo Bot"></a>
|