You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
104 lines
2.1 KiB
104 lines
2.1 KiB
<template>
|
|
<view :style="{height: sumHeight}">
|
|
<view class="stabar" :style="{height: height}"></view>
|
|
<view class="header" :style="{top: height, height: navHeight}">
|
|
<label v-if="isBack" class="back" @click="back()"></label>
|
|
<label v-else class="noback"></label>
|
|
<view class="title">{{title}}</view>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
name:"navigation",
|
|
data() {
|
|
return {
|
|
height: 0,
|
|
navHeight: 0,
|
|
sumHeight: 0,
|
|
};
|
|
},
|
|
props: {
|
|
title: {
|
|
type: String,
|
|
default: ''
|
|
},
|
|
isBack: {
|
|
type: Boolean,
|
|
default: true
|
|
}
|
|
},
|
|
created() {
|
|
this.getWXStatusHeight();
|
|
},
|
|
methods: {
|
|
getWXStatusHeight() {
|
|
//获取状态栏高度
|
|
const statusBarHeight = uni.getSystemInfoSync().statusBarHeight
|
|
//获取小程序胶囊信息
|
|
const menu = uni.getMenuButtonBoundingClientRect()
|
|
//导航栏高度 == (胶囊距顶部高度-状态栏高度) *2 +胶囊高度
|
|
const navBarHeightWechat = (menu.top - statusBarHeight) * 2 + menu.height
|
|
//头部整体高度 ==状态栏高度 + 导航栏高度
|
|
const headerHeight = statusBarHeight + navBarHeightWechat
|
|
//计算导航内容距离顶部高度= 状态栏高度/2
|
|
const topHeight = statusBarHeight / 2
|
|
this.height = menu.top + "px"
|
|
this.navHeight = menu.height + "px"
|
|
this.sumHeight = (menu.top + menu.height) + "px"
|
|
},
|
|
back(){
|
|
uni.navigateBack({
|
|
delta:1,//返回层数,2则上上页
|
|
})
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style>
|
|
navigation {
|
|
background-color: #bac6fc;
|
|
}
|
|
|
|
.header {
|
|
position: relative;
|
|
z-index: 99;
|
|
top: 90rpx;
|
|
width: 100%;
|
|
height: 90rpx;
|
|
background-color: #bac6fc;
|
|
}
|
|
|
|
label.back {
|
|
display: inline-block;
|
|
position: relative;
|
|
top: 0;
|
|
left: 4%;
|
|
padding-left: 1.25rem;
|
|
width: 60rpx;
|
|
height: 60rpx;
|
|
background: url(/static/images/icon_arb.png) no-repeat left center;
|
|
background-size: auto 60%;
|
|
}
|
|
|
|
label.noback {
|
|
display: inline-block;
|
|
position: relative;
|
|
top: 16rpx;
|
|
left: 4%;
|
|
padding-left: 1.25rem;
|
|
width: 60rpx;
|
|
height: 60rpx;
|
|
background-size: auto 60%;
|
|
}
|
|
|
|
.title {
|
|
margin: -64rpx 0 50rpx;
|
|
color: #333;
|
|
font-size: 36rpx;
|
|
font-weight: bold;
|
|
text-align: center;
|
|
}
|
|
</style>
|