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