使用的是vite + vue3的setup语法糖。

最终实现的效果为:

1.pages.json 中配置"navigationStyle": "custom"。以首页为例。

{
	"pages": [ 
		{
			"path": "pages/index/index",
			"style": {
				"navigationStyle": "custom",  //单个页面设置
				"navigationBarTitleText": "首页"
			}
		}
	],
	
	"globalStyle": {
        // 全局配置
		"navigationStyle": "custom"
	}
}

2.创建components目录,在components目录下创建navbar.vue组件

3.分析结构

顶部状态栏实际上分为两个部分,一个是系统状态栏,一个是状态栏的下方的内容区域。

大致就是图上两个部分。结构分出来后也就比较明了先要做啥了。

(1)获取顶部系统状态栏的高度

不同手机顶部的系统状态栏的高度是不一样的,可以通过方法uni.getSystemInfoSync() 获取顶部安全区域高度。拿到方法中的两个属性statusBarHeight,system。

const setNavSize = ()=>{
		const { statusBarHeight,system } = uni.getSystemInfoSync()
		status.value = statusBarHeight * 2
		const isIOS = system.indexOf('iOS') > -1
		if( !isIOS ){
			navHeight.value = 96  //非ios
		}else{
			navHeight.value = 88  //ios
		}
	}

由于iOS有刘海屏所以,iOS的内容高度为88。

(2)内容部分

首先当我们在主页时,出现主页的图标。

当我们主页有跳转内容时,点击跳转按钮进行跳转后,也就是当前不在主页页面,此时图标会变成返回图标。

HTML实现代码:

<!-- 内容 -->
		<view class="navbar" :style= " 'height:' + navHeight +'rpx;' + containerStyle">
			<view class="back-icon" @click="backHome">
				<image v-if="pages > 1" src="../../static/resource/navbar/ic_back.png" mode=""></image>
				<image v-else src="../../static/resource/navbar/ic_home.png" mode=""></image>
			</view>
			<view class="nav-title" v-if="titleText">
				<view :style=" 'height:' + navHeight + 'rpx;line-height:'+ navHeight + 'rpx;'+ textStyle ">{{titleText}}</view>
			</view>
		</view>

当页面有其他内容而不只是单单的图标时。

此时我们通过传入一个变量“isHome”配合v-if和v-else来实现该效果。

<view v-if="isHome" class="headNav" :style="'height:'+ navHeight + 'rpx;line-height:'+ navHeight + 'rpx;padding-left:20rpx'" >
			<text class="city">中部地区</text>
			<view style="flex:1">
				<navigator
					url="../../pages/search/index"
					:style=" 'height:'+ menu.height*2 + 'rpx;line-height:'+ menu.height*2 + 'rpx;margin-top:'+ (menu.top*2 - status) + 'rpx;margin-left:32rpx;margin-right:'+ (menu.width*2 + 24) + 'rpx;background:#f4f4f4;border-radius:200rpx;text-align:center'"
				>
					<text class="search-text">找医院</text>
				</navigator>
			</view>
		</view>
		<!-- 内容 -->
		<view v-else class="navbar" :style= " 'height:' + navHeight +'rpx;' + containerStyle">
			<view class="back-icon" @click="backHome">
				<image v-if="pages > 1" src="../../static/resource/navbar/ic_back.png" mode=""></image>
				<image v-else src="../../static/resource/navbar/ic_home.png" mode=""></image>
			</view>
			<view class="nav-title" v-if="titleText">
				<view :style=" 'height:' + navHeight + 'rpx;line-height:'+ navHeight + 'rpx;'+ textStyle ">{{titleText}}</view>
			</view>
		</view>

内容部分需要获取内容部分的高度,还需要知道胶囊的位置大小,从而来计算搜索框的大小。通过uni.getMenuButtonBoundingClientRect()来获取胶囊的位置大小。

整个的实现代码如下:

<template>
	<view class="nav">
		<!-- 状态栏 -->
		<view :style= "'height:' + status + 'rpx;' + containerStyle"></view>
		<view v-if="isHome" class="headNav" :style="'height:'+ navHeight + 'rpx;line-height:'+ navHeight + 'rpx;padding-left:20rpx'" >
			<text class="city">中部地区</text>
			<view style="flex:1">
				<navigator
					url="../../pages/search/index"
					:style=" 'height:'+ menu.height*2 + 'rpx;line-height:'+ menu.height*2 + 'rpx;margin-top:'+ (menu.top*2 - status) + 'rpx;margin-left:32rpx;margin-right:'+ (menu.width*2 + 24) + 'rpx;background:#f4f4f4;border-radius:200rpx;text-align:center'"
				>
					<text class="search-text">找医院</text>
				</navigator>
			</view>
		</view>
		<!-- 内容 -->
		<view v-else class="navbar" :style= " 'height:' + navHeight +'rpx;' + containerStyle">
			<view class="back-icon" @click="backHome">
				<image v-if="pages > 1" src="../../static/resource/navbar/ic_back.png" mode=""></image>
				<image v-else src="../../static/resource/navbar/ic_home.png" mode=""></image>
			</view>
			<view class="nav-title" v-if="titleText">
				<view :style=" 'height:' + navHeight + 'rpx;line-height:'+ navHeight + 'rpx;'+ textStyle ">{{titleText}}</view>
			</view>
		</view>
	</view>
</template>

<script setup>
	import { ref,reactive,onBeforeMount,defineProps } from 'vue'
	const props = defineProps({
		background:{
			type:String,
			default:'rgba(255,255,255,1)'
		},
		color:{
			type:String,
			default:'rgba(0,0,0,1)'
		},
		fontSize:{
			type:String,
			default: 32
		},
		iconWidth:{
			type:String,
			default: 116
		},
        iconHeight:{
        	type:String,
        	default: 38
        },
		titleText:{
			type:String,
			default: ''
		},
		isHome: {
			type:Boolean,
			default:false
		}
	})
	//状态栏高度
	const status = ref(0)
	//内容高度
	const navHeight = ref(0)
	//背景颜色
	const containerStyle = ref('')
	//字体样式
	const textStyle = ref('')
	//图标样式
	const iconStyle = ref('')
	//页面栈数量
	const pages = ref(getCurrentPages().length)
	//获取胶囊的位置
	const menu = reactive(uni.getMenuButtonBoundingClientRect())
	
	onBeforeMount(()=>{
		setNavSize()
		setStyle()
	})
	//计算状态栏高度
	const setNavSize = ()=>{
		const { statusBarHeight,system } = uni.getSystemInfoSync()
		status.value = statusBarHeight * 2
		const isIOS = system.indexOf('iOS') > -1
		if( !isIOS ){
			navHeight.value = 96  //非ios
		}else{
			navHeight.value = 88  //ios
		}
	}
	//样式设置
	const setStyle = ()=> {
		containerStyle.value = ['background:'+ props.background].join(';')
		textStyle.value = ['color:'+ props.color,'font-size:'+props.fontSize+'rpx'].join(';')
		iconStyle.value = ['width:'+ props.iconWidth + 'rpx' , 'height:'+ props.iconHeight +'rpx'].join(';')
	}
	const backHome = ()=> {
		if(pages.value > 1){
			uni.navigateBack()
		}else{
			uni.switchTab({
				url:'/pages/index/index'
			})
		}
	}
</script>

<style>
.nav{
	position: fixed;
	width: 100%;
	top: 0;
	left: 0;
	z-index: 2;
}
.back-icon{
	display: flex;
	align-items: center;
	width: 64rpx;
	height: 100%;
	margin-left: 20rpx;
}
.back-icon image{
	width: 64rpx;
	height: 64rpx;
}
.navbar{
	position: relative;
}
.nav-title{
	position: absolute;
	top: 0;
	left: 50%;
	transform: translate(-50%)
}
.headNav{
	display: flex;
}
.city {
    display: inline-block;
    position: relative;
    font-size: 30rpx;
    font-weight: bold;
    padding-left: 55rpx;
    background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAYAAABw4pVUAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAACB6SURBVHja7F0JlFxllb7vvVpe7VW9L0mzRINIgIREGBLHdViU4ejBBUdHHRfE9TjKwTPjMsw4+wgyI4MGEPSIChjEBZEAEwQkBBQkkMRIyNpJdyfdXdVV1bVXvffmfn+9V/2q0+mu6qrq7ozzd+pUVbr61Xv3+++9313+/0mHDh+lpTr6eztURVEG+OXKUkk7WzeMlZqmnaZpepfb5ZQcDsXFv3NLkuTQdUNKJFMenV/IspTnv4vLsjzudDr2KbK8W1bkXbIk7ebPDw4eOZZbxGua9ffSUgJkYFm3k59W8WO9rmkbSpq+rlAoDuQKRTc/k2EYxPIWn+3qCJPT6SQWPhm6Tql0liYSqeqLkyTxwGecDoXcblfB5XIecSjycw6H43H+yFMM4M4jw2PF/wdkCgQHz/oLeUZfxlrw1kw29+p0JqfwawHATENVXQxIRLxmgYrH0dFYBay5BkBizSHV5dTcqmuPR3Xfz//9Cz7ONgan9EcJCANxKj+9M58vvD+bzZ+dyeUlgDDXYDMkLgpCBRBEBkUnJomPMe9z4clAHtVpeD3qDlV138n/dS+btYN/FIAs7+9ax8L8WDaXf1c8kQoXi/VNyO7OCEyPAAMalC+UaDwab9r5uVhzfF5P0u/3bOLz3MjAPPt/EpC+nva1fIGf49n4jrFoXJ3PjPb7PNQWCVbMFLRl+GjU1JTmDhy7syNcYN8DYG48PDT63EIAIi+AaRoYWNZ1E1/UE3yR74MLgIOt36zIVWCwU6ZYfLIlYJT9DD9YYdgv4Zyf4Ou4aaC/e6DV8nK0EAi+Hvr43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T6YrZQnOD3+c9zGB8Etc2HzAWTUOmacsA7ibDM+rDiWTam85k6yqDLuZArIKaj0NRMqxxSA5+jU3zYCPHnEtDWg6INfp7O9Yya/kcz9x3JBIpNWX23y5VIFBQYkee48n0YwbjRrDJZhx7yQBi05h1siRdxUb+imw21xEXmyiXlsROEk6xFsWPNMs4T5b7ePIgbf5sM79jyQFiO7FT+aLfyTPwXfy8bjKVlWHONGt7wQVy/AABgR86//k1hL+Jv/9ejikOtui6lyYgthNE0HIhg3IZg3MRB2ZnZzM5ZyaXp1JRE92BzQLI2usX6+pBy92qu8hx5A4y6BH+5QP8kW1m2bqV17u0AZl2sshUrmJw1jM4F/Lr1RwLnJYvFr2owSDCRsRt75Oa3u5JYu/O8sIdWSzgkcnlZqrqFFtxsHOmA/yJ7RA+H+MpZlA7OY4oLuA1zg7IfGaf1fRWy7OVS7LS3fauQOtzFrW01+jN/0d4PMCPlfx4BT+wFSg2POziB6pLSKChK8FKDWB2o/8Va51xI13UJIb5gSgauSasYwNLylnU2J6Gt1Nmq8vyRHTdqoFPpWzkplD7/xVgANXycrQSArmMAAAAAElFTkSuQmCC)
        no-repeat left center;
    background-size: 40rpx;
}

.city:after {
    content: ' ';
    display: inline-block;
    height: 6px;
    width: 6px;
    border-width: 1px 1px 0 0;
    border-color: #353535;
    border-style: solid;
    -webkit-transform: matrix(0.71, 0.71, -0.71, 0.71, 0, 0);
    transform: matrix(0.71, 0.71, -0.71, 0.71, 0, 0);
    position: relative;
    top: -2px;
    position: absolute;
    top: 50%;
    margin-top: -4px;
    right: -10px;
}
.search-text {
    display: inline-block;
    padding-left: 30rpx;
    color: #bbbbbb;
    font-size: 26rpx;
    background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAPWSURBVHja1FpNSFRRFH4+Zikig4sQkUeEtAgrk4E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dfji7TYAI5Mx/VU3JFQoeGIeJv483VKnKFqjVLxECWBYZ09PuFwaugCaEvSHgWrELxiciT3p5Ww2G6Ys2nxoab2JZp4DhnBtkrooVTKmPjM2Pz8fJI2ISCanOT8TuZfkmMyqAZnEEhHJqMysnHQiuj6Tx1sr6UREMkM1TRJ8dsKjnlzK+z+kGohrG4lh9Y9nfwQYAJts3SyOpWPCAAAAAElFTkSuQmCC)
        no-repeat left center;
    background-size: 23rpx;
}
</style>

4.使用组件navbar

在主页的HTML中使用组件,根据需要传入自定义属性

<navbar :isHome="true"/>

Logo

前往低代码交流专区

更多推荐