import{A as e,C as t,M as n,O as r,_ as i,b as a,c as o,f as s,g as c,i as l,k as u,l as d,m as f,o as p,r as m,s as h,t as g,w as _,x as v}from"./index-vhvNh9F8.js";var y={class:`page`},b={class:`category-bar`},x=[`onClick`],S={key:0,class:`empty-state`},C={width:`48`,height:`48`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.2`,"stroke-linecap":`round`,"stroke-linejoin":`round`,style:{color:`#ccc`,"margin-bottom":`8px`}},w={key:1,class:`product-grid-list`},T=[`onClick`],E={class:`grid-img-wrap`},D=[`src`],O={class:`grid-info`},k={class:`grid-name`},A={class:`grid-price-row`},j={class:`grid-price`},M={key:0,class:`grid-original-price`},N=h({__name:`ProductList`,setup(h){let N=d(),P=o(),F=r([]),I=r(null),L=r([]),R=r(!1),z=r(``);async function B(e){I.value=e.id,z.value=e.name,await V()}async function V(){R.value=!0;try{let e={pageSize:20,page:1};I.value&&(e.category_id=I.value);let t=await l(e);t.code===0&&(L.value=t.data.list||[])}catch{}R.value=!1}return v(async()=>{let e=await m();if(e.code===0&&(F.value=e.data||[]),P.query.category){let e=+P.query.category;I.value=e;let t=F.value.find(t=>t.id===e);t&&(z.value=t.name)}await V()}),(r,o)=>(t(),i(`div`,y,[a(p,{title:z.value||`全部商品`,onBack:o[0]||=e=>u(N).push(`/`)},null,8,[`title`]),f(`div`,b,[(t(!0),i(s,null,_(F.value,r=>(t(),i(`span`,{key:r.id,onClick:e=>B(r),class:e([`category-tag`,{active:I.value===r.id}])},n(r.name),11,x))),128))]),L.value.length===0?(t(),i(`div`,S,[(t(),i(`svg`,C,[...o[1]||=[f(`path`,{d:`M21 16V8a2 2 0 00-1-1.73l-7-4a2 2 0 00-2 0l-7 4A2 2 0 002 8v8a2 2 0 001 1.73l7 4a2 2 0 002 0l7-4A2 2 0 0021 16z`},null,-1),f(`polyline`,{points:`3.27 6.96 12 12.01 20.73 6.96`},null,-1),f(`line`,{x1:`12`,y1:`22.08`,x2:`12`,y2:`12`},null,-1)]])),f(`div`,null,n(R.value?`加载中...`:`暂无商品`),1)])):(t(),i(`div`,w,[(t(!0),i(s,null,_(L.value,e=>(t(),i(`div`,{key:e.id,onClick:t=>u(N).push(`/product/`+e.id),class:`grid-item`},[f(`div`,E,[f(`img`,{src:e.image,class:`product-list-img`,alt:``},null,8,D)]),f(`div`,O,[f(`div`,k,n(e.name),1),f(`div`,A,[f(`span`,j,`¥`+n(u(g)(e.price)),1),e.original_price&&+e.original_price>+e.price?(t(),i(`span`,M,`¥`+n(u(g)(e.original_price)),1)):c(``,!0)])])],8,T))),128))]))]))}},[[`__scopeId`,`data-v-936b031a`]]);export{N as default};