import{d as f,f as c,g as d,v as u,n as p,D as b,y as S,j as o,A as l,bA as w,aw as D,B as k,$ as I}from"./ResizeObserver.es.f28023e0.js";import{S as C,a as P}from"./index.966d1893.js";import{I as T}from"./index.7a1af785.js";import{C as v}from"./index.2a22730e.js";import{C as m}from"./index.3b2e70c8.js";import{I as _}from"./index.d188aaf8.js";import{R as $,a as x}from"./index.697873a0.js";import"./index.49ee134a.js";import{T as B}from"./index.af901340.js";import{R as q,C as h}from"./index.00276806.js";import{C as E}from"./index.8c937010.js";import{s as y}from"./share.630c329d.js";import{getAssetsHomeFile as H}from"./index.3bea542d.js";import"./index.9a41251d.js";import"./icon_discount.535f7618.js";import"./share-vip-tips.16c5753d.js";import"./share-banner.3808bbad.js";import"./wx_bg.cce2a6c0.js";import"./index.46d36266.js";import"./bars.4f1962a6.js";import"./icon_album_active.a67a159e.js";import"./icon_music_active.5a84cf57.js";import"./index.07a2a95f.js";import"./index.d9fd7ad5.js";import"./icon_teacher.40b6f077.js";import"./icon_timer2.5fb1750d.js";import"./icon-jiaozi.20e415ca.js";const L="_swipeItemImg_i7yn2_1",N="_swipe_i7yn2_1",A="_goodsHead_i7yn2_17",W="_priceGroup_i7yn2_24",G="_price_i7yn2_24",V="_delPrice_i7yn2_37",R="_stock_i7yn2_43",z="_goodsName_i7yn2_47",M="_row_i7yn2_53",O="_col_i7yn2_57",j="_radio_i7yn2_61",F="_badge_i7yn2_96",J="_section_i7yn2_100",U="_detail_i7yn2_104",K="_photoDetail_i7yn2_129",Q="_goodsDetail_i7yn2_133",X="_actionBar_i7yn2_136",Y="_addCertBtn_i7yn2_157",Z="_buyGroup_i7yn2_161",tt="_selectWrap_i7yn2_171",ot="_shareBtn_i7yn2_177",et="_shareWrap_i7yn2_183",st="_sharePic_i7yn2_193",it="_shareLeft_i7yn2_198",at="_shareShopTitle_i7yn2_201",rt="_shareShopDes_i7yn2_206",nt="_shareShopValue_i7yn2_212",lt="_shareShopOldPrice_i7yn2_216",ct="_wxpopup_i7yn2_220";var a={swipeItemImg:L,swipe:N,"custom-indicator":"_custom-indicator_i7yn2_7",goodsHead:A,priceGroup:W,price:G,delPrice:V,stock:R,goodsName:z,row:M,col:O,"radio-group":"_radio-group_i7yn2_61",radio:j,badge:F,section:J,detail:U,photoDetail:K,goodsDetail:Q,actionBar:X,addCertBtn:Y,buyGroup:Z,selectWrap:tt,shareBtn:ot,shareWrap:et,sharePic:st,shareLeft:it,shareShopTitle:at,shareShopDes:rt,shareShopValue:nt,shareShopOldPrice:lt,wxpopup:ct};function pt(t){return typeof t=="function"||Object.prototype.toString.call(t)==="[object Object]"&&!I(t)}var Wt=f({name:"goods-detail",data(){return{id:this.$route.query.id,albumPics:[],product:{},radio:0,skuStockList:[],detailMobileHtml:"",loading:!1,wxStatus:!1}},computed:{getPrice(){const t=this.skuStockList.filter(e=>e.id==this.radio);return t&&Array.isArray(t)&&t.length?t[0].price:this.product.price}},created(){if(c().isApp)if(d.platformType==="STUDENT"){const{query:t}=this.$route,s=Object.assign({id:t.bizId,promoterId:t.userId},t);s.promoterId=t.userType&&t.userType=="STUDENT"?"":s.promoterId,c().ios?window.location.replace(`${location.origin}/student/#/goodsDetail?${u.stringify(s)}`):(p({api:"openWebView",content:{url:`${location.origin}/student/#/goodsDetail?${u.stringify(s)}`,orientation:1,isHideTitle:!1}}),p({api:"back"}))}else d.platformType==="TEACHER"&&b.alert({title:"\u63D0\u793A",message:"\u8BF7\u4F7F\u7528\u9177\u4E50\u79C0\u5B66\u751F\u7AEF\u626B\u7801\u6253\u5F00"}).then(()=>{p({api:"back"})});else{const{origin:t}=location,s=this.$route.query,e=t+`/student/#/goodsDetail?id=${s.bizId}&promoterId=${s.userType&&s.userType=="STUDENT"?"":s.userId}&p=${s.p}`;y(e,{})}},mounted(){this.getProduct()},methods:{locationReplace(t){history.replaceState?(history.replaceState(null,document.title,t),window.location.reload()):location.replace(t)},async getProduct(){this.loading=!0;let t={},s=[];try{const e=await S.post("/api-mall-portal/open/productProfit",{data:{bizId:this.$route.query.bizId,userId:this.$route.query.userId}});e.data&&e.data.productDetail&&(t=e.data.productDetail.product,s=e.data.productDetail.skuStockList||[])}catch{}this.product=t,this.skuStockList=s.map(e=>{if(e.spData){const i=JSON.parse(e.spData);e.spDataJson=i.reduce((r,n)=>(r+=n.value,r),""),e.sku=i.reduce((r,n)=>(r.push(`${n.key}: ${n.value}`),r),[]).join(",")}else e.spDataJson="\u9ED8\u8BA4";return e}),this.albumPics=[t.pic].concat(t.albumPics.split(",")).filter(e=>e),this.detailMobileHtml=t.detailMobileHtml,this.loading=!1},onPreview(t){_({images:this.albumPics,startPosition:t,closeable:!0})},onShowImg(t){const{localName:s}=t.srcElement;if(s!=="img")return;let e=0;const i=document.querySelectorAll(".msgWrap img"),r=Array.from(i).map((n,g)=>(t.srcElement==n&&(e=g),n.src));_({images:r,startPosition:e,closeable:!0})},onDetail(){if(c().weixin){this.wxStatus=!0;return}const{origin:t}=location,s=this.$route.query,e=t+`/student/#/goodsDetail?id=${s.bizId}&promoterId=${s.userId}&p=${s.p}`;y(e,{}),setTimeout(()=>{location.href=t+"/student/#/download"},3e3)}},render(){let t;const s=this.product,e=this.skuStockList.find(i=>i.id===this.radio);return o("div",{class:a.goodsDetail},[o(C,{class:a.swipe,lazyRender:!0},{default:()=>[this.albumPics.map((i,r)=>o(P,null,{default:()=>[o(T,{class:a.swipeItemImg,src:i,onClick:()=>this.onPreview(r),fit:"cover"},null)]}))],indicator:i=>i.total>1&&o("div",{class:a["custom-indicator"]},[(i.active||0)+1,l(" / "),i.total])}),o(v,{border:!1,class:[a.goodsHead,"mb12"]},{default:()=>[o(m,{center:!0,border:!1},{title:()=>o("div",{class:a.priceGroup},[o("span",{class:a.price},[o("i",null,[l("\xA5")]),w(this.getPrice)])])}),o(m,{center:!0,border:!1,title:s.name,titleClass:[a.goodsName,"van-ellipsis"]},null)]}),o(q,{class:[a.row,"mb12"]},{default:()=>[o(h,{span:4,class:a.col},{default:()=>[l("\u89C4\u683C")]}),o(h,{span:20},{default:()=>[e?o("div",{class:a.selectWrap},[e.stock<=0?"\u5F53\u524D\u6B3E\u5F0F\u6682\u65F6\u7F3A\u8D27":`\u5DF2\u9009\u62E9 ${e.spDataJson}`]):o("div",{class:a.selectWrap},[l("\u8BF7\u9009\u62E9 \u89C4\u683C")]),o($,{class:a["radio-group"],modelValue:this.radio,"onUpdate:modelValue":i=>this.radio=i},pt(t=this.skuStockList.map(i=>{const r=i.id===this.radio,n=r?"primary":"default";return o(D,{position:"top-right",content:i.stock<=0?"\u7F3A\u8D27":"",color:"#999999",class:a.badge,offset:[-20,0]},{default:()=>[o(x,{class:a.radio,name:i.id,disabled:i.stock<=0,onClick:()=>{i.stock<=0||(this.radio=i.id)}},{default:()=>[o(B,{size:"large",plain:r,type:n},{default:()=>[i.spDataJson]})]})]})}))?t:{default:()=>[t]})]})]}),this.detailMobileHtml&&o("div",{class:[a.section]},[o("div",{class:a.detail},[o("span",null,[l("\u56FE\u6587\u8BE6\u60C5")])]),o("div",{class:[a.photoDetail,"msgWrap"],onClick:this.onShowImg,innerHTML:this.detailMobileHtml},null)]),o(E,{position:"bottom"},{default:()=>[o("div",{class:["btnGroup"],style:{paddingTop:"12px"}},[o(k,{block:!0,round:!0,type:"primary",onClick:this.onDetail},{default:()=>[l("\u4E0B\u8F7D\u9177\u4E50\u79C0\u8D2D\u4E70\u5546\u54C1")]})])]}),this.wxStatus&&o("div",{class:a.wxpopup,onClick:()=>{this.wxStatus=!1}},[o("img",{src:H("wx_bg.png"),alt:""},null)])])}});export{Wt as default};