import{c as I,m as f,b as T,t as D,d as w,r as x,be as G,a as t,I as C,C as A,k as N,D as W,A as d,U as O,b2 as H,F as R,bf as V,Q as E,a3 as F}from"./index-521a9826.js";import{A as $}from"./index-c783d99f.js";import{s as S}from"./index-a8eb0bce.js";import{S as M,a as q}from"./index-5b82f39e.js";import{I as j}from"./index-25b5c9d0.js";import{C as J}from"./index-9b272659.js";import{C as k}from"./index-1ad6a58d.js";import{R as z,C as y}from"./index-163db0a7.js";import{R as U,a as Q}from"./index-7811aba5.js";import{T as K}from"./index-544f4e19.js";import"./student-register-store-b6550ec0.js";import"./index-62c45bca.js";import"./Checker-1ada2d85.js";const[X,u,Y]=I("submit-bar"),Z={tip:String,label:String,price:Number,tipIcon:String,loading:Boolean,currency:f("¥"),disabled:Boolean,textAlign:String,buttonText:String,buttonType:f("danger"),buttonColor:String,suffixLabel:String,placeholder:Boolean,decimalLength:T(2),safeAreaInsetBottom:D};var tt=w({name:X,props:Z,emits:["submit"],setup(e,{emit:i,slots:s}){const o=x(),r=G(o,u),c=()=>{const{price:l,label:n,currency:p,textAlign:L,suffixLabel:b,decimalLength:_}=e;if(typeof l=="number"){const g=(l/100).toFixed(+_).split("."),B=_?`.${g[1]}`:"";return t("div",{class:u("text"),style:{textAlign:L}},[t("span",null,[n||Y("label")]),t("span",{class:u("price")},[p,t("span",{class:u("price-integer")},[g[0]]),B]),b&&t("span",{class:u("suffix-label")},[b])])}},h=()=>{var l;const{tip:n,tipIcon:p}=e;if(s.tip||n)return t("div",{class:u("tip")},[p&&t(C,{class:u("tip-icon"),name:p},null),n&&t("span",{class:u("tip-text")},[n]),(l=s.tip)==null?void 0:l.call(s)])},v=()=>i("submit"),P=()=>s.button?s.button():t(A,{round:!0,type:e.buttonType,text:e.buttonText,class:u("button",e.buttonType),color:e.buttonColor,loading:e.loading,disabled:e.disabled,onClick:v},null),m=()=>{var l,n;return t("div",{ref:o,class:[u(),{"van-safe-area-bottom":e.safeAreaInsetBottom}]},[(l=s.top)==null?void 0:l.call(s),h(),t("div",{class:u("bar")},[(n=s.default)==null?void 0:n.call(s),c(),P()])])};return()=>e.placeholder?r(m):m()}});const et=N(tt),ot="_arrowLeft_ub7u2_1",st="_swipeItemImg_ub7u2_12",at="_swipe_ub7u2_12",rt="_goodsHead_ub7u2_28",it="_priceGroup_ub7u2_35",ct="_price_ub7u2_35",ut="_delPrice_ub7u2_48",lt="_stock_ub7u2_54",nt="_goodsName_ub7u2_58",dt="_row_ub7u2_64",pt="_col_ub7u2_68",ht="_radio_ub7u2_72",mt="_badge_ub7u2_113",bt="_section_ub7u2_117",_t="_detail_ub7u2_121",gt="_photoDetail_ub7u2_146",ft="_goodsDetail_ub7u2_150",St="_actionBar_ub7u2_153",kt="_text_ub7u2_175",yt="_addCertBtn_ub7u2_180",wt="_buyGroup_ub7u2_190",Ct="_selectWrap_ub7u2_196",vt="_shareBtn_ub7u2_202",Pt="_shareWrap_ub7u2_208",Lt="_sharePic_ub7u2_218",Bt="_shareLeft_ub7u2_223",It="_shareRight_ub7u2_226",Tt="_shareShopTitle_ub7u2_230",Dt="_shareShopDes_ub7u2_240",xt="_shareShopValue_ub7u2_249",Gt="_shareShopOldPrice_ub7u2_253",At="_imagesOverlayWrap_ub7u2_260",a={arrowLeft:ot,swipeItemImg:st,swipe:at,"custom-indicator":"_custom-indicator_ub7u2_18",goodsHead:rt,priceGroup:it,price:ct,delPrice:ut,stock:lt,goodsName:nt,row:dt,col:pt,"radio-group":"_radio-group_ub7u2_72",radio:ht,badge:mt,section:bt,detail:_t,photoDetail:gt,goodsDetail:ft,actionBar:St,text:kt,addCertBtn:yt,buyGroup:wt,selectWrap:Ct,shareBtn:vt,shareWrap:Pt,sharePic:Lt,shareLeft:Bt,shareRight:It,shareShopTitle:Tt,shareShopDes:Dt,shareShopValue:xt,shareShopOldPrice:Gt,imagesOverlayWrap:At};function Nt(e){return typeof e=="function"||Object.prototype.toString.call(e)==="[object Object]"&&!F(e)}const Ut=w({name:"goods-detail",data(){return{id:this.$route.query.id,albumPics:[],product:{},radio:0,skuStockListTemp:[],detailMobileHtml:"",loading:!1,addGoodsShow:!1,selectGoodsItem:{},cartCount:0}},computed:{skuStockList(){const e=this.product,i=this.skuStockListTemp.length>0?this.skuStockListTemp:[{id:-1,price:e.price,pic:e.pic,stock:e.stock,spData:null}];return i.forEach(s=>{if(s.spData){const o=JSON.parse(s.spData);s.spDataJson=o.reduce((r,c)=>(r+=c.value,r),""),s.sku=o.reduce((r,c)=>(r.push(`${c.key}: ${c.value}`),r),[]).join(",")}else s.spDataJson="默认"}),i},getPrice(){let e=this.skuStockList.filter(i=>i.id==this.radio);return e&&Array.isArray(e)&&e.length?e[0].price:0}},async mounted(){try{this.loading=!0;const e=await W.get(`/edu-app/open/mall/product/detail/${this.id}`,{noAuthorization:!0});this.loading=!1;const i=e.data||{};if(this.albumPics=[i.product.pic].concat(i.product.albumPics.split(",")).filter(s=>s),this.product=i.product,this.skuStockListTemp=i.skuStockList||[],this.skuStockListTemp.length){let s=this.skuStockListTemp.length;for(let o=0;o=0){this.radio=r.id;break}}}this.detailMobileHtml=i.product.detailMobileHtml}catch(e){}},methods:{onPreview(e){S({images:this.albumPics,startPosition:e,closeable:!0,className:a.imagesOverlayWrap})},onShowImg(e){const{localName:i}=e.srcElement;if(i!=="img")return;let s=0;const o=document.querySelectorAll(".msgWrap img");let r=Array.from(o).map((c,h)=>(e.srcElement==c&&(s=h),c.src));S({images:r,startPosition:s,closeable:!0,className:a.imagesOverlayWrap})},onShowCart(){this.selectGoodsItem={price:this.product.price,originalPrice:this.product.originalPrice,pic:this.product.pic,stock:this.product.stock,skuStockList:this.skuStockListTemp.length?this.skuStockListTemp:void 0,brandName:this.product.brandName,productCategoryId:this.product.productCategoryId,name:this.product.name,productSn:this.product.productSn,productSubTitle:this.product.subTitle,id:this.product.id},this.addGoodsShow=!0}},render(){let e;const i=this.product,s=this.skuStockList.find(o=>o.id===this.radio);return t("div",{class:a.goodsDetail},[t(C,{class:a.arrowLeft,name:"arrow-left",onClick:o=>{o.stopPropagation(),this.$router.back()}},null),t(M,{class:a.swipe,lazyRender:!0},{default:()=>[this.albumPics.map((o,r)=>t(q,null,{default:()=>[t(j,{class:a.swipeItemImg,src:o,onClick:()=>this.onPreview(r),fit:"cover"},null)]}))],indicator:o=>o.total>1&&t("div",{class:a["custom-indicator"]},[(o.active||0)+1,d(" / "),o.total])}),t(J,{border:!1,class:[a.goodsHead,"mb12"]},{default:()=>[t(k,{center:!0,border:!1},{title:()=>t("div",{class:a.priceGroup},[t("span",{class:a.price},[t("i",null,[d("¥")]),O(this.getPrice)])])}),t(k,{center:!0,border:!1,title:i.name,titleClass:[a.goodsName,"van-ellipsis"]},null)]}),t(z,{class:[a.row,"mb12"]},{default:()=>[t(y,{span:4,class:a.col},{default:()=>[d("规格")]}),t(y,{span:20},{default:()=>[s?t("div",{class:a.selectWrap},[s.stock<=0?"当前款式暂时缺货":`已选择 ${s.spDataJson}`]):t("div",null,[d("请选择 规格")]),t(U,{class:a["radio-group"],modelValue:this.radio,"onUpdate:modelValue":o=>this.radio=o},Nt(e=this.skuStockList.map(o=>{const r=o.id===this.radio,c=r?"primary":"default";return t(H,{position:"top-right",content:o.stock<=0?"缺货":"",color:"#999999",class:a.badge,offset:[-20,0]},{default:()=>[t(Q,{class:a.radio,name:o.id,disabled:o.stock<=0,onClick:()=>{o.stock<=0||(this.radio=o.id)}},{default:()=>[t(K,{size:"large",plain:r,type:c},{default:()=>[o.spDataJson]})]})]})}))?e:{default:()=>[e]})]})]}),this.detailMobileHtml&&t("div",{class:[a.section]},[t("div",{class:a.detail},[t("span",null,[d("图文详情")])]),t("div",{class:[a.photoDetail,"msgWrap"],onClick:this.onShowImg,innerHTML:this.detailMobileHtml},null)]),!this.loading&&t(R,null,[t(et,{class:a.actionBar,"safe-area-inset-bottom":!0},{button:()=>t("div",{class:a.buyGroup},[t(V,{type:"primary",class:a.addCertBtn,text:"添加购买",onClick:()=>this.onShowCart()},null)])})]),t(E,{show:this.addGoodsShow,closeable:!0,position:"bottom",round:!0,onClose:()=>{this.addGoodsShow=!1}},{default:()=>[t($,{show:this.addGoodsShow,item:this.selectGoodsItem,onClose:()=>{this.addGoodsShow=!1},defaultRadio:this.radio,showType:"cart"},null)]})])}});export{Ut as default};