import{o,c as e,r as s,z as a,Z as t,v as i,x as l,w as d,n,i as u,e as c,a as r,f as m,t as p,b as f,d as g,F as _,l as h,U as S,y as k}from"./index-4ddb689d.js";import{_ as v}from"./mp-html.2b6407c3.js";import{r as T}from"./uni-app.es.24af5d4f.js";import{W as x}from"./wxofficial.956096a5.js";import{S as C,a as y,C as w}from"./Comment.8cab973f.js";import{C as I}from"./index.cdfc996d.js";import{h as b}from"./color.813a9497.js";import{G as B}from"./index.0d19d98b.js";import{_ as P}from"./_plugin-vue_export-helper.1b428a4d.js";import{C as G}from"./index.994d85b2.js";import{p as N,d as A}from"./goods.d51b766f.js";import{t as E}from"./cart.86d426b5.js";import{A as L,G as j}from"./GoodsStatus.54b07d63.js";import"./u-popup.37b3343e.js";import"./u-icon.e981d1c2.js";import"./comment.083546cf.js";import"./index.1169d7d7.js";const V=P({components:{ShareSheet:C,CustomerBtn:I,SlideImage:y,SkuPopup:P({components:{GoodsSkuPopup:B},emits:["update:modelValue"],props:{modelValue:{Type:Boolean,default:!1},skuMode:{type:Number,default:1},active:{type:Object,default:{}},noStockText:{Type:String,default:"该商品已抢完"},goods:{type:Object,default:{}}},data:()=>({goodsInfo:{}}),computed:{activedBtnBackgroundColor(){return b(this.appTheme.mainBg,.1)}},created(){const o=this,{goods:e}=o;o.goodsInfo={_id:e.goods_id,name:e.goods_name,goods_thumb:e.goods_image,sku_list:o.getSkuList(),spec_list:o.getSpecList()}},methods:{onChangeValue(o){this.$emit("update:modelValue",o)},findGoodsInfo:()=>new Promise(((o,e)=>{o(goodsInfo)})),getSkuList(){const o=this,{goods:{goods_name:e,goods_image:s,skuList:a}}=o,t=[];return a.forEach((a=>{t.push({_id:a.id,goods_sku_id:a.goods_sku_id,goods_id:a.goods_id,goods_name:e,image:a.image_url?a.image_url:s,price:100*a.seckill_price,stock:a.seckill_stock,spec_value_ids:a.spec_value_ids,sku_name_arr:o.getSkuNameArr(a.spec_value_ids)})})),t},getSkuNameArr(o){const e=this,s=[];return o&&o.forEach(((o,a)=>{const t=e.getSpecValueName(o,a);s.push(t)})),s.length?s:["默认"]},getSpecValueName(o,e){const{goods:{specList:s}}=this;return s[e].valueList.find((e=>e.spec_value_id==o)).spec_value},getSpecList(){const{goods:{specList:o}}=this,e=[];return o.forEach((o=>{const s=[];o.valueList.forEach((o=>{s.push({name:o.spec_value})})),e.push({name:o.spec_name,list:s})})),e.length?e:[{name:"默认",list:[{name:"默认"}]}]},openSkuPopup(){},closeSkuPopup(){},buyNow(o){const e=this;e.$navTo("pages/checkout/index",{mode:"sharp",activeTimeId:e.active.active_time_id,sharpGoodsId:e.goods.sharp_goods_id,goodsSkuId:o.goods_sku_id,goodsNum:o.buy_num}),e.onChangeValue(!1)}}},[["render",function(a,t,i,l,d,n){const u=s("goods-sku-popup");return o(),e(u,{modelValue:i.modelValue,onInput:n.onChangeValue,"border-radius":"20",localdata:d.goodsInfo,mode:i.skuMode,maskCloseAble:!0,priceColor:a.appTheme.mainBg,buyNowBackgroundColor:a.appTheme.mainBg,addCartColor:a.appTheme.viceText,addCartBackgroundColor:a.appTheme.viceBg,activedStyle:{color:a.appTheme.mainBg,borderColor:a.appTheme.mainBg,backgroundColor:n.activedBtnBackgroundColor},onOpen:n.openSkuPopup,onClose:n.closeSkuPopup,onBuyNow:n.buyNow,buyNowText:"立即购买",maxBuyNum:i.goods.limit_num,noStockText:i.noStockText},null,8,["modelValue","onInput","localdata","mode","priceColor","buyNowBackgroundColor","addCartColor","addCartBackgroundColor","activedStyle","onOpen","onClose","onBuyNow","maxBuyNum","noStockText"])}]]),Comment:w,CountDown:G},mixins:[x],data:()=>({isLoading:!0,ActiveStatusEnum:L,GoodsStatusEnum:j,showSkuPopup:!1,skuMode:3,noStockText:"该商品已抢完",showShareSheet:!1,posterApiCall:N,activeTimeId:null,sharpGoodsId:null,active:{},goods:{},cartTotal:0,isShowCustomerBtn:!1}),async onLoad(o){this.onRecordQuery(o),this.onRefreshPage(),this.isShowCustomerBtn=await a.isShowCustomerBtn()},methods:{onRecordQuery(o){const e=t(o);this.activeTimeId=o.activeTimeId?parseInt(o.activeTimeId):parseInt(e.aid),this.sharpGoodsId=o.sharpGoodsId?parseInt(o.sharpGoodsId):parseInt(e.gid)},onRefreshPage(){const o=this;o.isLoading=!0,Promise.all([o.getActiveDetail(),o.getCartTotal()]).then((()=>{const e=o.active.active_status;e!=j.STATE_BEGIN.value&&(o.skuMode=4,o.noStockText=e==j.STATE_SOON.value?"活动未开始":"活动已结束"),o.setWxofficialShareData()})).finally((()=>o.isLoading=!1))},getActiveDetail(){const o=this;return new Promise(((e,s)=>{A(o.activeTimeId,o.sharpGoodsId).then((s=>{o.active=s.data.active,o.goods=s.data.goods,e(s)})).catch(s)}))},getCartTotal(){const o=this;return new Promise(((e,s)=>{E().then((s=>{o.cartTotal=s.data.cartTotal,e(s)})).catch(s)}))},onShowSkuPopup(){this.showSkuPopup=!this.showSkuPopup},onShowShareSheet(){this.showShareSheet=!this.showShareSheet},onTargetHome(o){this.$navTo("pages/index/index")},onTargetCart(){this.$navTo("pages/cart/index")},setWxofficialShareData(){const{goods:o}=this;this.updateShareCardData({title:o.goods_name,desc:o.selling_point,imgUrl:o.goods_image})}},onShareAppMessage(){const o=this,e=o.$getShareUrlParams({activeTimeId:o.activeTimeId,sharpGoodsId:o.sharpGoodsId});return{title:o.goods.goods_name,path:`/pages/sharp/goods/index?${e}`}},onShareTimeline(){const o=this,e=o.$getShareUrlParams({activeTimeId:o.activeTimeId,sharpGoodsId:o.sharpGoodsId});return{title:o.goods.goods_name,path:`/pages/sharp/goods/index?${e}`}}},[["render",function(a,t,x,C,y,w){const I=s("SlideImage"),b=h,B=u,P=S,G=s("count-down"),N=s("SkuPopup"),A=s("Comment"),E=T(k("mp-html"),v),L=s("customer-btn"),j=s("share-sheet");return i((o(),e(B,{class:"container",style:n(a.appThemeStyle)},{default:d((()=>[y.isLoading?c("",!0):(o(),e(I,{key:0,video:y.goods.video,videoCover:y.goods.videoCover,images:y.goods.goods_images},null,8,["video","videoCover","images"])),y.isLoading?c("",!0):(o(),e(B,{key:1,class:"goods-info m-top20"},{default:d((()=>[r(B,{class:"info-item info-item__top dis-flex flex-x-between flex-y-end"},{default:d((()=>[r(B,{class:"block-left dis-flex flex-y-center"},{default:d((()=>[r(B,{class:"active-tag"},{default:d((()=>[r(b,null,{default:d((()=>[m("限时秒杀")])),_:1})])),_:1}),r(b,{class:"floor-price__samll"},{default:d((()=>[m("¥")])),_:1}),r(b,{class:"floor-price"},{default:d((()=>[m(p(y.goods.seckill_price),1)])),_:1}),r(b,{class:"original-price"},{default:d((()=>[m("¥"+p(y.goods.original_price),1)])),_:1})])),_:1}),r(B,{class:"block-right dis-flex"},{default:d((()=>[r(B,{class:"goods-sales"},{default:d((()=>[r(b,null,{default:d((()=>[m("已抢"+p(y.active.sales_actual)+"件",1)])),_:1})])),_:1})])),_:1})])),_:1}),r(B,{class:"info-item info-item__name dis-flex flex-y-center"},{default:d((()=>[r(B,{class:"goods-name flex-box"},{default:d((()=>[r(b,{class:"twoline-hide"},{default:d((()=>[m(p(y.goods.goods_name),1)])),_:1})])),_:1}),r(B,{class:"goods-share__line"}),r(B,{class:"goods-share"},{default:d((()=>[r(P,{class:"share-btn dis-flex flex-dir-column",onClick:t[0]||(t[0]=o=>w.onShowShareSheet())},{default:d((()=>[r(b,{class:"share__icon iconfont icon-fenxiang"}),r(b,{class:"f-24"},{default:d((()=>[m("分享")])),_:1})])),_:1})])),_:1})])),_:1}),y.goods.selling_point?(o(),e(B,{key:0,class:"info-item info-item_selling-point"},{default:d((()=>[r(b,null,{default:d((()=>[m(p(y.goods.selling_point),1)])),_:1})])),_:1})):c("",!0),y.active.active_status!=y.GoodsStatusEnum.STATE_END.value?(o(),e(B,{key:1,class:"info-item info-item_status info-item_countdown dis-flex flex-y-center"},{default:d((()=>[r(b,{class:"countdown-icon iconfont icon-naozhong"}),r(b,null,{default:d((()=>[m("距离秒杀"+p(y.active.active_status==y.GoodsStatusEnum.STATE_SOON.value?"开始":"结束"),1)])),_:1}),r(b,{class:"m-r-10"},{default:d((()=>[m("还剩")])),_:1}),r(G,{date:y.active.count_down_time,separator:"zh",theme:"text"},null,8,["date"])])),_:1})):(o(),e(B,{key:2,class:"info-item info-item_status info-item_end"},{default:d((()=>[r(b,{class:"countdown-icon iconfont icon-naozhong"}),r(b,null,{default:d((()=>[m("秒杀活动已结束,下次记得早点来哦~")])),_:1})])),_:1}))])),_:1})),20==y.goods.spec_type?(o(),e(B,{key:2,class:"goods-choice m-top20 b-f",onClick:t[1]||(t[1]=o=>w.onShowSkuPopup())},{default:d((()=>[r(B,{class:"spec-list"},{default:d((()=>[r(B,{class:"flex-box"},{default:d((()=>[r(b,{class:"col-8"},{default:d((()=>[m("选择:")])),_:1}),(o(!0),f(_,null,g(y.goods.specList,((s,a)=>(o(),e(b,{class:"spec-name",key:a},{default:d((()=>[m(p(s.spec_name),1)])),_:2},1024)))),128))])),_:1}),r(B,{class:"f-26 col-9 t-r"},{default:d((()=>[r(b,{class:"iconfont icon-arrow-right"})])),_:1})])),_:1})])),_:1})):c("",!0),y.isLoading?c("",!0):(o(),e(N,{key:3,modelValue:y.showSkuPopup,"onUpdate:modelValue":t[2]||(t[2]=o=>y.showSkuPopup=o),skuMode:y.skuMode,active:y.active,goods:y.goods,noStockText:y.noStockText},null,8,["modelValue","skuMode","active","goods","noStockText"])),y.isLoading?c("",!0):(o(),e(A,{key:4,"goods-id":y.goods.goods_id,limit:2},null,8,["goods-id"])),y.isLoading?c("",!0):(o(),e(B,{key:5,class:"goods-content m-top20"},{default:d((()=>[r(B,{class:"item-title b-f"},{default:d((()=>[r(b,null,{default:d((()=>[m("商品描述")])),_:1})])),_:1}),""!=y.goods.content?(o(),e(B,{key:0,class:"goods-content__detail b-f"},{default:d((()=>[r(E,{content:y.goods.content},null,8,["content"])])),_:1})):c("",!0)])),_:1})),r(B,{class:"footer-fixed"},{default:d((()=>[r(B,{class:"footer-container"},{default:d((()=>[r(B,{class:"foo-item-fast"},{default:d((()=>[r(B,{class:"fast-item fast-item--home",onClick:w.onTargetHome},{default:d((()=>[r(B,{class:"fast-icon"},{default:d((()=>[r(b,{class:"iconfont icon-shouye"})])),_:1}),r(B,{class:"fast-text"},{default:d((()=>[r(b,null,{default:d((()=>[m("首页")])),_:1})])),_:1})])),_:1},8,["onClick"]),y.isShowCustomerBtn?(o(),e(L,{key:0},{default:d((()=>[r(B,{class:"fast-item"},{default:d((()=>[r(B,{class:"fast-icon"},{default:d((()=>[r(b,{class:"iconfont icon-kefu1"})])),_:1}),r(B,{class:"fast-text"},{default:d((()=>[r(b,null,{default:d((()=>[m("客服")])),_:1})])),_:1})])),_:1})])),_:1})):c("",!0),y.isShowCustomerBtn?c("",!0):(o(),e(B,{key:1,class:"fast-item fast-item--cart",onClick:w.onTargetCart},{default:d((()=>[y.cartTotal>0?(o(),e(B,{key:0,class:"fast-badge fast-badge--fixed"},{default:d((()=>[m(p(y.cartTotal>99?"99+":y.cartTotal),1)])),_:1})):c("",!0),r(B,{class:"fast-icon"},{default:d((()=>[r(b,{class:"iconfont icon-gouwuche"})])),_:1}),r(B,{class:"fast-text"},{default:d((()=>[r(b,null,{default:d((()=>[m("购物车")])),_:1})])),_:1})])),_:1},8,["onClick"]))])),_:1}),r(B,{class:"foo-item-btn"},{default:d((()=>[r(B,{class:"btn-wrapper"},{default:d((()=>[y.active.active_status==y.GoodsStatusEnum.STATE_BEGIN.value?(o(),e(B,{key:0,class:"btn-item btn--main",onClick:t[3]||(t[3]=o=>w.onShowSkuPopup())},{default:d((()=>[r(b,null,{default:d((()=>[m("立即购买")])),_:1})])),_:1})):(o(),e(P,{key:1,class:"btn-item btn--gray"},{default:d((()=>[r(b,null,{default:d((()=>[m(p(y.active.active_status==y.GoodsStatusEnum.STATE_SOON.value?"活动未开始":"活动已结束"),1)])),_:1})])),_:1}))])),_:1})])),_:1})])),_:1})])),_:1}),r(j,{modelValue:y.showShareSheet,"onUpdate:modelValue":t[4]||(t[4]=o=>y.showShareSheet=o),shareTitle:y.goods.goods_name,shareImageUrl:y.goods.goods_image,posterApiCall:y.posterApiCall,posterApiParam:{activeTimeId:y.activeTimeId,sharpGoodsId:y.sharpGoodsId}},null,8,["modelValue","shareTitle","shareImageUrl","posterApiCall","posterApiParam"])])),_:1},8,["style"])),[[l,!y.isLoading]])}],["__scopeId","data-v-3506a21f"]]);export{V as default};