"use strict";const e=require("../common/vendor.js"),u=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:!1,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){e.index.__f__("log","at pages_shop/store.vue:131","接收到的options:",o),o.liveId&&o.storeId&&(this.liveId=o.liveId,this.storeId=o.storeId||"",this.queryCollect())},mounted(){},onShow(){this.divHeight=`calc(100vh - 44px - 88rpx - ${this.statusBarHeight}px)`},methods:{mescrollInit(o){this.mescroll=o,e.index.__f__("log","at pages_shop/store.vue:148","mescroll初始化完成")},async downCallback(o){this.loading=!0;try{this.page=1,await this.queryStore(),o.endSuccess(),o.resetUpScroll()}catch(s){e.index.__f__("error","at pages_shop/store.vue:165","下拉刷新失败:",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){e.index.__f__("error","at pages_shop/store.vue:198","上拉加载失败:",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=10){return new Promise((r,n)=>{if(!this.storeId){n("storeId不存在");return}u.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;u.store(this.storeId,"",this.liveId).then(s=>{s.code==200?(e.index.__f__("log","at pages_shop/store.vue:257","查询店铺>>",s),this.storeInfo=s.data):e.index.showToast({title:s.msg,icon:"none"})}).catch(s=>{e.index.__f__("error","at pages_shop/store.vue:266","查询店铺信息失败:",s)})},rightClick(){getCurrentPages().length>1?e.index.navigateBack():e.index.redirectTo({url:"/pages/home/living"})},showProductList(o){e.index.__f__("log","at pages_shop/store.vue:283","跳到商品详情",o),e.index.navigateTo({url:"/pages_shop/goods?productId="+o.productId+"&liveId="+this.liveId+"&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 _=()=>"../uni_modules/uview-plus/components/u-icon/u-icon.js",g=()=>"../uni_modules/uview-plus/components/u-image/u-image.js",m=()=>"../uni_modules/mescroll-uni/components/mescroll-body/mescroll-body.js";Math||(_+g+m)();function f(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$7,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,a,I)=>({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:a,f:e.o(v=>l.showProductList(i),a)})),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 x=e._export_sfc(p,[["render",f],["__scopeId","data-v-dd5fc6f3"]]);wx.createPage(x); //# sourceMappingURL=../../.sourcemap/mp-weixin/pages_shop/store.js.map