bep40 commited on
Commit
2ca81d2
·
verified ·
1 Parent(s): 4ac1831

Add AI Search + AI Quote boxes on web homepage

Browse files
Files changed (1) hide show
  1. index.html +98 -1
index.html CHANGED
@@ -1,6 +1,6 @@
1
  <!DOCTYPE html>
2
  <html lang="vi">
3
- <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width,initial-scale=1">
6
  <title>V.AI STUDIO | Niềm tin khách hàng là tài sản của chúng tôi</title>
@@ -490,6 +490,19 @@ textarea.form-input{height:120px;resize:vertical}
490
  <div class="hero-stat"><strong>100%</strong><span>Dữ liệu thật</span></div>
491
  </div>
492
  </div></section>
 
 
 
 
 
 
 
 
 
 
 
 
 
493
 
494
  <!-- Partner Logos -->
495
  <div style="background:#fff;padding:14px 0;border-bottom:1px solid var(--gl)">
@@ -2713,5 +2726,89 @@ Miễn phí giao hàng trong TPHCM. | Giá đã bao gồm VAT.
2713
  </div>
2714
  </div>
2715
  <script src="search-plus-boot.js"></script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2716
  </body>
2717
  </html>
 
1
  <!DOCTYPE html>
2
  <html lang="vi">
3
+ <head><script>window.huggingface={variables:{"SPACE_CREATOR_USER_ID":"661b9191e7b0ab12bceb66f3","VAISTUDIO":""}};</script>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width,initial-scale=1">
6
  <title>V.AI STUDIO | Niềm tin khách hàng là tài sản của chúng tôi</title>
 
490
  <div class="hero-stat"><strong>100%</strong><span>Dữ liệu thật</span></div>
491
  </div>
492
  </div></section>
493
+ <!-- AI SEARCH + QUOTE -->
494
+ <div style="background:#fff;padding:16px 0;border-bottom:1px solid #e2e8f0">
495
+ <div class="container" style="display:flex;gap:12px;flex-wrap:wrap;justify-content:center;max-width:900px">
496
+ <div style="flex:1;min-width:280px;position:relative">
497
+ <i class="fas fa-robot" style="position:absolute;left:12px;top:50%;transform:translateY(-50%);color:#003f62;font-size:.85rem"></i>
498
+ <input type="text" id="aiSearch" placeholder="🔍 AI tìm kiếm: bếp từ đôi dưới 15 triệu, máy hút mùi tốt nhất..." style="width:100%;padding:11px 14px 11px 36px;border:2px solid #003f62;border-radius:10px;font-size:.85rem;font-family:inherit;outline:none" onkeypress="if(event.key==='Enter')doAISearch()">
499
+ </div>
500
+ <button onclick="doAISearch()" style="padding:11px 20px;background:#003f62;color:#fff;border:none;border-radius:10px;font-weight:700;font-size:.85rem;cursor:pointer;white-space:nowrap"><i class="fas fa-search"></i> Tìm AI</button>
501
+ <button onclick="doAIQuote()" style="padding:11px 20px;background:#db9815;color:#fff;border:none;border-radius:10px;font-weight:700;font-size:.85rem;cursor:pointer;white-space:nowrap"><i class="fas fa-file-invoice-dollar"></i> AI Báo giá</button>
502
+ </div>
503
+ <div id="aiResults" style="max-width:900px;margin:12px auto 0;display:none;background:#f8fafc;border-radius:10px;padding:14px;font-size:.82rem"></div>
504
+ </div>
505
+
506
 
507
  <!-- Partner Logos -->
508
  <div style="background:#fff;padding:14px 0;border-bottom:1px solid var(--gl)">
 
2726
  </div>
2727
  </div>
2728
  <script src="search-plus-boot.js"></script>
2729
+
2730
+ <script>
2731
+ function doAISearch(){
2732
+ const q=document.getElementById('aiSearch').value.trim();
2733
+ if(!q)return;
2734
+ const res=document.getElementById('aiResults');
2735
+ res.style.display='block';
2736
+ res.innerHTML='<i class="fas fa-spinner fa-spin"></i> Đang tìm...';
2737
+ // Parse budget from query
2738
+ const budgetMatch=q.match(/(\d+)\s*(tr|triệu|m)/i);
2739
+ const budget=budgetMatch?parseInt(budgetMatch[1])*1000000:0;
2740
+ // Search in loaded products (D = product array from main JS)
2741
+ if(typeof D==='undefined'||!D.length){res.innerHTML='⏳ Đang tải SP...';return}
2742
+ const qn=q.toLowerCase().normalize('NFD').replace(/[\u0300-\u036f]/g,'').replace(/đ/g,'d');
2743
+ let results=D.filter(p=>{
2744
+ const pn=((p.name||'')+(p.cat||'')).toLowerCase().normalize('NFD').replace(/[\u0300-\u036f]/g,'').replace(/đ/g,'d');
2745
+ const words=qn.split(/\s+/).filter(w=>w.length>=2&&!['duoi','tren','khoang','tu','van','tot','nhat','ban','chay','gia','re'].includes(w));
2746
+ return words.length>0&&words.some(w=>pn.includes(w));
2747
+ });
2748
+ // Filter by budget
2749
+ if(budget>0)results=results.filter(p=>p.priceNum>0&&p.priceNum<=budget*1.2);
2750
+ // Sort: Malloca/Grob first, then price low→high
2751
+ results.sort((a,b)=>{
2752
+ const brandScore=p=>(/malloca/i.test(p.brand)?3:/grob/i.test(p.brand)?2:1);
2753
+ if(brandScore(b)!==brandScore(a))return brandScore(b)-brandScore(a);
2754
+ return(a.priceNum||9e9)-(b.priceNum||9e9);
2755
+ });
2756
+ results=results.slice(0,8);
2757
+ if(!results.length){res.innerHTML='😅 Không tìm thấy SP phù hợp. Thử từ khóa khác!';return}
2758
+ let html='<div style="font-weight:700;margin-bottom:8px">🎯 Kết quả'+(budget?' (dưới '+budget.toLocaleString('vi')+'đ)':'')+':</div>';
2759
+ html+='<div style="display:grid;grid-template-columns:repeat(auto-fill,minmax(200px,1fr));gap:10px">';
2760
+ results.forEach(p=>{
2761
+ html+='<div style="background:#fff;border-radius:8px;padding:10px;box-shadow:0 1px 3px rgba(0,0,0,.08);cursor:pointer" onclick="showDetail('+D.indexOf(p)+')">';
2762
+ if(p.image)html+='<img src="'+p.image+'" style="width:100%;height:100px;object-fit:contain;border-radius:4px;margin-bottom:6px">';
2763
+ html+='<div style="font-size:.75rem;font-weight:600;line-height:1.3;margin-bottom:4px">'+p.name.substring(0,40)+'</div>';
2764
+ html+='<div style="font-size:.82rem;font-weight:800;color:#003f62">'+(p.price||'LH')+'</div>';
2765
+ html+='<div style="font-size:.65rem;color:#64748b">'+p.brand+' | '+p.sku+'</div></div>';
2766
+ });
2767
+ html+='</div>';
2768
+ res.innerHTML=html;
2769
+ }
2770
+ function doAIQuote(){
2771
+ const q=document.getElementById('aiSearch').value.trim()||'bếp từ + máy hút mùi + chậu rửa khoảng 50 triệu';
2772
+ const res=document.getElementById('aiResults');
2773
+ res.style.display='block';
2774
+ res.innerHTML='<i class="fas fa-spinner fa-spin"></i> AI đang chọn SP phù hợp...';
2775
+ if(typeof D==='undefined'||!D.length){res.innerHTML='⏳ Đang tải SP...';return}
2776
+ // Parse budget
2777
+ const budgetMatch=q.match(/(\d+)\s*(tr|triệu|m)/i);
2778
+ const budget=budgetMatch?parseInt(budgetMatch[1])*1000000:50000000;
2779
+ // Detect product types wanted
2780
+ const qn=q.toLowerCase().normalize('NFD').replace(/[\u0300-\u036f]/g,'').replace(/đ/g,'d');
2781
+ const typeMap={'bep tu':{k:['bep tu','bep dien'],n:'Bếp từ'},'may hut':{k:['may hut','hut mui'],n:'Máy hút mùi'},'chau rua':{k:['chau rua','bon rua'],n:'Chậu rửa'},'voi rua':{k:['voi rua'],n:'Vòi rửa'},'lo nuong':{k:['lo nuong'],n:'Lò nướng'},'may rua':{k:['may rua'],n:'Máy rửa bát'}};
2782
+ let wantTypes=[];
2783
+ for(const[key,cfg] of Object.entries(typeMap)){if(cfg.k.some(k=>qn.includes(k)))wantTypes.push(cfg)}
2784
+ if(!wantTypes.length)wantTypes=[typeMap['bep tu'],typeMap['may hut'],typeMap['chau rua']];
2785
+ const perBudget=Math.floor(budget/wantTypes.length);
2786
+ // Pick best product per type
2787
+ let picks=[];let total=0;
2788
+ wantTypes.forEach(typ=>{
2789
+ let candidates=D.filter(p=>{
2790
+ const pn=((p.name||'')+(p.cat||'')).toLowerCase().normalize('NFD').replace(/[\u0300-\u036f]/g,'').replace(/đ/g,'d');
2791
+ return typ.k.some(k=>pn.includes(k))&&p.priceNum>0&&p.priceNum<=perBudget*1.3;
2792
+ });
2793
+ candidates.sort((a,b)=>{const s=p=>(/malloca/i.test(p.brand)?3:/grob/i.test(p.brand)?2:1);return s(b)-s(a)||(a.priceNum-b.priceNum)});
2794
+ if(candidates.length){picks.push({...candidates[0],typeName:typ.n});total+=candidates[0].priceNum}
2795
+ });
2796
+ if(!picks.length){res.innerHTML='😅 Không đủ SP trong ngân sách. Thử tăng budget!';return}
2797
+ let html='<div style="font-weight:700;margin-bottom:10px">📋 AI BÁO GIÁ (ngân sách ~'+budget.toLocaleString('vi')+'đ):</div>';
2798
+ html+='<table style="width:100%;border-collapse:collapse;font-size:.78rem">';
2799
+ html+='<tr style="background:#003f62;color:#fff"><th style="padding:6px">Loại</th><th>Sản phẩm</th><th>Brand</th><th style="text-align:right">Giá</th></tr>';
2800
+ picks.forEach((p,i)=>{
2801
+ html+='<tr style="border-bottom:1px solid #e2e8f0"><td style="padding:6px;font-weight:600">'+p.typeName+'</td><td>'+p.name.substring(0,35)+'</td><td>'+p.brand+'</td><td style="text-align:right;font-weight:700;color:#003f62">'+(p.price||'LH')+'</td></tr>';
2802
+ });
2803
+ html+='<tr style="background:#f0f2f5;font-weight:800"><td colspan="3" style="padding:8px;text-align:right">TỔNG:</td><td style="text-align:right;color:#003f62;padding:8px">'+total.toLocaleString('vi')+'đ</td></tr>';
2804
+ html+='</table>';
2805
+ if(total<=budget)html+='<div style="margin-top:8px;color:#28a745;font-weight:600">✅ Trong ngân sách! Còn dư '+(budget-total).toLocaleString('vi')+'đ</div>';
2806
+ else html+='<div style="margin-top:8px;color:#dc3545;font-weight:600">⚠️ Vượt ngân sách '+(total-budget).toLocaleString('vi')+'đ</div>';
2807
+ html+='<div style="margin-top:10px;text-align:center"><button onclick="addQuoteToCart()" style="padding:8px 20px;background:#db9815;color:#fff;border:none;border-radius:8px;font-weight:700;cursor:pointer">🛒 Thêm vào giỏ hàng</button></div>';
2808
+ res.innerHTML=html;
2809
+ window._aiPicks=picks;
2810
+ }
2811
+ function addQuoteToCart(){if(window._aiPicks)window._aiPicks.forEach(p=>{let found=D.find(d=>d.sku===p.sku);if(found&&typeof addToCart==='function')addToCart(D.indexOf(found))});document.getElementById('aiResults').innerHTML='✅ Đã thêm vào giỏ!';}
2812
+ </script>
2813
  </body>
2814
  </html>