niucloud-admin/niucloud/public/wap/assets/tabbar.f7ee8f1f.js
全栈小学生 aca7f2e478 update wap
2023-07-01 16:31:03 +08:00

2 lines
8.1 KiB
JavaScript

import{p as e,_ as t}from"./u-image.9265f18d.js";import{y as a,z as o,ab as r,h as l,i as s,w as i,B as n,x as u,C as d,D as c,F as b,n as h,E as p,H as m,m as g,p as y,j as f,M as v,O as x,q as _,G as S,d as C,c as k,Y as w,ai as I,l as $,N as B,t as D,R as N}from"./index-5bb08350.js";import{_ as P}from"./_plugin-vue_export-helper.1b428a4d.js";import{_ as H}from"./u-icon.461524ba.js";import{_ as A}from"./u-safe-bottom.6578a4de.js";const L=P({name:"u--image",mixins:[a,e,o],components:{uvImage:t},emits:["click","error","load"]},[["render",function(e,t,a,o,u,d){const c=r("uvImage");return l(),s(c,{src:e.src,mode:e.mode,width:e.width,height:e.height,shape:e.shape,radius:e.radius,lazyLoad:e.lazyLoad,showMenuByLongpress:e.showMenuByLongpress,loadingIcon:e.loadingIcon,errorIcon:e.errorIcon,showLoading:e.showLoading,showError:e.showError,fade:e.fade,webp:e.webp,duration:e.duration,bgColor:e.bgColor,customStyle:e.customStyle,onClick:t[0]||(t[0]=t=>e.$emit("click")),onError:t[1]||(t[1]=t=>e.$emit("error")),onLoad:t[2]||(t[2]=t=>e.$emit("load"))},{loading:i((()=>[n(e.$slots,"loading")])),error:i((()=>[n(e.$slots,"error")])),_:3},8,["src","mode","width","height","shape","radius","lazyLoad","showMenuByLongpress","loadingIcon","errorIcon","showLoading","showError","fade","webp","duration","bgColor","customStyle"])}]]);const z=P({name:"u-badge",mixins:[a,{props:{isDot:{type:Boolean,default:u.badge.isDot},value:{type:[Number,String],default:u.badge.value},modelValue:{type:[Number,String],default:u.badge.modelValue},show:{type:Boolean,default:u.badge.show},max:{type:[Number,String],default:u.badge.max},type:{type:String,default:u.badge.type},showZero:{type:Boolean,default:u.badge.showZero},bgColor:{type:[String,null],default:u.badge.bgColor},color:{type:[String,null],default:u.badge.color},shape:{type:String,default:u.badge.shape},numberType:{type:String,default:u.badge.numberType},offset:{type:Array,default:u.badge.offset},inverted:{type:Boolean,default:u.badge.inverted},absolute:{type:Boolean,default:u.badge.absolute}}},o],computed:{boxStyle:()=>({}),badgeStyle(){const e={};if(this.color&&(e.color=this.color),this.bgColor&&!this.inverted&&(e.backgroundColor=this.bgColor),this.absolute&&(e.position="absolute",this.offset.length)){const t=this.offset[0],a=this.offset[1]||t;e.top=uni.$u.addUnit(t),e.right=uni.$u.addUnit(a)}return e},showValue(){switch(this.numberType){case"overflow":return Number(this.value)>Number(this.max)?this.max+"+":this.value;case"ellipsis":return Number(this.value)>Number(this.max)?"...":this.value;case"limit":return Number(this.value)>999?Number(this.value)>=9999?Math.floor(this.value/1e4*100)/100+"w":Math.floor(this.value/1e3*100)/100+"k":this.value;default:return Number(this.value)}}}},[["render",function(e,t,a,o,r,n){const u=m;return e.show&&(0!==Number(e.value)||e.showZero||e.isDot)?(l(),s(u,{key:0,class:b([[e.isDot?"u-badge--dot":"u-badge--not-dot",e.inverted&&"u-badge--inverted","horn"===e.shape&&"u-badge--horn",`u-badge--${e.type}${e.inverted?"--inverted":""}`],"u-badge"]),style:h([e.$u.addStyle(e.customStyle),n.badgeStyle])},{default:i((()=>[d(c(e.isDot?"":n.showValue),1)])),_:1},8,["class","style"])):p("",!0)}],["__scopeId","data-v-99cd5b85"]]);const j=P({name:"u-tabbar-item",mixins:[a,o,{props:{name:{type:[String,Number,null],default:u.tabbarItem.name},icon:{icon:String,default:u.tabbarItem.icon},badge:{type:[String,Number,null],default:u.tabbarItem.badge},dot:{type:Boolean,default:u.tabbarItem.dot},text:{type:String,default:u.tabbarItem.text},badgeStyle:{type:[Object,String],default:u.tabbarItem.badgeStyle}}}],data:()=>({isActive:!1,parentData:{value:null,activeColor:"",inactiveColor:""}}),options:{virtualHost:!0},created(){this.init()},methods:{init(){this.updateParentData(),this.parent||uni.$u.error("u-tabbar-item必须搭配u-tabbar组件使用");const e=this.parent.children.indexOf(this);this.isActive=(this.name||e)===this.parentData.value},updateParentData(){this.getParentData("u-tabbar")},updateFromParent(){this.init()},clickHandler(){this.$nextTick((()=>{const e=this.parent.children.indexOf(this),t=this.name||e;t!==this.parent.value&&this.parent.$emit("change",t),this.$emit("click",t)}))}}},[["render",function(e,t,a,o,r,u){const b=g(y("u-icon"),H),p=g(y("u-badge"),z),S=_,C=m;return l(),s(S,{class:"u-tabbar-item",style:h([e.$u.addStyle(e.customStyle)]),onClick:u.clickHandler},{default:i((()=>[f(S,{class:"u-tabbar-item__icon"},{default:i((()=>[e.icon?(l(),s(b,{key:0,name:e.icon,color:r.isActive?r.parentData.activeColor:r.parentData.inactiveColor,size:20},null,8,["name","color"])):(l(),v(x,{key:1},[r.isActive?n(e.$slots,"active-icon",{key:0},void 0,!0):n(e.$slots,"inactive-icon",{key:1},void 0,!0)],64)),f(p,{absolute:"",offset:[0,e.dot?"34rpx":e.badge>9?"14rpx":"20rpx"],customStyle:e.badgeStyle,isDot:e.dot,value:e.badge||(e.dot?1:null),show:e.dot||e.badge>0},null,8,["offset","customStyle","isDot","value","show"])])),_:3}),n(e.$slots,"text",{},(()=>[f(C,{class:"u-tabbar-item__text",style:h({color:r.isActive?r.parentData.activeColor:r.parentData.inactiveColor})},{default:i((()=>[d(c(e.text),1)])),_:1},8,["style"])]),!0)])),_:3},8,["style","onClick"])}],["__scopeId","data-v-b5faebd4"]]);const M=P({name:"u-tabbar",mixins:[a,o,{props:{value:{type:[String,Number,null],default:u.tabbar.value},safeAreaInsetBottom:{type:Boolean,default:u.tabbar.safeAreaInsetBottom},border:{type:Boolean,default:u.tabbar.border},zIndex:{type:[String,Number],default:u.tabbar.zIndex},activeColor:{type:String,default:u.tabbar.activeColor},inactiveColor:{type:String,default:u.tabbar.inactiveColor},fixed:{type:Boolean,default:u.tabbar.fixed},placeholder:{type:Boolean,default:u.tabbar.placeholder}}}],data:()=>({placeholderHeight:0}),computed:{tabbarStyle(){const e={zIndex:this.zIndex};return uni.$u.deepMerge(e,uni.$u.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()))},async setPlaceholderHeight(){this.fixed&&this.placeholder&&(await uni.$u.sleep(20),this.$uGetRect(".u-tabbar__content").then((({height:e=50})=>{this.placeholderHeight=e})))}}},[["render",function(e,t,a,o,r,u){const d=_,c=g(y("u-safe-bottom"),A);return l(),s(d,{class:"u-tabbar"},{default:i((()=>[f(d,{class:b(["u-tabbar__content",[e.border&&"u-border-top",e.fixed&&"u-tabbar--fixed"]]),ref:"u-tabbar__content",onTouchmove:S(e.noop,["stop","prevent"]),style:h([u.tabbarStyle])},{default:i((()=>[f(d,{class:"u-tabbar__content__item-wrapper"},{default:i((()=>[n(e.$slots,"default",{},void 0,!0)])),_:3}),e.safeAreaInsetBottom?(l(),s(c,{key:0})):p("",!0)])),_:3},8,["onTouchmove","class","style"]),e.placeholder?(l(),s(d,{key:0,class:"u-tabbar__placeholder",style:h({height:r.placeholderHeight+"px"})},null,8,["style"])):p("",!0)])),_:3})}],["__scopeId","data-v-b564ac71"]]),T=P(C({__name:"tabbar",setup(e){const t=k((()=>w().tabbar)),a=k((()=>"/"+I())),o=e=>{N({url:`${e}`})};return(e,r)=>{const n=g(y("u-tabbar-item"),j),u=g(y("u-tabbar"),M),d=_;return l(),v(x,null,[$(t)?(l(),s(u,{key:0,value:$(a),onChange:o,fixed:!0,placeholder:!0,safeAreaInsetBottom:!0,"inactive-color":$(t).textColor,"active-color":$(t).textHoverColor},{default:i((()=>[(l(!0),v(x,null,B($(t).list,(e=>(l(),v(x,null,[1==$(t).type?(l(),s(n,{key:0,style:h({"background-color":$(t).backgroundColor}),text:e.text,icon:$(D)($(a)==e.link.url?e.iconSelectPath:e.iconPath),name:e.link.url},null,8,["style","text","icon","name"])):p("",!0),2==$(t).type?(l(),s(n,{key:1,style:h({"background-color":$(t).backgroundColor}),icon:$(D)($(a)==e.link.url?e.iconSelectPath:e.iconPath),name:e.link.url},null,8,["style","icon","name"])):p("",!0),3==$(t).type?(l(),s(n,{key:2,style:h({"background-color":$(t).backgroundColor}),text:e.text,name:e.link.url},null,8,["style","text","name"])):p("",!0)],64)))),256))])),_:1},8,["value","inactive-color","active-color"])):p("",!0),f(d,{class:"tab-bar-placeholder"})],64)}}}),[["__scopeId","data-v-d23d1a6b"]]);export{L as _,T as a};