"use strict";const e=require("../../../../common/vendor.js"),a=require("../../../../sheep/index.js"),o=require("../../../../sheep/hooks/useGoods.js"),d=require("../../../../sheep/hooks/useModal.js"),t=require("../../../../sheep/api/promotion/combination.js"),r=require("../../../../sheep/api/product/spu.js");if(!Array){(e.resolveComponent("s-goods-item")+e.resolveComponent("s-select-groupon-sku")+e.resolveComponent("s-empty")+e.resolveComponent("s-layout")+e.resolveComponent("layout-default-uni"))()}Math||((()=>"../../../../sheep/components/s-goods-item/s-goods-item.js")+(()=>"../../../../sheep/components/s-select-groupon-sku/s-select-groupon-sku.js")+(()=>"../../../../sheep/components/s-empty/s-empty.js")+(()=>"../../../../sheep/components/s-layout/s-layout.js"))();const s={__name:"detail",setup(s){e.useCssVars((a=>({"3ce32533":e.unref(i)})));const i=a.sheep.$url.css("/static/img/shop/user/withdraw_bg.png"),n=2*a.sheep.$platform.device.statusBarHeight,c=e.reactive({data:{},goodsId:0,goodsInfo:{},showSelectSku:!1,selectedSkuPrice:{},activity:{},grouponId:0,grouponNum:0,grouponAction:"create",combinationHeadId:null,loading:!0}),u=e.computed((()=>{var d;return e.isEmpty(c.data)?{}:a.sheep.$platform.share.getShareInfo({title:c.data.headRecord.spuName,image:a.sheep.$url.cdn(c.data.headRecord.picUrl),desc:null==(d=c.data.goods)?void 0:d.subtitle,params:{page:"5",query:c.data.headRecord.id}},{type:"groupon",title:c.data.headRecord.spuName,image:a.sheep.$url.cdn(c.data.headRecord.picUrl),price:o.fen2yuan(c.data.headRecord.combinationPrice)})}));function p(e){a.sheep.$router.go("/modules/mall/order/detail",{id:e})}function m(){c.grouponAction="create",c.grouponId=0,c.showSelectSku=!0}function h(e){c.selectedSkuPrice=e}function l(e){a.sheep.$router.go("/modules/mall/order/confirm",{data:JSON.stringify({order_type:"goods",combinationActivityId:c.activity.id,combinationHeadId:c.combinationHeadId,items:[{skuId:e.id,count:e.count}]})})}const g=e.computed((()=>o.useDurationTime(c.data.headRecord.expireTime)));function R(e){return a=this,o=null,d=function*(){const{code:a,data:o}=yield t.CombinationApi.getCombinationRecordDetail(e);if(0===a){c.data=o;const e=Number(c.data.headRecord.userSize-c.data.headRecord.userCount);c.remainNumber=e>0?e:0;const{data:a}=yield t.CombinationApi.getCombinationActivity(o.headRecord.activityId);c.activity=a,c.grouponNum=a.userSize;const{data:d}=yield r.SpuApi.getSpuDetail(a.spuId);c.goodsId=d.id,a.products.forEach((e=>{d.price=Math.min(d.price,e.combinationPrice)})),c.goodsInfo=d,d.skus.forEach((e=>{const o=a.products.find((a=>a.skuId===e.id));o?e.price=o.combinationPrice:e.stock=0}))}else c.data=null;c.loading=!1},new Promise(((e,t)=>{var r=e=>{try{i(d.next(e))}catch(a){t(a)}},s=e=>{try{i(d.throw(e))}catch(a){t(a)}},i=a=>a.done?e(a.value):Promise.resolve(a.value).then(r,s);i((d=d.apply(a,o)).next())}));var a,o,d}function I(){d.showShareModal()}return e.onLoad((e=>{R(e.id)})),(o,d)=>e.e({a:c.loading},(c.loading,{}),{b:c.data&&!c.loading},c.data&&!c.loading?e.e({c:c.data.headRecord},c.data.headRecord?{d:e.t(c.data.headRecord.userSize),e:e.t(c.data.headRecord.userCount),f:e.o((o=>e.unref(a.sheep).$router.go("/modules/mall/goods/groupon",{id:c.data.headRecord.activityId}))),g:e.s({top:Number(n+108)+"rpx"}),h:e.p({img:c.data.headRecord.picUrl,title:c.data.headRecord.spuName,price:c.data.headRecord.combinationPrice,priceColor:"#E1212B"}),i:e.s({marginTop:"-"+Number(n+88)+"rpx",paddingTop:Number(n+108)+"rpx"})}:{},{j:1===c.data.headRecord.status},1===c.data.headRecord.status?e.e({k:c.data.orderId},(c.data.orderId,{})):{},{l:2===c.data.headRecord.status},2===c.data.headRecord.status?{m:e.t(c.data.orderId?"拼团超时,已自动退款":"该团已解散")}:{},{n:0===c.data.headRecord.status},0===c.data.headRecord.status?e.e({o:c.data.headRecord.expireTime<=(new Date).getTime()},c.data.headRecord.expireTime<=(new Date).getTime()?{}:{p:e.t(c.data.headRecord.userSize-c.data.headRecord.userCount),q:e.t(g.value.h),r:e.t(g.value.m),s:e.t(g.value.s)}):{},{t:e.unref(a.sheep).$url.cdn(c.data.headRecord.avatar),v:e.f(c.data.memberRecords,((o,d,t)=>e.e({a:e.unref(a.sheep).$url.cdn(o.avatar),b:"1"==o.is_leader},(o.is_leader,{}),{c:o.id}))),w:e.f(c.remainNumber,((e,a,o)=>({a:e}))),x:e.unref(a.sheep).$url.static("/static/img/shop/avatar/unknown.png"),y:1===c.data.headRecord.status||2===c.data.headRecord.status},1===c.data.headRecord.status||2===c.data.headRecord.status?e.e({z:c.data.orderId},c.data.orderId?{A:e.o((e=>p(c.data.orderId)))}:{B:e.o(m)}):{},{C:0===c.data.headRecord.status},0===c.data.headRecord.status?e.e({D:c.data.headRecord.expireTime<=(new Date).getTime()},c.data.headRecord.expireTime<=(new Date).getTime()?e.e({E:c.data.orderId},c.data.orderId?{F:e.o((e=>p(c.data.orderId)))}:{G:e.o((e=>p(c.data.orderId)))}):e.e({H:c.data.orderId},c.data.orderId?{I:g.value.ms<=0,J:e.o(I)}:{K:g.value.ms<=0,L:e.o((e=>(c.grouponAction="join",c.grouponId=c.data.headRecord.activityId,c.combinationHeadId=c.data.headRecord.id,c.grouponNum=c.data.headRecord.userSize,void(c.showSelectSku=!0))))})):{},{M:!e.unref(e.isEmpty)(c.goodsInfo)},e.unref(e.isEmpty)(c.goodsInfo)?{}:{N:e.o(l),O:e.o(h),P:e.o((e=>c.showSelectSku=!1)),Q:e.p({show:c.showSelectSku,goodsInfo:c.goodsInfo,grouponAction:c.grouponAction,grouponNum:c.grouponNum})}):{},{R:!c.data&&!c.loading},c.data||c.loading?{}:{S:e.p({icon:"/static/goods-empty.png"})},{T:e.p({title:"拼团详情",navbar:c.data&&!c.loading?"inner":"normal",onShareAppMessage:u.value}),U:e.s(o.__cssVars())})}},i=e._export_sfc(s,[["__scopeId","data-v-12408d46"]]);s.__runtimeHooks=2,wx.createPage(i);