1 |
- import{aI as t,ay as e,aJ as a,e as l,d as r,w as s,f as i,y as n,F as o,aj as c,n as u,g as d,j as p,k as h,i as b,l as m,s as y,aK as g,ah as f,aL as v,J as _,L as S,x,c as C,a as k,b as B,z as I,u as $}from"./index-D3w8LAvI.js";import{_ as D}from"./_plugin-vue_export-helper.BCo6x5W8.js";const A=D({name:"su-tabbar-item",props:{customStyle:{type:[Object,String],default:()=>({})},customClass:{type:String,default:""},url:{type:String,default:""},linkType:{type:String,default:"navigateTo"},name:{type:[String,Number,null],default:""},icon:{icon:String,default:""},badge:{type:[String,Number,null],default:""},dot:{type:Boolean,default:!1},text:{type:String,default:""},badgeStyle:{type:[Object,String],default:""},isCenter:{type:Boolean,default:!1},centerImage:{type:String,default:""}},data:()=>({isActive:!1,addStyle:t,parentData:{value:null,activeColor:"",color:""},parent:{}}),setup(){const{t:t}=e();return{t:t}},created(){this.init()},methods:{getParentData(t=""){this.parent||(this.parent={}),this.parent=a.call(this,t),this.parent.children&&-1===this.parent.children.indexOf(this)&&this.parent.children.push(this),this.parent&&this.parentData&&Object.keys(this.parentData).map((t=>{this.parentData[t]=this.parent[t]}))},init(){this.updateParentData(),this.parent||console.log("u-tabbar-item必须搭配u-tabbar组件使用");const t=this.parent.children.indexOf(this);this.isActive=(this.name.split("?")[0]||t)===this.parentData.value},updateParentData(){this.getParentData("su-tabbar")},updateFromParent(){this.init()},clickHandler(){this.$nextTick((()=>{const t=this.parent.children.indexOf(this),e=this.name||t;e!==this.parent.value&&this.parent.$emit("change",e),this.$emit("click",e)}))}}},[["render",function(t,e,a,y,g,f){const v=h,_=b,S=m;return l(),r(_,{class:"u-tabbar-item",style:u([g.addStyle(a.customStyle)])},{default:s((()=>[a.isCenter?(l(),r(_,{key:0,class:"tabbar-center-item"},{default:s((()=>[i(v,{class:"center-image",src:a.centerImage,mode:"aspectFill"},null,8,["src"])])),_:1})):(l(),n(o,{key:1},[i(_,{class:"u-tabbar-item__icon"},{default:s((()=>[a.icon?(l(),r(v,{key:0,name:a.icon,color:g.isActive?g.parentData.activeColor:g.parentData.color,size:20},null,8,["name","color"])):(l(),n(o,{key:1},[g.isActive?c(t.$slots,"active-icon",{key:0},void 0,!0):c(t.$slots,"inactive-icon",{key:1},void 0,!0)],64))])),_:3}),c(t.$slots,"text",{},(()=>[i(S,{class:"u-tabbar-item__text",style:u({color:g.isActive?g.parentData.activeColor:g.parentData.color})},{default:s((()=>[d(p(a.text),1)])),_:1},8,["style"])]),!0)],64))])),_:3},8,["style"])}],["__scopeId","data-v-06f1029a"]]);const P=D({name:"su-tabbar",props:{customStyle:{type:[Object,String],default:()=>({})},customClass:{type:String,default:""},url:{type:String,default:""},linkType:{type:String,default:"navigateTo"},value:{type:[String,Number,null],default:""},safeAreaInsetBottom:{type:Boolean,default:!0},border:{type:Boolean,default:!0},zIndex:{type:[String,Number],default:10},activeColor:{type:String,default:"#1989fa"},inactiveColor:{type:String,default:"#7d7e80"},fixed:{type:Boolean,default:!0},placeholder:{type:Boolean,default:!0},midTabBar:{type:Boolean,default:!1}},data:()=>({placeholderHeight:0,safeBottomHeight:y.$platform.device.safeAreaInsets.bottom}),computed:{tabbarStyle(){const e={zIndex:this.zIndex};return g(e,t(this.customStyle))},updateChild(){return[this.value,this.activeColor,this.inactiveColor]},color(){return this.inactiveColor},updatePlaceholder(){return[this.fixed,this.placeholder]}},watch:{updateChild(){this.updateChildren()},updatePlaceholder(){this.setPlaceholderHeight()}},created(){this.children=[]},mounted(){this.setPlaceholderHeight()},methods:{updateChildren(){this.children.length&&this.children.map((t=>t.updateFromParent()))},getRect(t,e){return new Promise((a=>{f().in(this)[e?"selectAll":"select"](t).boundingClientRect((t=>{e&&Array.isArray(t)&&t.length&&a(t),!e&&t&&a(t)})).exec()}))},async setPlaceholderHeight(){this.fixed&&this.placeholder&&(await v(20),this.getRect(".u-tabbar__content").then((({height:t=50})=>{this.placeholderHeight=t})))}}},[["render",function(t,e,a,n,o,d){const p=b;return l(),r(p,{class:"u-tabbar"},{default:s((()=>[i(p,{class:_(["u-tabbar__content",[a.border&&"u-border-top",a.fixed&&"u-tabbar--fixed",{"mid-tabbar":a.midTabBar}]]),ref:"u-tabbar__content",onTouchmove:e[0]||(e[0]=S((()=>{}),["stop","prevent"])),style:u([d.tabbarStyle])},{default:s((()=>[i(p,{class:"u-tabbar__content__item-wrapper"},{default:s((()=>[c(t.$slots,"default",{},void 0,!0)])),_:3}),a.safeAreaInsetBottom?(l(),r(p,{key:0,style:u([{height:o.safeBottomHeight+"px"}])},null,8,["style"])):x("",!0)])),_:3},8,["class","style"]),a.placeholder?(l(),r(p,{key:0,class:"u-tabbar__placeholder",style:u({height:o.placeholderHeight+"px"})},null,8,["style"])):x("",!0)])),_:3})}],["__scopeId","data-v-90875691"]]),T=D({__name:"s-tabbar",props:{path:{type:String,default:""},tabbar:{type:Object,default:()=>{}}},setup(t){const e=t,a=C((()=>e.tabbar?e.tabbar:(console.log(y.$store("app").template.home.tabBar),y.$store("app").template.home.tabBar))),c=C((()=>{const t=a.value.style;return"color"===t.bgType?{background:t.bgColor}:"img"===t.bgType?{background:`url(${y.$url.cdn(t.bgImg)}) no-repeat top center / 100% auto`}:void 0})),u=t=>2===$(a).mode&&($(a).items%2>0&&Math.ceil($(a).items.length/2)===t+1);return(e,d)=>{var p,m;const g=h,f=k(B("su-tabbar-item"),A),v=k(B("su-tabbar"),P),_=b;return(null==(m=null==(p=a.value)?void 0:p.items)?void 0:m.length)>0?(l(),r(_,{key:0,class:"u-page__item"},{default:s((()=>[i(v,{value:t.path,fixed:!0,placeholder:!0,safeAreaInsetBottom:!0,inactiveColor:a.value.style.color,activeColor:a.value.style.activeColor,midTabBar:2===a.value.mode,customStyle:c.value},{default:s((()=>[(l(!0),n(o,null,I(a.value.items,((t,e)=>(l(),r(f,{key:t.text,text:t.text,name:t.url,isCenter:u(e),centerImage:$(y).$url.cdn(t.iconUrl),onClick:e=>$(y).$router.go(t.url)},{"active-icon":s((()=>[i(g,{class:"u-page__item__slot-icon",src:$(y).$url.cdn(t.activeIconUrl)},null,8,["src"])])),"inactive-icon":s((()=>[i(g,{class:"u-page__item__slot-icon",src:$(y).$url.cdn(t.iconUrl)},null,8,["src"])])),_:2},1032,["text","name","isCenter","centerImage","onClick"])))),128))])),_:1},8,["value","inactiveColor","activeColor","midTabBar","customStyle"])])),_:1})):x("",!0)}}},[["__scopeId","data-v-7841d127"]]);export{T as _};
|