import{r as a,o as l,n as e,c as s,b as t,d as o,e as c,f as u,w as i,g as d,_ as n,l as r,t as p,v as f,j as v,z as _,x as g,h as m,i as h,F as x,k as y,y as k,p as b,A as w,B as C}from"./index-DVkgSHpn.js";import{_ as j}from"./el-navbar.DVIyjZEN.js";import{_ as P,b as H,a as z}from"./el-layout._U-vZTft.js";import{_ as R}from"./el-refresh.CkIPFmzm.js";import"./el-empty.CMLN1lgh.js";import"./el-loading-icon.Bh3RKCou.js";const S=P({__name:"index",setup(P){const S=a(0),$=a(),A=a(0);l((a=>{S.value=a.id||0,e((()=>{D()}))}));const B=a([]),D=async()=>{var a;null==(a=$.value)||a.resetPage()},F=s((()=>{const{windowHeight:a}=y();return a-A.value})),I=()=>{D()},M=a=>{$.value.isMore()&&($.value.loadingPage(),setTimeout((()=>{uni.$http.get("goods.index/index",{cat_id:S.value,page:a.page,type:T.value,order:U.value?"desc":"asc"}).then((l=>{1==l.code?(1==a.page&&(B.value=[]),$.value.setData(l.data.total,l.data.list.length),B.value=B.value.concat(l.data.list)):-1==l.code&&(1==a.page&&l.data.list.length<=0&&(B.value=[]),$.value.emptyPage())}))}),100))},T=a("all"),U=a(!1),V=a=>{T.value=a,U.value="price"!=a||!U.value,"price"!=a&&(U.value=!0),D()},W=a("grid"),X=a=>{W.value=a};return(a,l)=>{const e=t(o("el-navbar"),j),s=t(o("uni-icons"),H),y=k,P=b,S=C,D=t(o("el-refresh"),R),q=t(o("el-layout"),z);return c(),u(q,null,{default:i((()=>[d(e,{top:A.value,"onUpdate:top":l[0]||(l[0]=a=>A.value=a),placeholder:!0,fixed:!0,border:!1,title:"商品列表"},null,8,["top"]),d(P,{class:"search",style:g({top:A.value+"px"})},{default:i((()=>[d(P,{class:"top"},{default:i((()=>[d(P,{class:"search-wrap",onClick:l[1]||(l[1]=n((a=>r(p)("pages/search/index")),["stop"]))},{default:i((()=>[d(P,{class:"search-box"},{default:i((()=>[d(s,{type:"search",size:"18",color:"#6d6d6d"}),d(y,null,{default:i((()=>[f("搜索商品")])),_:1})])),_:1})])),_:1}),d(P,{class:"menu"},{default:i((()=>["grid"==W.value?(c(),u(P,{key:0,onClick:l[2]||(l[2]=n((a=>X("list")),["stop"])),class:"iconfont icon-grid"})):v("",!0),"list"==W.value?(c(),u(P,{key:1,onClick:l[3]||(l[3]=n((a=>X("grid")),["stop"])),class:"iconfont icon-list"})):v("",!0)])),_:1})])),_:1}),d(P,{class:"bottom"},{default:i((()=>[d(P,{class:_(["item-box",{active:"all"==T.value}]),onClick:l[4]||(l[4]=n((a=>V("all")),["stop"]))},{default:i((()=>[d(y,null,{default:i((()=>[f("综合")])),_:1})])),_:1},8,["class"]),d(P,{class:_(["item-box",{active:"sales"==T.value}]),onClick:l[5]||(l[5]=n((a=>V("sales")),["stop"]))},{default:i((()=>[d(y,null,{default:i((()=>[f("销量")])),_:1})])),_:1},8,["class"]),d(P,{class:_(["item-box",{active:"price"==T.value}]),onClick:l[6]||(l[6]=n((a=>V("price")),["stop"]))},{default:i((()=>[d(y,null,{default:i((()=>[f("价格")])),_:1}),d(P,{class:"menu"},{default:i((()=>[d(P,{class:_(["icon up",{active:"price"==T.value&&!U.value}])},{default:i((()=>[d(y,{class:"iconfont icon-arrow-top"})])),_:1},8,["class"]),d(P,{class:_(["icon down",{active:"price"==T.value&&U.value}])},{default:i((()=>[d(y,{class:"iconfont icon-arrow-bottom"})])),_:1},8,["class"])])),_:1})])),_:1},8,["class"])])),_:1})])),_:1},8,["style"]),d(P,{style:{width:"100%",height:"82px"}}),d(D,{ref_key:"refreshRef",ref:$,onRefresh:I,onScrolltolower:M,scrollHeight:F.value},{default:i((()=>[d(P,{class:"wrapper"},{default:i((()=>[d(P,{class:_(["goods",{on:"list"==W.value}])},{default:i((()=>[d(P,{class:_(["goods-list",{on:"list"==W.value}])},{default:i((()=>[(c(!0),m(x,null,h(B.value,((a,l)=>(c(),u(P,{class:_(["goods-item",{on:"list"==W.value}]),key:l,onClick:l=>r(p)(`/pages/goods/view?id=${a.id}`)},{default:i((()=>[d(P,{class:"thumb-image"},{default:i((()=>[d(S,{src:a.image},null,8,["src"])])),_:2},1024),d(P,{class:"goods-text"},{default:i((()=>[d(P,{class:"goods-name"},{default:i((()=>[f(w(a.name),1)])),_:2},1024),d(P,{class:"price"},{default:i((()=>[d(P,null,{default:i((()=>[d(y,null,{default:i((()=>[f("￥")])),_:1}),f(w(a.sell_price),1)])),_:2},1024)])),_:2},1024),d(P,{class:"unit"},{default:i((()=>[f(" 已售 "+w(a.sale)+" "+w(a.unit||"件"),1)])),_:2},1024)])),_:2},1024)])),_:2},1032,["class","onClick"])))),128))])),_:1},8,["class"])])),_:1},8,["class"])])),_:1})])),_:1},8,["scrollHeight"])])),_:1})}}},[["__scopeId","data-v-da241f8d"]]);export{S as default};
//# sourceMappingURL=pages-goods-index.CNJ1mrLY.js.map
