index-93fbb083.js 13 KB

1
  1. import{c as Y,d as M,b4 as Z,n as V,x as Q,u as he,r as E,e as B,w as N,Y as pe,a as o,p as X,_ as D,L as ge,b5 as fe,t as A,aa as be,b as H,a3 as q,m as $,X as ve,y as _e,b6 as Se,b7 as we,z as ye,h as ee,ad as ke,V as te,Z as Pe,H as Ce,I as z,$ as Te,aM as xe,ab as Ie,b8 as Le,b9 as Be,k as oe,ba as De,C as We,D as Ae,A as W,P as He,as as Ne,F as Re,bb as Ze,a1 as Ge}from"./index-2eaca48c.js";import{A as $e}from"./index-f9641aec.js";import{a as se,S as ae}from"./index-87cddea8.js";import{I as ie}from"./index-cff31c09.js";import{C as Me}from"./index-a86bff5d.js";import{C as j}from"./index-3b216eb3.js";import{R as Xe,C as J}from"./index-7d99c8b0.js";import{R as Oe,a as Ye}from"./index-c74550cb.js";import{T as Ee}from"./index-2ceb0c19.js";import"./student-register-store-41a6699d.js";import"./index-2b84495d.js";import"./Checker-1b9c08f9.js";const U=e=>Math.sqrt((e[0].clientX-e[1].clientX)**2+(e[0].clientY-e[1].clientY)**2),O=Y("image-preview")[1];var ze=M({props:{src:String,show:Boolean,active:Number,minZoom:Z(V),maxZoom:Z(V),rootWidth:Z(Number),rootHeight:Z(Number),disableZoom:Boolean},emits:["scale","close","longPress"],setup(e,{emit:n,slots:i}){const t=Q({scale:1,moveX:0,moveY:0,moving:!1,zooming:!1,imageRatio:0,displayWidth:0,displayHeight:0}),a=he(),d=E(),b=B(()=>{const{rootWidth:s,rootHeight:c}=e,u=c/s;return t.imageRatio>u}),I=B(()=>{const{scale:s,moveX:c,moveY:u,moving:C,zooming:T}=t,R={transitionDuration:T||C?"0s":".3s"};if(s!==1){const de=c/s,me=u/s;R.transform=`scale(${s}, ${s}) translate(${de}px, ${me}px)`}return R}),p=B(()=>{if(t.imageRatio){const{rootWidth:s,rootHeight:c}=e,u=b.value?c/t.imageRatio:s;return Math.max(0,(t.scale*u-s)/2)}return 0}),g=B(()=>{if(t.imageRatio){const{rootWidth:s,rootHeight:c}=e,u=b.value?c:s*t.imageRatio;return Math.max(0,(t.scale*u-c)/2)}return 0}),m=s=>{s=D(s,+e.minZoom,+e.maxZoom+1),s!==t.scale&&(t.scale=s,n("scale",{scale:s,index:e.active}))},h=()=>{m(1),t.moveX=0,t.moveY=0},y=()=>{const s=t.scale>1?1:2;m(s),t.moveX=0,t.moveY=0};let v,_,S,k,x,r,P,w=!1;const re=s=>{const{touches:c}=s;if(v=c.length,v===2&&e.disableZoom)return;const{offsetX:u}=a;a.start(s),_=t.moveX,S=t.moveY,P=Date.now(),w=!1,t.moving=v===1&&t.scale!==1,t.zooming=v===2&&!u.value,t.zooming&&(k=t.scale,x=U(s.touches))},le=s=>{const{touches:c}=s;if(a.move(s),t.moving){const{deltaX:u,deltaY:C}=a,T=u.value+_,R=C.value+S;if((T>p.value||T<-p.value)&&!w&&a.isHorizontal()){t.moving=!1;return}w=!0,X(s,!0),t.moveX=D(T,-p.value,p.value),t.moveY=D(R,-g.value,g.value)}if(t.zooming&&(X(s,!0),c.length===2)){const u=U(c),C=k*u/x;m(C)}},ce=()=>{if(v>1)return;const{offsetX:s,offsetY:c}=a,u=Date.now()-P,C=250,T=5;s.value<T&&c.value<T&&(u<C?r?(clearTimeout(r),r=null,y()):r=setTimeout(()=>{n("close"),r=null},C):u>fe&&n("longPress"))},F=s=>{let c=!1;if((t.moving||t.zooming)&&(c=!0,t.moving&&_===t.moveX&&S===t.moveY&&(c=!1),!s.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,S=0,k=1,t.scale<1&&h();const u=+e.maxZoom;t.scale>u&&(t.scale=u)}X(s,c),ce(),a.reset()},ue=s=>{const{naturalWidth:c,naturalHeight:u}=s.target;t.imageRatio=u/c};return N(()=>e.active,h),N(()=>e.show,s=>{s||h()}),pe("touchmove",le,{target:B(()=>{var s;return(s=d.value)==null?void 0:s.$el})}),()=>{const s={loading:()=>o(ge,{type:"spinner"},null)};return o(se,{ref:d,class:O("swipe-item"),onTouchstartPassive:re,onTouchend:F,onTouchcancel:F},{default:()=>[i.image?o("div",{class:O("image-wrap")},[i.image({src:e.src})]):o(ie,{src:e.src,fit:"contain",class:O("image",{vertical:b.value}),style:I.value,onLoad:ue},s)]})}}});const[Fe,L]=Y("image-preview"),Ve=["show","teleport","transition","overlayStyle","closeOnPopstate"],qe={show:Boolean,loop:A,images:be(),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=M({name:Fe,props:qe,emits:["scale","close","closed","change","longPress","update:show"],setup(e,{emit:n,slots:i}){const t=E(),a=Q({active:0,rootWidth:0,rootHeight:0,disableZoom:!1}),d=()=>{if(t.value){const r=Pe(t.value.$el);a.rootWidth=r.width,a.rootHeight=r.height,t.value.resize()}},b=r=>n("scale",r),I=r=>n("update:show",r),p=()=>{Te(e.beforeClose,{args:[a.active],done:()=>I(!1)})},g=r=>{r!==a.active&&(a.active=r,n("change",r))},m=()=>{if(e.showIndex)return o("div",{class:L("index")},[i.index?i.index({index:a.active}):`${a.active+1} / ${e.images.length}`])},h=()=>{if(i.cover)return o("div",{class:L("cover")},[i.cover()])},y=()=>{a.disableZoom=!0},v=()=>{a.disableZoom=!1},_=()=>o(ae,{ref:t,lazyRender:!0,loop:e.loop,class:L("swipe"),duration:e.swipeDuration,initialSwipe:e.startPosition,showIndicators:e.showIndicators,indicatorColor:"white",onChange:g,onDragEnd:v,onDragStart:y},{default:()=>[e.images.map((r,P)=>o(ze,{src:r,show:e.show,active:a.active,maxZoom:e.maxZoom,minZoom:e.minZoom,rootWidth:a.rootWidth,rootHeight:a.rootHeight,disableZoom:a.disableZoom,onScale:b,onClose:p,onLongPress:()=>n("longPress",{index:P})},{image:i.image}))]}),S=()=>{if(e.closeable)return o(z,{role:"button",name:e.closeIcon,class:[L("close-icon",e.closeIconPosition),Ce],onClick:p},null)},k=()=>n("closed"),x=(r,P)=>{var w;return(w=t.value)==null?void 0:w.swipeTo(r,P)};return ve({swipeTo:x}),_e(d),N([Se,we],d),N(()=>e.startPosition,r=>g(+r)),N(()=>e.show,r=>{const{images:P,startPosition:w}=e;r?(g(+w),ye(()=>{d(),x(+w,{immediate:!0})})):n("close",{index:a.active,url:P[a.active]})}),()=>o(te,ee({class:[L(),e.className],overlayClass:[L("overlay"),e.overlayClass],onClosed:k,"onUpdate:show":I},ke(e,Ve)),{default:()=>[S(),_(),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}=Le({setup(){const{state:e,toggle:n}=Be(),i=()=>{e.images=[]};return()=>o(ne,ee(e,{onClosed:i,"onUpdate:show":n}),null)}}))}const K=(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]=Y("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=M({name:Ue,props:Qe,emits:["submit"],setup(e,{emit:n,slots:i}){const t=E(),a=De(t,f),d=()=>{const{price:m,label:h,currency:y,textAlign:v,suffixLabel:_,decimalLength:S}=e;if(typeof m=="number"){const k=(m/100).toFixed(+S).split("."),x=S?`.${k[1]}`:"";return o("div",{class:f("text"),style:{textAlign:v}},[o("span",null,[h||Ke("label")]),o("span",{class:f("price")},[y,o("span",{class:f("price-integer")},[k[0]]),x]),_&&o("span",{class:f("suffix-label")},[_])])}},b=()=>{var m;const{tip:h,tipIcon:y}=e;if(i.tip||h)return o("div",{class:f("tip")},[y&&o(z,{class:f("tip-icon"),name:y},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),b(),o("div",{class:f("bar")},[(h=i.default)==null?void 0:h.call(i),d(),p()])])};return()=>e.placeholder?a(g):g()}});const tt=oe(et),ot="_arrowLeft_ub7u2_1",st="_swipeItemImg_ub7u2_12",at="_swipe_ub7u2_12",it="_goodsHead_ub7u2_28",nt="_priceGroup_ub7u2_35",rt="_price_ub7u2_35",lt="_delPrice_ub7u2_48",ct="_stock_ub7u2_54",ut="_goodsName_ub7u2_58",dt="_row_ub7u2_64",mt="_col_ub7u2_68",ht="_radio_ub7u2_72",pt="_badge_ub7u2_113",gt="_section_ub7u2_117",ft="_detail_ub7u2_121",bt="_photoDetail_ub7u2_146",vt="_goodsDetail_ub7u2_150",_t="_actionBar_ub7u2_153",St="_text_ub7u2_175",wt="_addCertBtn_ub7u2_180",yt="_buyGroup_ub7u2_190",kt="_selectWrap_ub7u2_196",Pt="_shareBtn_ub7u2_202",Ct="_shareWrap_ub7u2_208",Tt="_sharePic_ub7u2_218",xt="_shareLeft_ub7u2_223",It="_shareRight_ub7u2_226",Lt="_shareShopTitle_ub7u2_230",Bt="_shareShopDes_ub7u2_240",Dt="_shareShopValue_ub7u2_249",Wt="_shareShopOldPrice_ub7u2_253",At="_imagesOverlayWrap_ub7u2_260",l={arrowLeft:ot,swipeItemImg:st,swipe:at,"custom-indicator":"_custom-indicator_ub7u2_18",goodsHead:it,priceGroup:nt,price:rt,delPrice:lt,stock:ct,goodsName:ut,row:dt,col:mt,"radio-group":"_radio-group_ub7u2_72",radio:ht,badge:pt,section:gt,detail:ft,photoDetail:bt,goodsDetail:vt,actionBar:_t,text:St,addCertBtn:wt,buyGroup:yt,selectWrap:kt,shareBtn:Pt,shareWrap:Ct,sharePic:Tt,shareLeft:xt,shareRight:It,shareShopTitle:Lt,shareShopDes:Bt,shareShopValue:Dt,shareShopOldPrice:Wt,imagesOverlayWrap:At};function Ht(e){return typeof e=="function"||Object.prototype.toString.call(e)==="[object Object]"&&!Ge(e)}const Vt=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,d)=>(a+=d.value,a),""),i.sku=t.reduce((a,d)=>(a.push(`${d.key}: ${d.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 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 a=this.skuStockListTemp[t];if(a.stock>=0){this.radio=a.id;break}}}this.detailMobileHtml=n.product.detailMobileHtml}catch(e){}},methods:{onPreview(e){K({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 a=Array.from(t).map((d,b)=>(e.srcElement==d&&(i=b),d.src));K({images:a,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(z,{class:l.arrowLeft,name:"arrow-left",onClick:t=>{t.stopPropagation(),this.$router.back()}},null),o(ae,{class:l.swipe,lazyRender:!0},{default:()=>[this.albumPics.map((t,a)=>o(se,null,{default:()=>[o(ie,{class:l.swipeItemImg,src:t,onClick:()=>this.onPreview(a),fit:"cover"},null)]}))],indicator:t=>t.total>1&&o("div",{class:l["custom-indicator"]},[(t.active||0)+1,W(" / "),t.total])}),o(Me,{border:!1,class:[l.goodsHead,"mb12"]},{default:()=>[o(j,{center:!0,border:!1},{title:()=>o("div",{class:l.priceGroup},[o("span",{class:l.price},[o("i",null,[W("¥")]),He(this.getPrice)])])}),o(j,{center:!0,border:!1,title:n.name,titleClass:[l.goodsName,"van-ellipsis"]},null)]}),o(Xe,{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(Oe,{class:l["radio-group"],modelValue:this.radio,"onUpdate:modelValue":t=>this.radio=t},Ht(e=this.skuStockList.map(t=>{const a=t.id===this.radio,d=a?"primary":"default";return o(Ne,{position:"top-right",content:t.stock<=0?"缺货":"",color:"#999999",class:l.badge,offset:[-20,0]},{default:()=>[o(Ye,{class:l.radio,name:t.id,disabled:t.stock<=0,onClick:()=>{t.stock<=0||(this.radio=t.id)}},{default:()=>[o(Ee,{size:"large",plain:a,type:d},{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(te,{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{Vt as default};