Files
2026-08-17 13:59:12 +08:00

14 lines
3.0 KiB
JavaScript

"use strict";const c=require("../../common/vendor.js"),L=require("../utils/svgDataUrl.js"),v=require("../utils/treeLevels.js"),M={__name:"SugarTreeGraphic",props:{level:{type:Number,default:0},size:{type:String,default:"md"},watering:{type:Boolean,default:!1}},setup(n){const l=v.TREE_MAX_LEVEL,o=c.ref(!0),x=n,r=c.computed(()=>Math.min(l,Math.max(0,Number(x.level)||0))),y=c.computed(()=>{const t=r.value;return t<=0?0:t<=2?1:t<=4?2:t<=6?3:t<=8?4:5}),$=c.computed(()=>(v.TREE_LEVELS[r.value]||v.TREE_LEVELS[0]).emoji);function h(t){const s=`
<ellipse cx="24" cy="50" rx="15" ry="3" fill="#204e2b" opacity="0.12"/>
<path d="M11 46h26c1.2 0 2 1 2 2.2v3.8c0 1-.8 1.8-1.8 1.8H10.8c-1 0-1.8-.8-1.8-1.8v-3.8c0-1.2.8-2.2 2-2.2z" fill="#E7E5E4"/>
<path d="M12.5 46h23c.8 0 1.5.7 1.5 1.5v2.2c0 .6-.5 1.1-1.1 1.1H12.1c-.6 0-1.1-.5-1.1-1.1v-2.2c0-.8.7-1.5 1.5-1.5z" fill="#D6D3D1"/>
<ellipse cx="24" cy="46.5" rx="9" ry="1.6" fill="#A8A29E" opacity="0.35"/>
`,u='<ellipse cx="24" cy="44.5" rx="8" ry="2.2" fill="#386641" opacity="0.18"/>';if(t<=0)return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 56" fill="none">
${s}${u}
<circle cx="24" cy="41.5" r="2.2" fill="#a8a29e" opacity="0.7"/>
<path d="M24 41.5v3.5" stroke="#78716c" stroke-width="1" stroke-linecap="round"/>
</svg>`;const f=t>=6?16:t>=3?14:10,d=46-f,w=`<rect x="22.2" y="${d}" width="3.6" height="${f}" rx="1.8" fill="#78716C"/>
<rect x="22.6" y="${d+1}" width="2.8" height="${f-1}" rx="1.4" fill="#A8A29E" opacity="0.35"/>`,e=(m,g,a,b,k=1)=>`<circle cx="${m}" cy="${g}" r="${a}" fill="${b}" opacity="${k}"/>
<circle cx="${m-a*.25}" cy="${g-a*.2}" r="${a*.35}" fill="#eef6ef" opacity="0.55"/>`,p=t>=7?e(17,18,3,"#fda4af",.95)+e(31,17,2.8,"#f9a8d4",.9)+e(24,13,3.2,"#fb7185",.95)+'<circle cx="24" cy="12" r="1.3" fill="#fef3c7"/>':"",_=t>=9?e(12,22,6,"#34d399",.9)+e(36,22,6,"#34d399",.9)+e(24,10,7,"#386641",.95)+p:p;let i="";return t===1?i=e(24,38,4,"#afe2b3")+'<path d="M24 38v-5" stroke="#386641" stroke-width="1.2" stroke-linecap="round"/>':t===2?i=e(24,32,5.5,"#34d399")+e(20,34,3.5,"#6ee7b7",.9):t<=4?i=e(24,28,7,"#34d399")+e(17,30,5,"#6ee7b7",.9)+e(31,30,5,"#6ee7b7",.9):t<=6?i=e(24,24,9,"#22c55e")+e(14,26,7,"#4ade80",.92)+e(34,26,7,"#4ade80",.92)+e(24,16,6,"#386641",.88):i=e(24,20,10,"#204e2b")+e(13,24,8,"#34d399",.95)+e(35,24,8,"#34d399",.95)+_,`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 56" fill="none">${s}${u}${w}${i}</svg>`}const E=c.computed(()=>L.svgToDataUrl(h(r.value)));return(t,s)=>c.e({a:r.value>=7},r.value>=7?{}:{},{b:!o.value},o.value?{e:c.t($.value)}:{c:E.value,d:c.o(u=>o.value=!0,"20")},{f:r.value>=7},r.value>=7?{}:{},{g:r.value>=8},r.value>=8?{}:{},{h:r.value>=c.unref(l)},r.value>=c.unref(l)?{}:{},{i:c.n(`lv-${r.value}`),j:c.n(`tier-${y.value}`),k:c.n(`size-${n.size}`),l:c.n({watering:n.watering,"is-max":r.value>=c.unref(l)})})}},T=c._export_sfc(M,[["__scopeId","data-v-d91cb5e7"]]);wx.createComponent(T);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/tongji/components/SugarTreeGraphic.js.map