Files
chuanggao-website/client/dist/assets/ProductListView-CFgnsMR8.js
2026-05-12 16:53:18 +08:00

2 lines
5.2 KiB
JavaScript

import{d as S,g as a,b as r,k as C,q as B,f as v,_ as Z,l as q,o as A,w as F,e,m as N,t as l,p as h,i as b,j as V,F as f,h as k,s as D,v as E,x as K,r as d,u as U,y as j,z as O,R as Q,A as G}from"./index-eVF4AHSu.js";import{a as H,b as J}from"./product-xndN8QNU.js";import{P as W}from"./PortalBreadcrumb-BcLGJAMu.js";import{r as X}from"./media-BgGGvhcR.js";import"./pagination-BgSlm-mj.js";const Y=["src","alt"],tt=S({__name:"PortalImage",props:{src:{},alt:{},fit:{}},setup($){B(c=>({v200e201a:y.value}));const i=$,p=v(()=>X(i.src??void 0)),w=v(()=>i.alt??""),y=v(()=>i.fit??"cover");return(c,g)=>p.value?(a(),r("img",{key:0,class:"portal-img",src:p.value,alt:w.value,loading:"lazy",decoding:"async"},null,8,Y)):C("",!0)}}),et=Z(tt,[["__scopeId","data-v-b1c82d87"]]),st={class:"product-list-page"},ot={class:"pl-banner"},at={class:"container"},rt={class:"title-lg"},nt={class:"banner-desc"},lt={class:"container pl-layout"},it={class:"pl-sidebar"},ct=["onClick"],ut=["onClick"],dt={class:"pl-main"},vt={class:"pl-toolbar"},pt={class:"result-info"},yt={class:"total-count"},_t={class:"search-box"},gt={key:0,class:"loading-state"},mt={key:1,class:"product-grid"},ht={class:"product-thumb"},bt={class:"product-info"},ft={class:"product-category"},kt={class:"product-name"},Ct={key:0,class:"product-summary"},wt={key:1,class:"product-price"},Pt={key:2,class:"empty-state"},xt={key:3,class:"pagination-bar"},It=["disabled"],Lt=["onClick"],Vt=["disabled"],$t=S({__name:"ProductListView",setup($){const{t:i}=q(),p=G(),w=U(),y=d([]),c=d({records:[],total:0,current:1,pages:0}),g=d(!1),P=d(""),R=d(12),u=d(1),_=v(()=>{const o=p.query.categoryId;if(!o||Array.isArray(o))return;const s=Number.parseInt(String(o),10);return Number.isFinite(s)?s:void 0}),T=v(()=>[{label:i("nav.home"),to:"/"},{label:i("products.title")}]),z=v(()=>{const o=_.value;if(!o)return i("products.filter.all");const s=t=>{for(const n of t){if(n.id===o)return n.nameZh;if(n.children){const L=s(n.children);if(L)return L}}};return s(y.value)||i("products.filter.all")});async function m(){g.value=!0;try{c.value=await J({categoryId:_.value,page:u.value,size:R.value,keyword:P.value.trim()||void 0})}catch(o){console.error("[ProductListView] reloadList",o),c.value={records:[],total:0,current:1,pages:0}}finally{g.value=!1}}function x(o){u.value=1,w.push({path:"/products",query:o?{categoryId:String(o)}:{}})}function I(o){u.value=o,m(),window.scrollTo({top:0,behavior:"smooth"})}function M(){u.value=1,m()}return A(async()=>{try{y.value=await H(),await m()}catch(o){console.error("[ProductListView] mount",o)}}),F(()=>p.query.categoryId,()=>{u.value=1,m()}),(o,s)=>(a(),r("div",st,[e("section",ot,[e("div",at,[N(W,{items:T.value},null,8,["items"]),s[4]||(s[4]=e("div",{class:"kicker-en"},"PRODUCTS CENTER",-1)),e("h1",rt,l(h(i)("products.title")),1),e("p",nt,l(h(i)("products.subtitle")),1)])]),e("div",lt,[e("aside",it,[s[7]||(s[7]=e("div",{class:"sidebar-title"},"产品分类",-1)),e("button",{type:"button",class:b(["category-btn",{active:_.value===void 0}]),onClick:s[0]||(s[0]=t=>x())},[s[5]||(s[5]=e("span",{class:"category-dot"},null,-1)),V(" "+l(h(i)("products.filter.all")),1)],2),(a(!0),r(f,null,k(y.value,t=>(a(),r("div",{key:t.id,class:"category-group"},[e("button",{type:"button",class:b(["category-btn category-parent",{active:_.value===t.id}]),onClick:n=>x(t.id)},[s[6]||(s[6]=e("span",{class:"category-dot"},null,-1)),V(" "+l(t.nameZh),1)],10,ct),(a(!0),r(f,null,k(t.children??[],n=>(a(),r("button",{key:n.id,type:"button",class:b(["category-btn category-child",{active:_.value===n.id}]),onClick:L=>x(n.id)},l(n.nameZh),11,ut))),128))]))),128))]),e("div",dt,[e("div",vt,[e("div",pt,[s[8]||(s[8]=V(" 当前分类:",-1)),e("strong",null,l(z.value),1),e("span",yt,"共 "+l(c.value.total)+" 件产品",1)]),e("div",_t,[D(e("input",{"onUpdate:modelValue":s[1]||(s[1]=t=>P.value=t),type:"text",class:"search-input",placeholder:"搜索产品名称...",onKeyup:K(M,["enter"])},null,544),[[E,P.value]]),e("button",{class:"search-btn",onClick:M},"搜索")])]),g.value?(a(),r("div",gt,"加载中...")):c.value.records.length?(a(),r("div",mt,[(a(!0),r(f,null,k(c.value.records,t=>(a(),j(h(Q),{key:t.id,class:"product-card",to:`/products/${t.id}`},{default:O(()=>{var n;return[e("div",ht,[N(et,{class:"product-img",src:t.mainImage,alt:t.nameZh},null,8,["src","alt"]),s[9]||(s[9]=e("div",{class:"product-overlay"},[e("span",null,"查看详情")],-1))]),e("div",bt,[e("div",ft,l(t.categoryLabelZh),1),e("div",kt,l(t.nameZh),1),t.summaryZh?(a(),r("p",Ct,l(t.summaryZh),1)):C("",!0),t.isShowPrice&&(t.priceMin||t.priceMax)?(a(),r("div",wt," ¥"+l((n=t.priceMin)==null?void 0:n.toLocaleString())+l(t.priceMax?` - ¥${t.priceMax.toLocaleString()}`:""),1)):C("",!0)])]}),_:2},1032,["to"]))),128))])):(a(),r("div",Pt,"暂无产品数据")),c.value.pages>1?(a(),r("div",xt,[e("button",{class:"page-btn",disabled:u.value<=1,onClick:s[2]||(s[2]=t=>I(u.value-1))}," 上一页 ",8,It),(a(!0),r(f,null,k(c.value.pages,t=>(a(),r("button",{key:t,class:b(["page-btn",{active:t===u.value}]),onClick:n=>I(t)},l(t),11,Lt))),128)),e("button",{class:"page-btn",disabled:u.value>=c.value.pages,onClick:s[3]||(s[3]=t=>I(u.value+1))}," 下一页 ",8,Vt)])):C("",!0)])])]))}}),Tt=Z($t,[["__scopeId","data-v-698686eb"]]);export{Tt as default};