index.e6e212d8.js 3.7 KB

1
  1. import{S as v,U as m,W as I,X as y,j as i,A as R,E as _,G as $,d as k,ad as w,aT as u,aU as A,M as N,N as F,n as o,f,F as P}from"./index.394decd7.js";const L=t=>{const a=v(),e=()=>{a.value=y(t).height};return m(()=>{I(e),setTimeout(e,100)}),a};function E(t,a){const e=L(t);return l=>i("div",{class:a("placeholder"),style:{height:e.value?`${e.value}px`:void 0}},[l()])}const[M,n]=R("nav-bar"),O={title:String,fixed:Boolean,zIndex:_,border:$,leftText:String,rightText:String,leftArrow:Boolean,placeholder:Boolean,safeAreaInsetTop:Boolean};var z=k({name:M,props:O,emits:["click-left","click-right"],setup(t,{emit:a,slots:e}){const l=v(),s=E(l,n),h=c=>a("click-left",c),r=c=>a("click-right",c),p=()=>e.left?e.left():[t.leftArrow&&i(N,{class:n("arrow"),name:"arrow-left"},null),t.leftText&&i("span",{class:n("text")},[t.leftText])],H=()=>e.right?e.right():i("span",{class:n("text")},[t.rightText]),d=()=>{const{title:c,fixed:x,border:S,zIndex:b}=t,B=w(b),T=t.leftArrow||t.leftText||e.left,C=t.rightText||e.right;return i("div",{ref:l,style:B,class:[n({fixed:x}),{[A]:S,"van-safe-area-top":t.safeAreaInsetTop}]},[i("div",{class:n("content")},[T&&i("div",{class:[n("left"),u],onClick:h},[p()]),i("div",{class:[n("title"),"van-ellipsis"]},[e.title?e.title():c]),C&&i("div",{class:[n("right"),u],onClick:r},[H()])])])};return()=>t.fixed&&t.placeholder?s(d):d()}});const j=F(z);const D="_colHeader_9vc6f_1",U="_transparent_9vc6f_11",G="_headerSection_9vc6f_14";var g={colHeader:D,transparent:U,headerSection:G},V=k({name:"col-header",props:{title:String,isBack:{type:Boolean,default:!0},backIconColor:{type:String,default:"black"},isFixed:{type:Boolean,default:!0},styleName:{type:Object,default:()=>({})},titleClass:String,background:{type:String,default:"white"},color:{type:String,default:"#323233"},rightText:String,onClickRight:{type:Function,default:()=>{}},border:{type:Boolean,default:!0},onHeaderBack:{type:Function,default:()=>{}}},watch:{backIconColor(){o({api:"backIconChange",content:{iconStyle:this.backIconColor}})}},data(){return{headerTitle:null,navBarHeight:0,titleHeight:44}},mounted(){this.headerTitle=this.title||this.$route.meta.title,this.navBarInit(()=>{this.onHeaderBack&&this.onHeaderBack()})},unmounted(){o({api:"setBarStatus",content:{status:1}}),o({api:"backIconChange",content:{iconStyle:"black"}})},methods:{navBarInit(t){o({api:"setBarStatus",content:{status:0}}),o({api:"backIconChange",content:{iconStyle:this.backIconColor||"black"}});const a=sessionStorage.getItem("navHeight"),e=sessionStorage.getItem("titleHeight");a&&e?(this.navBarHeight=Number(a),t&&t()):o({api:"getNavHeight"},l=>{const{content:s}=l,h=s.dpi||2;if(s.navHeight){const r=s.navHeight/h;sessionStorage.setItem("navHeight",String(r)),this.navBarHeight=r}if(s.titleHeight){const r=s.titleHeight/h;sessionStorage.setItem("titleHeight",String(r)),this.titleHeight=r}t&&t()}),!f().isApp&&t&&t()},onClickLeft(){f().isApp?o({api:"goBack"}):this.$router.back()},clickRight(){this.onClickRight&&this.onClickRight()}},render(){return i("div",null,[this.$slots.content?i("div",{style:{paddingTop:`${this.navBarHeight}px`,background:this.background},class:g.headerSection},[this.$slots.content(this.navBarHeight)]):i(P,null,[i("div",{style:{minHeight:`calc(var(--van-nav-bar-height) + ${this.navBarHeight}px)`},class:g.headerSection},[i(j,{title:this.headerTitle,class:[g.colHeader],style:{background:this.background,color:this.color,paddingTop:`${this.navBarHeight}px`,zIndex:99},"left-arrow":this.isBack,rightText:this.rightText,fixed:this.isFixed,border:this.border,"onClick-right":this.clickRight,"onClick-left":this.onClickLeft},{right:()=>this.$slots.right&&this.$slots.right()||this.rightText})]),this.$slots.default?this.$slots.default():null])])}});export{V as C,j as N,L as u};