1 |
- import{c as q,d as M,b4 as Z,n as K,x as ne,u as Se,r as R,e as z,w as A,Y as we,a as o,p as F,_ as I,ad as Pe,L as ke,Z as re,bb as Q,bc as Ce,t as N,ai as xe,b as Y,a3 as ee,m as $,X as Te,y as Ie,b2 as De,b3 as Be,z as Le,h as le,ae as Re,V as ce,H as Ae,I as ue,$ as We,ay as He,a9 as Ne,bd as Ye,be as Xe,k as de,bf as Ze,C as ze,D as Ge,A as H,P as $e,av as Me,F as Ee,bg as Oe,a1 as Fe}from"./index-fac4d009.js";import{A as Ve}from"./index-61252f21.js";import{a as me,S as he}from"./index-1701cc18.js";import{I as ge}from"./index-fdcc93f3.js";import{C as qe}from"./index-1770a616.js";import{C as te}from"./index-5cba6af7.js";import{R as je,C as oe}from"./student-register-store-5f367f9a.js";import{R as Je,a as Ue}from"./index-5a3fcd76.js";import{T as Ke}from"./index-a0c979fe.js";import"./Checker-bb9feab8.js";const ae=e=>Math.sqrt((e[0].clientX-e[1].clientX)**2+(e[0].clientY-e[1].clientY)**2),Qe=e=>({x:(e[0].clientX+e[1].clientX)/2,y:(e[0].clientY+e[1].clientY)/2}),V=q("image-preview")[1],se=2.6;var et=M({props:{src:String,show:Boolean,active:Number,minZoom:Z(K),maxZoom:Z(K),rootWidth:Z(Number),rootHeight:Z(Number),disableZoom:Boolean},emits:["scale","close","longPress"],setup(e,{emit:n,slots:i}){const t=ne({scale:1,moveX:0,moveY:0,moving:!1,zooming:!1,initializing:!1,imageRatio:0}),a=Se(),m=R(),C=R(),S=R(!1),v=R(!1);let b=0;const p=z(()=>{const{scale:s,moveX:r,moveY:l,moving:h,zooming:y,initializing:B}=t,X={transitionDuration:y||h||B?"0s":".3s"};return(s!==1||v.value)&&(X.transform=`matrix(${s}, 0, 0, ${s}, ${r}, ${l})`),X}),d=z(()=>{if(t.imageRatio){const{rootWidth:s,rootHeight:r}=e,l=S.value?r/t.imageRatio:s;return Math.max(0,(t.scale*l-s)/2)}return 0}),g=z(()=>{if(t.imageRatio){const{rootWidth:s,rootHeight:r}=e,l=S.value?r:s*t.imageRatio;return Math.max(0,(t.scale*l-r)/2)}return 0}),x=(s,r)=>{var l;if(s=I(s,+e.minZoom,+e.maxZoom+1),s!==t.scale){const h=s/t.scale;if(t.scale=s,r){const y=re((l=m.value)==null?void 0:l.$el),B={x:y.width*.5,y:y.height*.5},X=t.moveX-(r.x-y.left-B.x)*(h-1),ye=t.moveY-(r.y-y.top-B.y)*(h-1);t.moveX=I(X,-d.value,d.value),t.moveY=I(ye,-g.value,g.value)}else t.moveX=0,t.moveY=v.value?b:0;n("scale",{scale:s,index:e.active})}},w=()=>{x(1)},D=()=>{const s=t.scale>1?1:2;x(s,s===2||v.value?{x:a.startX.value,y:a.startY.value}:void 0)};let _,P,c,k,T,E,W,j,O=!1;const ve=s=>{const{touches:r}=s;if(_=r.length,_===2&&e.disableZoom)return;const{offsetX:l}=a;a.start(s),P=t.moveX,c=t.moveY,j=Date.now(),O=!1,t.moving=_===1&&(t.scale!==1||v.value),t.zooming=_===2&&!l.value,t.zooming&&(k=t.scale,T=ae(r))},fe=s=>{const{touches:r}=s;if(a.move(s),t.moving){const{deltaX:l,deltaY:h}=a,y=l.value+P,B=h.value+c;if((y>d.value||y<-d.value)&&!O&&a.isHorizontal()){t.moving=!1;return}O=!0,F(s,!0),t.moveX=I(y,-d.value,d.value),t.moveY=I(B,-g.value,g.value)}if(t.zooming&&(F(s,!0),r.length===2)){const l=ae(r),h=k*l/T;E=Qe(r),x(h,E)}},be=()=>{if(_>1)return;const{offsetX:s,offsetY:r}=a,l=Date.now()-j,h=250;s.value<Q&&r.value<Q&&(l<h?W?(clearTimeout(W),W=null,D()):W=setTimeout(()=>{n("close"),W=null},h):l>Ce&&n("longPress"))},J=s=>{let r=!1;if((t.moving||t.zooming)&&(r=!0,t.moving&&P===t.moveX&&c===t.moveY&&(r=!1),!s.touches.length)){t.zooming&&(t.moveX=I(t.moveX,-d.value,d.value),t.moveY=I(t.moveY,-g.value,g.value),t.zooming=!1),t.moving=!1,P=0,c=0,k=1,t.scale<1&&w();const l=+e.maxZoom;t.scale>l&&x(l,E)}F(s,r),be(),a.reset()},U=()=>{const{rootWidth:s,rootHeight:r}=e,l=r/s,{imageRatio:h}=t;S.value=t.imageRatio>l&&h<se,v.value=t.imageRatio>l&&h>=se,v.value&&(b=(h*s-r)/2,t.moveY=b,t.initializing=!0,Pe(()=>{t.initializing=!1})),w()},_e=s=>{const{naturalWidth:r,naturalHeight:l}=s.target;t.imageRatio=l/r,U()};return A(()=>e.active,w),A(()=>e.show,s=>{s||w()}),A(()=>[e.rootWidth,e.rootHeight],U),we("touchmove",fe,{target:z(()=>{var s;return(s=C.value)==null?void 0:s.$el})}),()=>{const s={loading:()=>o(ke,{type:"spinner"},null)};return o(me,{ref:C,class:V("swipe-item"),onTouchstartPassive:ve,onTouchend:J,onTouchcancel:J},{default:()=>[i.image?o("div",{class:V("image-wrap")},[i.image({src:e.src})]):o(ge,{ref:m,src:e.src,fit:"contain",class:V("image",{vertical:S.value}),style:p.value,onLoad:_e},s)]})}}});const[tt,L]=q("image-preview"),ot=["show","teleport","transition","overlayStyle","closeOnPopstate"],at={show:Boolean,loop:N,images:xe(),minZoom:Y(1/3),maxZoom:Y(3),overlay:N,closeable:Boolean,showIndex:N,className:ee,closeIcon:$("clear"),transition:String,beforeClose:Function,overlayClass:ee,overlayStyle:Object,swipeDuration:Y(300),startPosition:Y(0),showIndicators:Boolean,closeOnPopstate:N,closeIconPosition:$("top-right"),teleport:[String,Object]};var pe=M({name:tt,props:at,emits:["scale","close","closed","change","longPress","update:show"],setup(e,{emit:n,slots:i}){const t=R(),a=ne({active:0,rootWidth:0,rootHeight:0,disableZoom:!1}),m=()=>{if(t.value){const c=re(t.value.$el);a.rootWidth=c.width,a.rootHeight=c.height,t.value.resize()}},C=c=>n("scale",c),S=c=>n("update:show",c),v=()=>{We(e.beforeClose,{args:[a.active],done:()=>S(!1)})},b=c=>{c!==a.active&&(a.active=c,n("change",c))},p=()=>{if(e.showIndex)return o("div",{class:L("index")},[i.index?i.index({index:a.active}):`${a.active+1} / ${e.images.length}`])},d=()=>{if(i.cover)return o("div",{class:L("cover")},[i.cover()])},g=()=>{a.disableZoom=!0},x=()=>{a.disableZoom=!1},w=()=>o(he,{ref:t,lazyRender:!0,loop:e.loop,class:L("swipe"),duration:e.swipeDuration,initialSwipe:e.startPosition,showIndicators:e.showIndicators,indicatorColor:"white",onChange:b,onDragEnd:x,onDragStart:g},{default:()=>[e.images.map((c,k)=>o(et,{src:c,show:e.show,active:a.active,maxZoom:e.maxZoom,minZoom:e.minZoom,rootWidth:a.rootWidth,rootHeight:a.rootHeight,disableZoom:a.disableZoom,onScale:C,onClose:v,onLongPress:()=>n("longPress",{index:k})},{image:i.image}))]}),D=()=>{if(e.closeable)return o(ue,{role:"button",name:e.closeIcon,class:[L("close-icon",e.closeIconPosition),Ae],onClick:v},null)},_=()=>n("closed"),P=(c,k)=>{var T;return(T=t.value)==null?void 0:T.swipeTo(c,k)};return Te({swipeTo:P}),Ie(m),A([De,Be],m),A(()=>e.startPosition,c=>b(+c)),A(()=>e.show,c=>{const{images:k,startPosition:T}=e;c?(b(+T),Le(()=>{m(),P(+T,{immediate:!0})})):n("close",{index:a.active,url:k[a.active]})}),()=>o(ce,le({class:[L(),e.className],overlayClass:[L("overlay"),e.overlayClass],onClosed:_,"onUpdate:show":S},Re(e,ot)),{default:()=>[D(),w(),p(),d()]})}});let G;const st={loop:!0,images:[],maxZoom:3,minZoom:1/3,onScale:void 0,onClose:void 0,onChange:void 0,teleport:"body",className:"",showIndex:!0,closeable:!1,closeIcon:"clear",transition:void 0,beforeClose:void 0,overlayStyle:void 0,overlayClass:void 0,startPosition:0,swipeDuration:300,showIndicators:!1,closeOnPopstate:!0,closeIconPosition:"top-right"};function it(){({instance:G}=Ye({setup(){const{state:e,toggle:n}=Xe(),i=()=>{e.images=[]};return()=>o(pe,le(e,{onClosed:i,"onUpdate:show":n}),null)}}))}const ie=(e,n=0)=>{if(He)return G||it(),e=Array.isArray(e)?{images:e,startPosition:n}:e,G.open(Ne({},st,e)),G};de(pe);const[nt,f,rt]=q("submit-bar"),lt={tip:String,label:String,price:Number,tipIcon:String,loading:Boolean,currency:$("¥"),disabled:Boolean,textAlign:String,buttonText:String,buttonType:$("danger"),buttonColor:String,suffixLabel:String,placeholder:Boolean,decimalLength:Y(2),safeAreaInsetBottom:N};var ct=M({name:nt,props:lt,emits:["submit"],setup(e,{emit:n,slots:i}){const t=R(),a=Ze(t,f),m=()=>{const{price:p,label:d,currency:g,textAlign:x,suffixLabel:w,decimalLength:D}=e;if(typeof p=="number"){const _=(p/100).toFixed(+D).split("."),P=D?`.${_[1]}`:"";return o("div",{class:f("text"),style:{textAlign:x}},[o("span",null,[d||rt("label")]),o("span",{class:f("price")},[g,o("span",{class:f("price-integer")},[_[0]]),P]),w&&o("span",{class:f("suffix-label")},[w])])}},C=()=>{var p;const{tip:d,tipIcon:g}=e;if(i.tip||d)return o("div",{class:f("tip")},[g&&o(ue,{class:f("tip-icon"),name:g},null),d&&o("span",{class:f("tip-text")},[d]),(p=i.tip)==null?void 0:p.call(i)])},S=()=>n("submit"),v=()=>i.button?i.button():o(ze,{round:!0,type:e.buttonType,text:e.buttonText,class:f("button",e.buttonType),color:e.buttonColor,loading:e.loading,disabled:e.disabled,onClick:S},null),b=()=>{var p,d;return o("div",{ref:t,class:[f(),{"van-safe-area-bottom":e.safeAreaInsetBottom}]},[(p=i.top)==null?void 0:p.call(i),C(),o("div",{class:f("bar")},[(d=i.default)==null?void 0:d.call(i),m(),v()])])};return()=>e.placeholder?a(b):b()}});const ut=de(ct),dt="_swipeItemImg_1ayhb_1",mt="_swipe_1ayhb_1",ht="_goodsHead_1ayhb_17",gt="_priceGroup_1ayhb_24",pt="_price_1ayhb_24",vt="_delPrice_1ayhb_37",ft="_stock_1ayhb_43",bt="_goodsName_1ayhb_47",_t="_row_1ayhb_53",yt="_col_1ayhb_57",St="_radio_1ayhb_61",wt="_badge_1ayhb_102",Pt="_section_1ayhb_106",kt="_detail_1ayhb_110",Ct="_photoDetail_1ayhb_135",xt="_goodsDetail_1ayhb_139",Tt="_actionBar_1ayhb_142",It="_text_1ayhb_164",Dt="_addCertBtn_1ayhb_169",Bt="_buyGroup_1ayhb_179",Lt="_selectWrap_1ayhb_185",Rt="_shareBtn_1ayhb_191",At="_shareWrap_1ayhb_197",Wt="_sharePic_1ayhb_207",Ht="_shareLeft_1ayhb_212",Nt="_shareRight_1ayhb_215",Yt="_shareShopTitle_1ayhb_219",Xt="_shareShopDes_1ayhb_229",Zt="_shareShopValue_1ayhb_238",zt="_shareShopOldPrice_1ayhb_242",Gt="_imagesOverlayWrap_1ayhb_249",u={swipeItemImg:dt,swipe:mt,"custom-indicator":"_custom-indicator_1ayhb_7",goodsHead:ht,priceGroup:gt,price:pt,delPrice:vt,stock:ft,goodsName:bt,row:_t,col:yt,"radio-group":"_radio-group_1ayhb_61",radio:St,badge:wt,section:Pt,detail:kt,photoDetail:Ct,goodsDetail:xt,actionBar:Tt,text:It,addCertBtn:Dt,buyGroup:Bt,selectWrap:Lt,shareBtn:Rt,shareWrap:At,sharePic:Wt,shareLeft:Ht,shareRight:Nt,shareShopTitle:Yt,shareShopDes:Xt,shareShopValue:Zt,shareShopOldPrice:zt,imagesOverlayWrap:Gt};function $t(e){return typeof e=="function"||Object.prototype.toString.call(e)==="[object Object]"&&!Fe(e)}const Qt=M({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,n=this.skuStockListTemp.length>0?this.skuStockListTemp:[{id:-1,price:e.price,pic:e.pic,stock:e.stock,spData:null}];return n.forEach(i=>{if(i.spData){const t=JSON.parse(i.spData);i.spDataJson=t.reduce((a,m)=>(a+=m.value,a),""),i.sku=t.reduce((a,m)=>(a.push(`${m.key}: ${m.value}`),a),[]).join(",")}else i.spDataJson="默认"}),n},getPrice(){let e=this.skuStockList.filter(n=>n.id==this.radio);return e&&Array.isArray(e)&&e.length?e[0].price:0}},async mounted(){try{this.loading=!0;const e=await Ge.get(`/edu-app/open/mall/product/detail/${this.id}`,{noAuthorization:!0});this.loading=!1;const n=e.data||{};if(this.albumPics=[n.product.pic].concat(n.product.albumPics.split(",")).filter(i=>i),this.product=n.product,this.skuStockListTemp=n.skuStockList||[],this.skuStockListTemp.length){let i=this.skuStockListTemp.length;for(let t=0;t<i;t++){let a=this.skuStockListTemp[t];if(a.stock>=0){this.radio=a.id;break}}}this.detailMobileHtml=n.product.detailMobileHtml}catch(e){}},methods:{onPreview(e){ie({images:this.albumPics,startPosition:e,closeable:!0,className:u.imagesOverlayWrap})},onShowImg(e){const{localName:n}=e.srcElement;if(n!=="img")return;let i=0;const t=document.querySelectorAll(".msgWrap img");let a=Array.from(t).map((m,C)=>(e.srcElement==m&&(i=C),m.src));ie({images:a,startPosition:i,closeable:!0,className:u.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 n=this.product,i=this.skuStockList.find(t=>t.id===this.radio);return o("div",{class:u.goodsDetail},[o(he,{class:u.swipe,lazyRender:!0},{default:()=>[this.albumPics.map((t,a)=>o(me,null,{default:()=>[o(ge,{class:u.swipeItemImg,src:t,onClick:()=>this.onPreview(a),fit:"cover"},null)]}))],indicator:t=>t.total>1&&o("div",{class:u["custom-indicator"]},[(t.active||0)+1,H(" / "),t.total])}),o(qe,{border:!1,class:[u.goodsHead,"mb12"]},{default:()=>[o(te,{center:!0,border:!1},{title:()=>o("div",{class:u.priceGroup},[o("span",{class:u.price},[o("i",null,[H("¥")]),$e(this.getPrice)])])}),o(te,{center:!0,border:!1,title:n.name,titleClass:[u.goodsName,"van-ellipsis"]},null)]}),o(je,{class:[u.row,"mb12"]},{default:()=>[o(oe,{span:4,class:u.col},{default:()=>[H("规格")]}),o(oe,{span:20},{default:()=>[i?o("div",{class:u.selectWrap},[i.stock<=0?"当前款式暂时缺货":`已选择 ${i.spDataJson}`]):o("div",null,[H("请选择 规格")]),o(Je,{class:u["radio-group"],modelValue:this.radio,"onUpdate:modelValue":t=>this.radio=t},$t(e=this.skuStockList.map(t=>{const a=t.id===this.radio,m=a?"primary":"default";return o(Me,{position:"top-right",content:t.stock<=0?"缺货":"",color:"#999999",class:u.badge,offset:[-20,0]},{default:()=>[o(Ue,{class:u.radio,name:t.id,disabled:t.stock<=0,onClick:()=>{t.stock<=0||(this.radio=t.id)}},{default:()=>[o(Ke,{size:"large",plain:a,type:m},{default:()=>[t.spDataJson]})]})]})}))?e:{default:()=>[e]})]})]}),this.detailMobileHtml&&o("div",{class:[u.section]},[o("div",{class:u.detail},[o("span",null,[H("图文详情")])]),o("div",{class:[u.photoDetail,"msgWrap"],onClick:this.onShowImg,innerHTML:this.detailMobileHtml},null)]),!this.loading&&o(Ee,null,[o(ut,{class:u.actionBar,"safe-area-inset-bottom":!0},{button:()=>o("div",{class:u.buyGroup},[o(Oe,{type:"primary",class:u.addCertBtn,text:"添加购买",onClick:()=>this.onShowCart()},null)])})]),o(ce,{show:this.addGoodsShow,closeable:!0,position:"bottom",round:!0,onClose:()=>{this.addGoodsShow=!1}},{default:()=>[o(Ve,{show:this.addGoodsShow,item:this.selectGoodsItem,onClose:()=>{this.addGoodsShow=!1},defaultRadio:this.radio,showType:"cart"},null)]})])}});export{Qt as default};
|