PageSourceSearch

https://courageous-vacherin-e84cf7.netlify.app/assets/Products-dd82e8ba.js

js courageous-vacherin-e84cf7.netlify.app collected 2026-10-03 10:36:35 UTC 12,840 bytes, 1 lines download raw bytes

1import{_,a as v,o as a,c as o,d as e,n as g,g as h,F as p,r as f,k as y,v as b,l as k,f as u,m as P,t as c,j as C}from"./index-89a33496.js";import{g as S}from"./utils-f0fed86d.js";const M={name:"Products",data(){return{products:[],categories:[],availableScales:["","1:6","1:12","1:18","1:24","1:64"],localSearch:"",localCategoryId:null,localScale:"",localMinPrice:null,localMaxPrice:null,localSort:"",currentPage:1,totalPages:1,totalItems:0,loading:!1,isMobileFilterOpen:!1}},computed:{hasActiveFilters(){return!!(this.localSearch||this.localCategoryId!==null||this.localScale!==""||this.localMinPrice!==null||this.localMaxPrice!==null)},paginatedPages(){const s=this.currentPage,t=this.totalPages;return t<=7?Array.from({length:t},(n,m)=>m+1):s<=4?[1,2,3,4,5,"...",t]:s>=t-3?[1,"...",t-4,t-3,t-2,t-1,t]:[1,"...",s-1,s,s+1,"...",t]}},watch:{"$route.query":{handler(){this.syncFromUrlAndFetch()},deep:!0}},mounted(){this.fetchCategories().then(()=>{this.syncFromUrlAndFetch()})},methods:{async fetchCategories(){try{const s=await v.get("/api/danh-muc");this.categories=s.data}catch(s){console.error("Lỗi khi tải danh mục:",s)}},async fetchProducts(){this.loading=!0;try{const s={page:this.currentPage,per_page:20};this.localSearch&&(s.search=this.localSearch),this.localCategoryId!==null&&(s.id_danh_muc=this.localCategoryId),this.localScale&&(s.scale=this.localScale),this.localMinPrice!==null&&(s.min_price=this.localMinPrice),this.localMaxPrice!==null&&(s.max_price=this.localMaxPrice),this.localSort&&(s.sort=this.localSort);const n=(await v.get("/api/san-pham",{params:s})).data;this.products=n.data||[],this.totalPages=n.last_page||1,this.totalItems=n.total||0}catch(s){console.error("Lỗi khi tải sản phẩm:",s),this.products=[],this.totalPages=1,this.totalItems=0}finally{this.loading=!1}},syncFromUrlAndFetch(){const s=this.$route.query||{};this.localSearch=s.search||"",this.localCategoryId=s.id_danh_muc?Number(s.id_danh_muc):null,this.localScale=s.scale||"",this.localMinPrice=s.min_price?Number(s.min_price):null,this.localMaxPrice=s.max_price?Number(s.max_price):null,this.localSort=s.sort||"",this.currentPage=s.page?Number(s.page):1,this.fetchProducts()},applyFilters(){this.isMobileFilterOpen=!1;const s={};this.localSearch&&(s.search=this.localSearch),this.localCategoryId!==null&&(s.id_danh_muc=this.localCategoryId),this.localScale&&(s.scale=this.localScale),this.localMinPrice!==null&&(s.min_price=this.localMinPrice),this.localMaxPrice!==null&&(s.max_price=this.localMaxPrice),this.localSort&&(s.sort=this.localSort),this.$router.push({path:"/san-pham",query:s})},applySort(){this.applyFilters()},selectCategory(s){this.localCategoryId=s,this.applyFilters()},selectScale(s){this.localScale=s,this.applyFilters()},setQuickPrice(s,t){this.localMinPrice=s,this.localMaxPrice=t,this.applyFilters()},clearFilters(){this.localSearch="",this.localCategoryId=null,this.localScale="",this.localMinPrice=null,this.localMaxPrice=null,this.localSort="",this.currentPage=1,this.isMobileFilterOpen=!1,this.$router.push({path:"/san-pham"})},changePage(s){if(s<1||s>this.totalPages)return;const t={...this.$route.query};t.page=s,this.$router.push({path:"/san-pham",query:t})},removeSearchTag(){this.localSearch="",this.applyFilters()},removeCategoryTag(){this.localCategoryId=null,this.applyFilters()},removeScaleTag(){this.localScale="",this.applyFilters()},removePriceTag(){this.localMinPrice=null,this.localMaxPrice=null,this.applyFilters()},getCategoryName(s){const t=this.categories.find(n=>n.id===s);return t?t.ten_danh_muc:""},formatPriceRange(s,t){return s!==null&&t!==null?`${this.formatPrice(s)} - ${this.formatPrice(t)}`:s!==null?`Trên ${this.formatPrice(s)}`:t!==null?`Dưới ${this.formatPrice(t)}`:""},getProductImage(s){if(s.hinh_anhs&&s.hinh_anhs.length>0){const n=(s.hinh_anhs.find(m=>m.la_anh_dai_dien)||s.hinh_anhs[0]).duong_dan_anh;return n.startsWith("http")?n:(n.startsWith("/")?"":"/")+n}return"https://via.placeholder.com/300?text=No+Image"},formatPrice(s){return s?new Intl.NumberFormat("vi-VN",{style:"currency",currency:"VND",minimumFractionDigits:0,maximumFractionDigits:0}).format(s):"0 đ"},goToDetail(s){this.$router.push(S(s))}}},F={class:"products-page-container"},x={class:"products-layout-wrapper"},w={class:"sidebar-header"},T={class:"filter-section"},I={class:"filter-list"},D=["onClick"],N={class:"filter-section"},L={class:"scale-chips-wrapper"},B=["onClick"],V={class:"filter-section"},A={class:"price-inputs"},q={class:"quick-prices"},U={class:"filter-actions"},K={class:"products-content-area"},O={class:"products-toolbar"},G={class:"toolbar-left"}
1,Q={key:0,class:"results-count"},X={class:"toolbar-right"},j={class:"sort-selector-wrap"},H={key:0,class:"active-filters-tags"},R={key:0,class:"filter-tag"},W={key:1,class:"filter-tag"},z={key:2,class:"filter-tag"},E={key:3,class:"filter-tag"},J={key:1,class:"products-loading-state"},Y={key:2},Z={class:"product-grid"},$=["onClick"],tt={key:0,class:"product-badge badge-new"},et={key:1,class:"product-badge badge-sale"},lt={key:2,class:"product-badge badge-ltd"},st={class:"product-img-wrap"},it=["src","alt"],rt={class:"product-info"},at={class:"product-brand"},ot=["title"],nt={class:"product-footer"},ct={class:"product-price-group"},ut={class:"product-price"},ht={key:0,class:"product-price-orig"},dt=["onClick"],gt={key:0,class:"pagination-wrap"},pt=["disabled"],mt={key:0,class:"page-ellipsis"},ft=["onClick"],yt=["disabled"],vt={key:3,class:"products-empty-state"};function bt(s,t,n,m,r,i){return a(),o("div",F,[t[43]||(t[43]=e("div",{class:"products-header-banner"},[e("div",{class:"banner-inner"},[e("h1",{class:"products-page-title"},"Cửa Hàng BALAB"),e("p",{class:"products-page-subtitle"},"Khám phá bộ sưu tập mô hình 3D cao cấp được in tỉ mỉ với độ nét hoàn hảo.")])],-1)),e("div",x,[e("aside",{class:g(["filter-sidebar",{"mobile-open":r.isMobileFilterOpen}])},[e("div",w,[t[23]||(t[23]=e("h3",null,"Bộ Lọc Sản Phẩm",-1)),e("button",{class:"btn-close-sidebar",onClick:t[0]||(t[0]=l=>r.isMobileFilterOpen=!1)},[...t[22]||(t[22]=[e("i",{class:"fa-solid fa-xmark"},null,-1)])])]),e("div",T,[t[26]||(t[26]=e("label",{class:"filter-label"},"Danh Mục",-1)),e("div",I,[e("button",{class:g(["filter-list-item",{active:r.localCategoryId===null}]),onClick:t[1]||(t[1]=l=>i.selectCategory(null))},[...t[24]||(t[24]=[e("span",{class:"bullet"},null,-1),h(" Tất cả sản phẩm ",-1)])],2),(a(!0),o(p,null,f(r.categories,l=>(a(),o("button",{key:l.id,class:g(["filter-list-item",{active:r.localCategoryId===l.id}]),onClick:d=>i.selectCategory(l.id)},[t[25]||(t[25]=e("span",{class:"bullet"},null,-1)),h(" "+c(l.ten_danh_muc),1)],10,D))),128))])]),e("div",N,[t[27]||(t[27]=e("label",{class:"filter-label"},"Tỉ lệ (Scale)",-1)),e("div",L,[(a(!0),o(p,null,f(r.availableScales,l=>(a(),o("button",{key:l,class:g(["scale-chip",{active:r.localScale===l}]),onClick:d=>i.selectScale(l)},c(l===""?"Tất cả":l),11,B))),128))])]),e("div",V,[t[29]||(t[29]=e("label",{class:"filter-label"},"Khoảng Giá (VND)",-1)),e("div",A,[y(e("input",{type:"number","onUpdate:modelValue":t[2]||(t[2]=l=>r.localMinPrice=l),placeholder:"Từ",min:"0",class:"price-input",onKeyup:t[3]||(t[3]=k((...l)=>i.applyFilters&&i.applyFilters(...l),["enter"]))},null,544),[[b,r.localMinPrice,void 0,{number:!0}]]),t[28]||(t[28]=e("span",{class:"price-separator"},"-",-1)),y(e("input",{type:"number","onUpdate:modelValue":t[4]||(t[4]=l=>r.localMaxPrice=l),placeholder:"Đến",min:"0",class:"price-input",onKeyup:t[5]||(t[5]=k((...l)=>i.applyFilters&&i.applyFilters(...l),["enter"]))},null,544),[[b,r.localMaxPrice,void 0,{number:!0}]])]),e("div",q,[e("button",{onClick:t[6]||(t[6]=l=>i.setQuickPrice(0,1e5))},"Dưới 100k"),e("button",{onClick:t[7]||(t[7]=l=>i.setQuickPrice(1e5,5e5))},"100k - 500k"),e("button",{onClick:t[8]||(t[8]=l=>i.setQuickPrice(5e5,null))},"Trên 500k")])]),e("div",U,[e("button",{class:"btn-apply-filters",onClick:t[9]||(t[9]=(...l)=>i.applyFilters&&i.applyFilters(...l))},[...t[30]||(t[30]=[e("i",{class:"fa-solid fa-filter"},null,-1),h(" Áp Dụng Lọc ",-1)])]),e("button",{class:"btn-reset-filters",onClick:t[10]||(t[10]=(...l)=>i.clearFilters&&i.clearFilters(...l))}," Xóa Tất Cả Lọc ")])],2),e("main",K,[e("div",O,[e("div",G,[e("button",{class:"btn-toggle-mobile-filters",onClick:t[11]||(t[11]=l=>r.isMobileFilterOpen=!0)},[...t[31]||(t[31]=[e("i",{class:"fa-solid fa-sliders"},null,-1),h(" Bộ Lọc ",-1)])]),r.loading?u("",!0):(a(),o("div",Q,[...t[32]||(t[32]=[e("strong",null,"Tìm thấy các sản phẩm",-1)])]))]),e("div",X,[e("div",j,[t[34]||(t[34]=e("span",{class:"sort-label"},"Sắp xếp:",-1)),y(e("select",{"onUpdate:modelValue":t[12]||(t[12]=l=>r.localSort=l),onChange:t[13]||(t[13]=(...l)=>i.applySort&&i.applySort(...l)),class:"sort-select"},[...t[33]||(t[33]=[e("option",{value:""},"Mặc định",-1),e("option",{value:"price_asc"},"Giá: Thấp đến Cao",-1),e("option",{value:"price_desc"},"Giá: Cao đến Thấp",-1),e("option",{value:"newest"}
1,"Mới nhất",-1)])],544),[[P,r.localSort]])])])]),i.hasActiveFilters?(a(),o("div",H,[t[35]||(t[35]=e("span",{class:"tag-title"},"Đang lọc theo:",-1)),r.localSearch?(a(),o("span",R,[h(' Từ khóa: "'+c(r.localSearch)+'" ',1),e("i",{class:"fa-solid fa-xmark",onClick:t[14]||(t[14]=(...l)=>i.removeSearchTag&&i.removeSearchTag(...l))})])):u("",!0),r.localCategoryId?(a(),o("span",W,[h(" Danh mục: "+c(i.getCategoryName(r.localCategoryId))+" ",1),e("i",{class:"fa-solid fa-xmark",onClick:t[15]||(t[15]=(...l)=>i.removeCategoryTag&&i.removeCategoryTag(...l))})])):u("",!0),r.localScale?(a(),o("span",z,[h(" Tỉ lệ: "+c(r.localScale)+" ",1),e("i",{class:"fa-solid fa-xmark",onClick:t[16]||(t[16]=(...l)=>i.removeScaleTag&&i.removeScaleTag(...l))})])):u("",!0),r.localMinPrice||r.localMaxPrice?(a(),o("span",E,[h(" Giá: "+c(i.formatPriceRange(r.localMinPrice,r.localMaxPrice))+" ",1),e("i",{class:"fa-solid fa-xmark",onClick:t[17]||(t[17]=(...l)=>i.removePriceTag&&i.removePriceTag(...l))})])):u("",!0),e("button",{class:"btn-clear-tags",onClick:t[18]||(t[18]=(...l)=>i.clearFilters&&i.clearFilters(...l))},"Xóa hết")])):u("",!0),r.loading?(a(),o("div",J,[...t[36]||(t[36]=[e("i",{class:"fa-solid fa-circle-notch fa-spin"},null,-1),e("p",null,"Đang tải danh sách sản phẩm...",-1)])])):r.products.length>0?(a(),o("div",Y,[e("div",Z,[(a(!0),o(p,null,f(r.products,l=>(a(),o("div",{key:l.id,class:"product-card",onClick:d=>i.goToDetail(l)},[l.tinh_trang===1?(a(),o("div",tt,"Đang bán")):l.tinh_trang===0?(a(),o("div",et,"Hết hàng")):l.tinh_trang===2?(a(),o("div",lt,"Ẩn")):u("",!0),e("div",st,[e("img",{src:i.getProductImage(l),alt:l.ten_san_pham,class:"product-img"},null,8,it)]),e("div",rt,[e("div",at,c(l.danh_muc?l.danh_muc.ten_danh_muc:"Mô hình"),1),e("div",{class:"product-name truncate",title:l.ten_san_pham},c(l.ten_san_pham),9,ot),t[37]||(t[37]=e("div",{class:"product-rating"},[e("span",{class:"stars"},"★★★★★"),e("span",null,"(5.0)")],-1)),e("div",nt,[e("div",ct,[e("span",ut,c(i.formatPrice(l.gia_co_ban)),1),l.gia_goc&&l.gia_goc>0?(a(),o("span",ht,c(i.formatPrice(l.gia_goc)),1)):u("",!0)]),e("button",{class:"btn-view",onClick:C(d=>i.goToDetail(l),["stop"])},"Xem",8,dt)])])],8,$))),128))]),r.totalPages>1?(a(),o("div",gt,[e("button",{class:"page-btn page-arrow",disabled:r.currentPage===1,onClick:t[19]||(t[19]=l=>i.changePage(r.currentPage-1))},[...t[38]||(t[38]=[e("svg",{width:"8",height:"12",viewBox:"0 0 8 12",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[e("path",{d:"M7 11L2 6L7 1",stroke:"currentColor","stroke-width":"1.6","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])],8,pt),(a(!0),o(p,null,f(i.paginatedPages,(l,d)=>(a(),o(p,{key:d},[l==="..."?(a(),o("span",mt,"...")):(a(),o("button",{key:1,class:g(["page-btn",{active:r.currentPage===l}]),onClick:kt=>i.changePage(l)},c(l),11,ft))],64))),128)),e("button",{class:"page-btn page-arrow",disabled:r.currentPage===r.totalPages,onClick:t[20]||(t[20]=l=>i.changePage(r.currentPage+1))},[...t[39]||(t[39]=[e("svg",{width:"8",height:"12",viewBox:"0 0 8 12",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[e("path",{d:"M1 11L6 6L1 1",stroke:"currentColor","stroke-width":"1.6","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])],8,yt)])):u("",!0)])):(a(),o("div",vt,[t[40]||(t[40]=e("div",{class:"empty-icon"},[e("i",{class:"fa-regular fa-folder-open"})],-1)),t[41]||(t[41]=e("h3",null,"Không tìm thấy sản phẩm nào",-1)),t[42]||(t[42]=e("p",null,"Hãy thử thay đổi điều kiện lọc hoặc từ khóa tìm kiếm khác nhé.",-1)),e("button",{class:"btn-reset-empty",onClick:t[21]||(t[21]=(...l)=>i.clearFilters&&i.clearFilters(...l))},"Xóa tất cả bộ lọc")]))])])])}const Ct=_(M,[["render",bt],["__scopeId","data-v-152b1f1e"]]);export{Ct as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.