index-c30a12c1.js 14 KB

1
  1. import{c as q,d as M,b6 as Z,n as Q,x as re,u as we,r as R,e as $,w as A,Z as ye,a as o,p as F,$ as I,aM as ke,L as Pe,_ as le,b7 as ee,b8 as Ce,t as N,ab as xe,b as Y,a4 as te,m as G,Y as Te,y as Ie,b9 as Le,ba as De,z as Be,h as ce,ae as Re,V as ue,H as Ae,I as j,a0 as We,aN as He,ac as Ne,bb as Ye,bc as Xe,k as de,bd as Ze,C as $e,D as ze,A as H,P as Ge,at as Me,F as Ee,be as Oe,a2 as Fe}from"./index-5e5e4ebc.js";import{A as Ve}from"./index-a802c753.js";import{a as me,S as he}from"./index-d46a4ad2.js";import{I as ge}from"./index-fa23aaeb.js";import{C as qe}from"./index-9827a1cb.js";import{C as oe}from"./index-4bcfa431.js";import{R as je,C as ae}from"./index-0e2c1963.js";import{R as Je,a as Ue}from"./index-cb21536d.js";import{T as Ke}from"./index-cc5b42dd.js";import"./student-register-store-64ec444b.js";import"./index-8338d355.js";import"./Checker-d0f399df.js";const se=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],ie=2.6;var et=M({props:{src:String,show:Boolean,active:Number,minZoom:Z(Q),maxZoom:Z(Q),rootWidth:Z(Number),rootHeight:Z(Number),disableZoom:Boolean},emits:["scale","close","longPress"],setup(e,{emit:n,slots:i}){const t=re({scale:1,moveX:0,moveY:0,moving:!1,zooming:!1,initializing:!1,imageRatio:0}),a=we(),m=R(),C=R(),w=R(!1),v=R(!1);let b=0;const p=$(()=>{const{scale:s,moveX:r,moveY:l,moving:h,zooming:S,initializing:D}=t,X={transitionDuration:S||h||D?"0s":".3s"};return(s!==1||v.value)&&(X.transform=`matrix(${s}, 0, 0, ${s}, ${r}, ${l})`),X}),d=$(()=>{if(t.imageRatio){const{rootWidth:s,rootHeight:r}=e,l=w.value?r/t.imageRatio:s;return Math.max(0,(t.scale*l-s)/2)}return 0}),g=$(()=>{if(t.imageRatio){const{rootWidth:s,rootHeight:r}=e,l=w.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 S=le((l=m.value)==null?void 0:l.$el),D={x:S.width*.5,y:S.height*.5},X=t.moveX-(r.x-S.left-D.x)*(h-1),Se=t.moveY-(r.y-S.top-D.y)*(h-1);t.moveX=I(X,-d.value,d.value),t.moveY=I(Se,-g.value,g.value)}else t.moveX=0,t.moveY=v.value?b:0;n("scale",{scale:s,index:e.active})}},y=()=>{x(1)},L=()=>{const s=t.scale>1?1:2;x(s,s===2||v.value?{x:a.startX.value,y:a.startY.value}:void 0)};let _,k,c,P,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),k=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&&(P=t.scale,T=se(r))},fe=s=>{const{touches:r}=s;if(a.move(s),t.moving){const{deltaX:l,deltaY:h}=a,S=l.value+k,D=h.value+c;if((S>d.value||S<-d.value)&&!O&&a.isHorizontal()){t.moving=!1;return}O=!0,F(s,!0),t.moveX=I(S,-d.value,d.value),t.moveY=I(D,-g.value,g.value)}if(t.zooming&&(F(s,!0),r.length===2)){const l=se(r),h=P*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<ee&&r.value<ee&&(l<h?W?(clearTimeout(W),W=null,L()):W=setTimeout(()=>{n("close"),W=null},h):l>Ce&&n("longPress"))},U=s=>{let r=!1;if((t.moving||t.zooming)&&(r=!0,t.moving&&k===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,k=0,c=0,P=1,t.scale<1&&y();const l=+e.maxZoom;t.scale>l&&x(l,E)}F(s,r),be(),a.reset()},K=()=>{const{rootWidth:s,rootHeight:r}=e,l=r/s,{imageRatio:h}=t;w.value=t.imageRatio>l&&h<ie,v.value=t.imageRatio>l&&h>=ie,v.value&&(b=(h*s-r)/2,t.moveY=b,t.initializing=!0,ke(()=>{t.initializing=!1})),y()},_e=s=>{const{naturalWidth:r,naturalHeight:l}=s.target;t.imageRatio=l/r,K()};return A(()=>e.active,y),A(()=>e.show,s=>{s||y()}),A(()=>[e.rootWidth,e.rootHeight],K),ye("touchmove",fe,{target:$(()=>{var s;return(s=C.value)==null?void 0:s.$el})}),()=>{const s={loading:()=>o(Pe,{type:"spinner"},null)};return o(me,{ref:C,class:V("swipe-item"),onTouchstartPassive:ve,onTouchend:U,onTouchcancel:U},{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:w.value}),style:p.value,onLoad:_e},s)]})}}});const[tt,B]=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:te,closeIcon:G("clear"),transition:String,beforeClose:Function,overlayClass:te,overlayStyle:Object,swipeDuration:Y(300),startPosition:Y(0),showIndicators:Boolean,closeOnPopstate:N,closeIconPosition:G("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=re({active:0,rootWidth:0,rootHeight:0,disableZoom:!1}),m=()=>{if(t.value){const c=le(t.value.$el);a.rootWidth=c.width,a.rootHeight=c.height,t.value.resize()}},C=c=>n("scale",c),w=c=>n("update:show",c),v=()=>{We(e.beforeClose,{args:[a.active],done:()=>w(!1)})},b=c=>{c!==a.active&&(a.active=c,n("change",c))},p=()=>{if(e.showIndex)return o("div",{class:B("index")},[i.index?i.index({index:a.active}):`${a.active+1} / ${e.images.length}`])},d=()=>{if(i.cover)return o("div",{class:B("cover")},[i.cover()])},g=()=>{a.disableZoom=!0},x=()=>{a.disableZoom=!1},y=()=>o(he,{ref:t,lazyRender:!0,loop:e.loop,class:B("swipe"),duration:e.swipeDuration,initialSwipe:e.startPosition,showIndicators:e.showIndicators,indicatorColor:"white",onChange:b,onDragEnd:x,onDragStart:g},{default:()=>[e.images.map((c,P)=>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:P})},{image:i.image}))]}),L=()=>{if(e.closeable)return o(j,{role:"button",name:e.closeIcon,class:[B("close-icon",e.closeIconPosition),Ae],onClick:v},null)},_=()=>n("closed"),k=(c,P)=>{var T;return(T=t.value)==null?void 0:T.swipeTo(c,P)};return Te({swipeTo:k}),Ie(m),A([Le,De],m),A(()=>e.startPosition,c=>b(+c)),A(()=>e.show,c=>{const{images:P,startPosition:T}=e;c?(b(+T),Be(()=>{m(),k(+T,{immediate:!0})})):n("close",{index:a.active,url:P[a.active]})}),()=>o(ue,ce({class:[B(),e.className],overlayClass:[B("overlay"),e.overlayClass],onClosed:_,"onUpdate:show":w},Re(e,ot)),{default:()=>[L(),y(),p(),d()]})}});let z;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:z}=Ye({setup(){const{state:e,toggle:n}=Xe(),i=()=>{e.images=[]};return()=>o(pe,ce(e,{onClosed:i,"onUpdate:show":n}),null)}}))}const ne=(e,n=0)=>{if(He)return z||it(),e=Array.isArray(e)?{images:e,startPosition:n}:e,z.open(Ne({},st,e)),z};de(pe);const[nt,f,rt]=q("submit-bar"),lt={tip:String,label:String,price:Number,tipIcon:String,loading:Boolean,currency:G("¥"),disabled:Boolean,textAlign:String,buttonText:String,buttonType:G("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:y,decimalLength:L}=e;if(typeof p=="number"){const _=(p/100).toFixed(+L).split("."),k=L?`.${_[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]]),k]),y&&o("span",{class:f("suffix-label")},[y])])}},C=()=>{var p;const{tip:d,tipIcon:g}=e;if(i.tip||d)return o("div",{class:f("tip")},[g&&o(j,{class:f("tip-icon"),name:g},null),d&&o("span",{class:f("tip-text")},[d]),(p=i.tip)==null?void 0:p.call(i)])},w=()=>n("submit"),v=()=>i.button?i.button():o($e,{round:!0,type:e.buttonType,text:e.buttonText,class:f("button",e.buttonType),color:e.buttonColor,loading:e.loading,disabled:e.disabled,onClick:w},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="_arrowLeft_ub7u2_1",mt="_swipeItemImg_ub7u2_12",ht="_swipe_ub7u2_12",gt="_goodsHead_ub7u2_28",pt="_priceGroup_ub7u2_35",vt="_price_ub7u2_35",ft="_delPrice_ub7u2_48",bt="_stock_ub7u2_54",_t="_goodsName_ub7u2_58",St="_row_ub7u2_64",wt="_col_ub7u2_68",yt="_radio_ub7u2_72",kt="_badge_ub7u2_113",Pt="_section_ub7u2_117",Ct="_detail_ub7u2_121",xt="_photoDetail_ub7u2_146",Tt="_goodsDetail_ub7u2_150",It="_actionBar_ub7u2_153",Lt="_text_ub7u2_175",Dt="_addCertBtn_ub7u2_180",Bt="_buyGroup_ub7u2_190",Rt="_selectWrap_ub7u2_196",At="_shareBtn_ub7u2_202",Wt="_shareWrap_ub7u2_208",Ht="_sharePic_ub7u2_218",Nt="_shareLeft_ub7u2_223",Yt="_shareRight_ub7u2_226",Xt="_shareShopTitle_ub7u2_230",Zt="_shareShopDes_ub7u2_240",$t="_shareShopValue_ub7u2_249",zt="_shareShopOldPrice_ub7u2_253",Gt="_imagesOverlayWrap_ub7u2_260",u={arrowLeft:dt,swipeItemImg:mt,swipe:ht,"custom-indicator":"_custom-indicator_ub7u2_18",goodsHead:gt,priceGroup:pt,price:vt,delPrice:ft,stock:bt,goodsName:_t,row:St,col:wt,"radio-group":"_radio-group_ub7u2_72",radio:yt,badge:kt,section:Pt,detail:Ct,photoDetail:xt,goodsDetail:Tt,actionBar:It,text:Lt,addCertBtn:Dt,buyGroup:Bt,selectWrap:Rt,shareBtn:At,shareWrap:Wt,sharePic:Ht,shareLeft:Nt,shareRight:Yt,shareShopTitle:Xt,shareShopDes:Zt,shareShopValue:$t,shareShopOldPrice:zt,imagesOverlayWrap:Gt};function Mt(e){return typeof e=="function"||Object.prototype.toString.call(e)==="[object Object]"&&!Fe(e)}const oo=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 ze.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){ne({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));ne({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(j,{class:u.arrowLeft,name:"arrow-left",onClick:t=>{t.stopPropagation(),this.$router.back()}},null),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(oe,{center:!0,border:!1},{title:()=>o("div",{class:u.priceGroup},[o("span",{class:u.price},[o("i",null,[H("¥")]),Ge(this.getPrice)])])}),o(oe,{center:!0,border:!1,title:n.name,titleClass:[u.goodsName,"van-ellipsis"]},null)]}),o(je,{class:[u.row,"mb12"]},{default:()=>[o(ae,{span:4,class:u.col},{default:()=>[H("规格")]}),o(ae,{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},Mt(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(ue,{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{oo as default};