"use strict";const t=require("../../../common/vendor.js"),o=require("../sheep/index.js"),e=require("../sheep/util/index.js"),r=require("../sheep/api/product/spu.js");if(!Array){(t.resolveComponent("su-tabs")+t.resolveComponent("su-sticky")+t.resolveComponent("su-popup")+t.resolveComponent("s-goods-column")+t.resolveComponent("uni-load-more")+t.resolveComponent("s-empty")+t.resolveComponent("s-layout")+t.resolveComponent("layout-default-uni"))()}Math||((()=>"../sheep/ui/su-tabs/su-tabs.js")+(()=>"../sheep/ui/su-sticky/su-sticky.js")+(()=>"../sheep/ui/su-popup/su-popup.js")+(()=>"../sheep/components/s-goods-column/s-goods-column.js")+(()=>"../../../uni_modules/uni-load-more/components/uni-load-more/uni-load-more.js")+(()=>"../sheep/components/s-empty/s-empty.js")+(()=>"../sheep/components/s-layout/s-layout.js"))();const i={__name:"list",emits:["close","change"],setup(i,{emit:a}){const s=o.sheep.$platform.navbar,n=t.reactive({pagination:{list:[],total:0,pageNo:1,pageSize:6},currentSort:void 0,currentOrder:void 0,currentTab:0,curFilter:0,showFilter:!1,iconStatus:!1,keyword:"",categoryId:0,tabList:[{name:"综合推荐",list:[{label:"综合推荐"},{label:"价格升序",sort:"price",order:!0},{label:"价格降序",sort:"price",order:!1}]},{name:"销量",sort:"salesCount",order:!1},{name:"新品优先",value:"createTime",order:!1}],loadStatus:"",leftGoodsList:[],rightGoodsList:[]});let l=0,u=0,d=0;function c(t=0,o="left"){n.pagination.list[l]&&("left"===o?u+=t:d+=t,u<=d?n.leftGoodsList.push(n.pagination.list[l]):n.rightGoodsList.push(n.pagination.list[l]),l++)}function p(){e.resetPagination(n.pagination),n.leftGoodsList=[],n.rightGoodsList=[],l=0,u=0,d=0}function g(t){n.keyword=t,p(),h(n.currentSort,n.currentOrder)}function m(t){if(n.tabList[t.index].list)return n.currentTab=t.index,void(n.showFilter=!n.showFilter);n.showFilter=!1,t.index!==n.currentTab&&(n.currentTab=t.index,n.currentSort=t.sort,n.currentOrder=t.order,p(),h(t.sort,t.order))}function h(){return o=this,e=null,i=function*(){n.loadStatus="loading";const{code:o,data:e}=yield r.SpuApi.getSpuPage({pageNo:n.pagination.pageNo,pageSize:n.pagination.pageSize,sortField:n.currentSort,sortAsc:n.currentOrder,categoryId:n.categoryId,keyword:n.keyword});0===o&&(n.pagination.list=t.lodash.concat(n.pagination.list,e.list),n.pagination.total=e.total,n.loadStatus=n.pagination.list.length{var a=t=>{try{n(i.next(t))}catch(o){r(o)}},s=t=>{try{n(i.throw(t))}catch(o){r(o)}},n=o=>o.done?t(o.value):Promise.resolve(o.value).then(a,s);n((i=i.apply(o,e)).next())}));var o,e,i}function b(){"noMore"!==n.loadStatus&&(n.pagination.pageNo++,h(n.currentSort,n.currentOrder))}return t.onLoad((t=>{n.categoryId=t.categoryId,n.keyword=t.keyword,h(n.currentSort,n.currentOrder)})),t.onReachBottom((()=>{b()})),(e,r)=>t.e({a:t.o(m),b:t.p({list:n.tabList,scrollable:!1,current:n.currentTab}),c:n.iconStatus},(n.iconStatus,{}),{d:t.o((t=>n.iconStatus=!n.iconStatus)),e:t.p({bgColor:"#fff"}),f:t.f(n.tabList[n.currentTab].list,((o,e,r)=>({a:t.t(o.label),b:o.value,c:t.n({"filter-item-active":e===n.curFilter}),d:t.o((t=>{return o=e,void(n.currentSort!==n.tabList[0].list[o].sort||n.currentOrder!==n.tabList[0].list[o].order?(n.showFilter=!1,n.curFilter=o,n.tabList[0].name=n.tabList[0].list[o].label,n.currentSort=n.tabList[0].list[o].sort,n.currentOrder=n.tabList[0].list[o].order,p(),h()):n.showFilter=!1);var o}),o.value)}))),g:t.o((t=>n.showFilter=!1)),h:t.p({show:n.showFilter,type:"top",round:"10",space:t.unref(s)+38,backgroundColor:"#F6F6F6",zIndex:10}),i:n.iconStatus&&n.pagination.total>0},n.iconStatus&&n.pagination.total>0?{j:t.f(n.pagination.list,((e,r,i)=>({a:t.o((r=>t.unref(o.sheep).$router.go("/modules/mall/goods/index",{id:e.id})),e.id),b:"9e0ebfc6-5-"+i+",9e0ebfc6-1",c:t.p({size:"lg",data:e,topRadius:10,bottomRadius:10}),d:e.id})))}:{},{k:!n.iconStatus&&n.pagination.total>0},!n.iconStatus&&n.pagination.total>0?{l:t.f(n.leftGoodsList,((e,r,i)=>({a:t.o((r=>t.unref(o.sheep).$router.go("/modules/mall/goods/index",{id:e.id})),e.id),b:t.o((t=>c(t,"left")),e.id),c:"9e0ebfc6-6-"+i+",9e0ebfc6-1",d:t.p({size:"md",data:e,topRadius:10,bottomRadius:10}),e:e.id}))),m:t.f(n.rightGoodsList,((e,r,i)=>({a:t.o((r=>t.unref(o.sheep).$router.go("/modules/mall/goods/index",{id:e.id})),e.id),b:t.o((t=>c(t,"right")),e.id),c:"9e0ebfc6-7-"+i+",9e0ebfc6-1",d:t.p({size:"md",topRadius:10,bottomRadius:10,data:e}),e:e.id})))}:{},{n:n.pagination.total>0},n.pagination.total>0?{o:t.o(b),p:t.p({status:n.loadStatus,"content-text":{contentdown:"上拉加载更多"}})}:{},{q:0===n.pagination.total},0===n.pagination.total?{r:t.p({icon:"/static/soldout-empty.png",text:"暂无商品"})}:{},{s:t.o(g),t:t.p({navbar:"normal",leftWidth:0,rightWidth:0,tools:"search",defaultSearch:n.keyword})})}},a=t._export_sfc(i,[["__scopeId","data-v-9e0ebfc6"]]);wx.createPage(a);