Files

2 lines
9.2 KiB
JavaScript
Raw Permalink Normal View History

import{a8 as I,a9 as D,aa as t,aJ as Q,aI as R,af as T,aK as O,I as C,ag as B,au as P,aL as G,aA as Y,aM as p,aN as ee,aj as ne,aO as F,aq as L,aP as M,aQ as Z,aR as te,ac as q,aS as N,aT as z,ab as ae,an as ie,aU as re,aV as ce,aW as oe,aX as le,aY as se,aZ as de,av as ue,a_ as fe,at as ge,a$ as K,b0 as U,b1 as W,b2 as ve,aw as me,aC as he,b3 as be}from"./index-CC8pRDT2.js";const[Se,V]=T("tag"),ye={size:String,mark:Boolean,show:D,type:R("default"),color:String,plain:Boolean,round:Boolean,textColor:String,closeable:Boolean};var ke=I({name:Se,props:ye,emits:["close"],setup(e,{slots:n,emit:i}){const l=s=>{s.stopPropagation(),i("close",s)},r=()=>e.plain?{color:e.textColor||e.color,borderColor:e.color}:{color:e.textColor,background:e.color},c=()=>{var s;const{type:h,mark:o,plain:u,round:f,size:d,closeable:g}=e,S={mark:o,plain:u,round:f};d&&(S[d]=d);const b=g&&t(C,{name:"cross",class:[V("close"),O],onClick:l},null);return t("span",{style:r(),class:V([S,h])},[(s=n.default)==null?void 0:s.call(n),b])};return()=>t(Q,{name:e.closeable?"van-fade":void 0},{default:()=>[e.show?c():null]})}});const we=B(ke),[xe,$]=T("image"),Pe={src:String,alt:String,fit:String,position:String,round:Boolean,block:Boolean,width:P,height:P,radius:P,lazyLoad:Boolean,iconSize:P,showError:D,errorIcon:R("photo-fail"),iconPrefix:String,showLoading:D,loadingIcon:R("photo"),crossorigin:String,referrerpolicy:String,decoding:String};var Ce=I({name:xe,props:Pe,emits:["load","error"],setup(e,{emit:n,slots:i}){const l=L(!1),r=L(!0),c=L(),{$Lazyload:s}=G().proxy,h=M(()=>{const a={width:N(e.width),height:N(e.height)};return z(e.radius)&&(a.overflow="hidden",a.borderRadius=N(e.radius)),a});Y(()=>e.src,()=>{l.value=!1,r.value=!0});const o=a=>{r.value&&(r.value=!1,n("load",a))},u=()=>{const a=new Event("load");Object.defineProperty(a,"target",{value:c.value,enumerable:!0}),o(a)},f=a=>{l.value=!0,r.value=!1,n("error",a)},d=(a,y,k)=>k?k():t(C,{name:a,size:e.iconSize,class:y,classPrefix:e.iconPrefix},null),g=()=>{if(r.value&&e.showLoading)return t("div",{class:$("loading")},[d(e.loadingIcon,$("loading-icon"),i.loading)]);if(l.value&&e.showError)return t("div",{class:$("error")},[d(e.errorIcon,$("error-icon"),i.error)])},S=()=>{if(l.value||!e.src)return;const a={alt:e.alt,class:$("img"),decoding:e.decoding,style:{objectFit:e.fit,objectPosition:e.position},crossorigin:e.crossorigin,referrerpolicy:e.referrerpolicy};return e.lazyLoad?Z(t("img",q({ref:c},a),null),[[te("lazy"),e.src]]):t("img",q({ref:c,src:e.src,onLoad:o,onError:f},a),null)},b=({el:a})=>{const y=()=>{a===c.value&&r.value&&u()};c.value?y():F(y)},v=({el:a})=>{a===c.value&&!l.value&&f()};return s&&p&&(s.$on("loaded",b),s.$on("error",v),ee(()=>{s.$off("loaded",b),s.$off("error",v)})),ne(()=>{F(()=>{var a;(a=c.value)!=null&&a.complete&&!e.lazyLoad&&u()})}),()=>{var a;return t("div",{class:$({round:e.round,block:e.block}),style:h.value},[S(),g(),(a=i.default)==null?void 0:a.call(i)])}}});const Ie=B(Ce),[Te,m]=T("card"),Be={tag:String,num:P,desc:String,thumb:String,title:String,price:P,centered:Boolean,lazyLoad:Boolean,currency:R("¥"),thumbLink:String,originPrice:P};var $e=I({name:Te,props:Be,emits:["clickThumb"],setup(e,{slots:n,emit:i}){const l=()=>{if(n.title)return n.title();if(e.title)return t("div",{class:[m("title"),"van-multi-ellipsis--l2"]},[e.title])},r=()=>{if(n.tag||e.tag)return t("div",{class:m("tag")},[n.tag?n.tag():t(we,{mark:!0,type:"primary"},{default:()=>[e.tag]})])},c=()=>n.thumb?n.thumb():t(Ie,{src:e.thumb,fit:"cover",width:"100%",height:"100%",lazyLoad:e.lazyLoad},null),s=()=>{if(n.thumb||e.thumb)return t("a",{href:e.thumbLink,class:m("thumb"),onClick:u=>i("clickThumb",u)},[c(),r()])},h=()=>{if(n.desc)return n.desc();if(e.desc)return t("div",{class:[m("desc"),"van-ellipsis"]},[e.desc])},o=()=>{const u=e.price.toString().split(".");return t("div",null,[t("span",{class:m("price-currency")},[e.currency]),t("span",{class:m("price-integer")},[u[0]]),u.length>1&&t(ae,null,[ie("."),t("span",{class:m("price-decimal")},[u[1]])])])};return()=>{var u,f,d;const g=n.num||z(e.num),S=n.price||z(e.price),b=n["o