2 lines
2.2 KiB
JavaScript
2 lines
2.2 KiB
JavaScript
|
"use strict";const e=require("../../../../../common/vendor.js"),t=require("../../helper/index.js"),r=require("../../index.js"),a={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:r.sheep.$platform.device.safeAreaInsets.bottom}),computed:{tabbarStyle(){const e={zIndex:this.zIndex};return t.deepMerge(e,t.addStyle(this.customStyle))},updateChild(){return[this.value,this.activeColor,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((e=>e.updateFromParent()))},getRect(t,r){return new Promise((a=>{e.index.createSelectorQuery().in(this)[r?"selectAll":"select"](t).boundingClientRect((e=>{r&&Array.isArray(e)&&e.length&&a(e),!r&&e&&a(e)})).exec()}))},setPlaceholderHeight(){return e=this,r=null,a=function*(){this.fixed&&this.placeholder&&(yield t.sleep(20),this.getRect(".u-tabbar__content").then((({height:e=50})=>{this.placeholderHeight=e})))},new Promise(((t,l)=>{var i=e=>{try{d(a.next(e))}catch(t){l(t)}},o=e=>{try{d(a.throw(e))}catch(t){l(t)}},d=e=>e.done?t(e.value):Promise.resolve(e.value).then(i,o);d((a=a.apply(e,r)).next())}));var e,r,a}}};const l=e._export_sfc(a,[["render",function(t,r,a,l,i,o){return e.e({a:a.safeAreaInsetBottom},a.safeAreaInsetBottom?{b:e.s({height:i.safeBottomHeight+"px"})}:{},{c:e.o((()=>{})),d:e.n(a.border&&"u-border-top"),e:e.n(a.fixed&&"u-tabbar--fixed"),f:e.n({"mid-tabbar":a.midTabBar}),g:e.s(o.tabbarStyle),h:a.placeholder},a.placeholder?{i:i.placeholderHeight+"px"}:{})}],["__scopeId","data-v-2860881e"]]);wx.createComponent(l);
|