"use strict";const e=require("../common/vendor.js"),a=require("../api/live.js"),d=require("../uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js"),h=require("../common/assets.js"),p={mixins:[d.MescrollMixin],data(){return{page:1,pageSize:6,total:0,loading:!1,mescroll:null,downOption:{use:!0,auto:!0,offset:80,textinoffset:"下拉刷新",textoutoffset:"释放更新",textloading:"加载中..."},upOption:{use:!0,auto:!0,page:{num:0,size:6},noMoreSize:6,textLoading:"加载中...",textNoMore:"-- 没有更多数据了 --",empty:{use:!1,icon:"",tip:""}},inputInfo:"",searchTimer:null,products:[],liveId:null,storeId:"",statusBarHeight:e.index.getWindowInfo().statusBarHeight,storeInfo:{}}},onLoad(o){console.log("接收到的options:",o),o.liveId&&(this.liveId=o.liveId),o.storeId?(this.storeId=o.storeId||"",this.queryCollect()):e.index.showToast({title:"storeId不存在~",icon:"none"})},mounted(){},onShow(){this.divHeight=`calc(100vh - 44px - 88rpx - ${this.statusBarHeight}px)`},methods:{mescrollInit(o){this.mescroll=o,console.log("mescroll初始化完成")},async downCallback(o){this.loading=!0;try{this.page=1,await this.queryStore(),o.endSuccess(),o.resetUpScroll()}catch(s){console.error("下拉刷新失败:",s),o.endErr()}finally{this.loading=!1}},async upCallback(o){this.loading=!0;try{const s=o.num,r=o.size,n=await this.queryStore(s,r),t=n.rows||[];s==1&&(this.products=[]),this.products=this.products.concat(t),this.mescroll.endBySize(t.length,n.total)}catch(s){console.error("上拉加载失败:",s),this.mescroll.endErr()}finally{this.loading=!1}},handleSearchInput(){clearTimeout(this.searchTimer),this.searchTimer=setTimeout(()=>{this.page=1,this.mescroll.resetUpScroll(!0)},500)},getPureDecimal(o,s=6){if(!o&&o!==0)return"00";const r=Math.abs(o).toFixed(s).split(".")[1];return(r==null?void 0:r.replace(/0+$/,""))||"00"},async queryStore(o=1,s=6){return new Promise((r,n)=>{if(!this.storeId){n("storeId不存在");return}a.queryStore(this.storeId,s,o,this.inputInfo).then(t=>{t.code==200?r(t):(e.index.showToast({title:t.msg||"加载失败",icon:"none"}),n(t.msg))}).catch(t=>{e.index.showToast({title:"加载失败",icon:"none"}),n(t)})})},queryCollect(){if(!this.storeId)return;a.store(this.storeId,"").then(s=>{s.code==200?(console.log("查询店铺>>",s),this.storeInfo=s.data):e.index.showToast({title:s.msg,icon:"none"})}).catch(s=>{console.error("查询店铺信息失败:",s)})},rightClick(){getCurrentPages().length>1?e.index.navigateBack():e.index.redirectTo({url:"/pages/home/living"})},showProductList(o){e.index.navigateTo({url:"/pages_shop/goods?productId="+o.productId+"&liveId="+this.liveId+"&goodsId="+o.goodsId+"&storeId="+this.storeId})}}};if(!Array){const o=e.resolveComponent("u-icon"),s=e.resolveComponent("u-image"),r=e.resolveComponent("mescroll-body"),n=e.resolveComponent("u-loading");(o+s+r+n)()}const g=()=>"../uni_modules/uview-plus/components/u-icon/u-icon.js",m=()=>"../uni_modules/uview-plus/components/u-image/u-image.js",f=()=>"../uni_modules/mescroll-uni/components/mescroll-body/mescroll-body.js";Math||(g+m+f)();function _(o,s,r,n,t,l){var c;return e.e({a:t.statusBarHeight+"px",b:e.o(l.rightClick),c:e.p({name:"arrow-left",color:"#ffffff",size:"20"}),d:h._imports_0$9,e:e.o([i=>t.inputInfo=i.detail.value,(...i)=>l.handleSearchInput&&l.handleSearchInput(...i)]),f:t.inputInfo,g:e.p({shape:"square",src:(c=t.storeInfo)==null?void 0:c.logoUrl,width:"100rpx",height:"100rpx",radius:"6"}),h:e.t(t.storeInfo.storeName||""),i:e.t(t.storeInfo.salesCount),j:t.storeInfo.storeName,k:e.f(t.products,(i,u,y)=>({a:i.imgUrl,b:e.t(i.productName),c:e.t(Math.trunc(i.price)),d:e.t(l.getPureDecimal(i.price)?l.getPureDecimal(i.price):"00"),e:u,f:e.o(x=>l.showProductList(i),u)})),l:t.products.length===0&&!t.loading},t.products.length===0&&!t.loading?{}:{},{m:e.sr("mescrollRef","dd5fc6f3-2"),n:e.o(l.mescrollInit),o:e.o(l.downCallback),p:e.o(l.upCallback),q:e.p({top:`calc(${t.statusBarHeight}px + 88rpx + 240rpx)`,bottom:"0",down:t.downOption,up:t.upOption}),r:t.loading},t.loading?{s:e.p({mode:"circle",size:"40",color:"#FF5C03"})}:{})}const I=e._export_sfc(p,[["render",_],["__scopeId","data-v-dd5fc6f3"]]);wx.createPage(I);