111 lines
2.4 KiB
Vue
111 lines
2.4 KiB
Vue
<template>
|
||
<view class="custom-navbar">
|
||
<view class="navbar-main" :style="{paddingTop:navBarPaddingTop+'px'}">
|
||
<!-- 左侧内容 -->
|
||
<view class="navbar-left" @click="handleBack" v-if="leftFlag">
|
||
<uni-icons type="left" size="24" color="#fff"></uni-icons>
|
||
</view>
|
||
|
||
<!-- 中间标题 -->
|
||
<view class="navbar-title">{{ title }}</view>
|
||
|
||
<!-- 右侧内容 -->
|
||
<view class="navbar-right" v-if="rightFlag">
|
||
<slot name="right"></slot>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</template>
|
||
|
||
<script setup>
|
||
import { ref, onMounted } from 'vue'
|
||
import { getNavBarPaddingTop,getNavBarHeight,getStatusBarHeight} from '@/utils/system.js'
|
||
|
||
const props = defineProps({
|
||
title: String,
|
||
leftFlag:true,//默认左侧显示 false-不显示
|
||
rightFlag:false,//默认右侧不显示
|
||
searchType:{default:0}//搜索返回为1,其他暂时不处理
|
||
})
|
||
|
||
const emit = defineEmits(['back'])
|
||
|
||
let navBarPaddingTop = ref(0)
|
||
let statusBarHeight = ref(0)
|
||
let navbarHeight = ref(0)
|
||
let navHeight = ref(0)
|
||
|
||
onMounted(() => {
|
||
navBarPaddingTop.value = getNavBarPaddingTop();
|
||
statusBarHeight.value = getStatusBarHeight();
|
||
navbarHeight.value = getNavBarHeight();
|
||
navHeight.value = navbarHeight.value - statusBarHeight.value
|
||
})
|
||
|
||
const handleBack = () => {
|
||
emit('back')
|
||
if(!props.searchType)
|
||
uni.navigateBack()
|
||
}
|
||
</script>
|
||
|
||
<style scoped>
|
||
.custom-navbar {
|
||
width: 100%;
|
||
position: fixed;
|
||
top: 0;
|
||
z-index: 999;
|
||
/* #ifdef APP-PLUS */
|
||
background: #307AF5 url('@/static/images/bg-Blue-header.png') no-repeat;
|
||
background-size:100% 160rpx;
|
||
height:160rpx;
|
||
/* #endif */
|
||
|
||
/* #ifndef APP-PLUS */
|
||
background: #307AF5 url('@/static/images/bg-Blue-header2.png') no-repeat;
|
||
background-size:100% 116rpx;
|
||
height:116rpx;
|
||
/* #endif */
|
||
|
||
}
|
||
|
||
.navbar-content {
|
||
width: 100%;
|
||
}
|
||
|
||
.navbar-main {
|
||
width: 100%;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
padding: 0 30rpx;
|
||
box-sizing: border-box;
|
||
color:#fff;
|
||
/* #ifdef APP-PLUS */
|
||
height:160rpx;
|
||
/* #endif */
|
||
/* #ifndef APP-PLUS */
|
||
height:116rpx;
|
||
/* #endif */
|
||
}
|
||
|
||
.navbar-left{
|
||
width: 70rpx;
|
||
text-align: left;
|
||
}
|
||
|
||
.navbar-title {
|
||
flex: 1;
|
||
font-size: 36rpx;
|
||
font-weight: bold;
|
||
overflow: hidden;
|
||
text-overflow: ellipsis;
|
||
white-space: nowrap;
|
||
color:#fff;
|
||
margin-top:-3rpx;
|
||
}
|
||
|
||
.navbar-right{
|
||
margin-left: auto;
|
||
}
|
||
</style> |