Initial commit
This commit is contained in:
@@ -0,0 +1,162 @@
|
||||
<template>
|
||||
<view>
|
||||
<view class="nav-box" :style="{'height':height+'px', 'background': bgColor,
|
||||
'position': flex==true?'fixed':'','width': '100%','z-index':100}">
|
||||
<!-- 自定义导航栏 -->
|
||||
<view class="status_bar" :style="{'height':statusBarHeight+'px'}">
|
||||
<!-- uni-ui这里是状态栏 -->
|
||||
</view>
|
||||
<!-- 胶囊位置信息 -->
|
||||
<view class="nav-main flex " :class="{'levelcenter':isJcenter}" :style="{height: navBarHeight+'px'}">
|
||||
<view class="nav-main-back" @click="back" v-if="backIcon" style="display: flex;align-items: center;">
|
||||
|
||||
<image v-if="iconChange" class="nav-main-back-img" mode="heightFix" src="../static/back/back-black.png" />
|
||||
|
||||
<image v-else class="nav-main-back-img" src="../static/back/n-back-mini.png"/>
|
||||
</view>
|
||||
|
||||
<view v-if="isJcenter" style="display: flex; justify-content: center;align-items: center;justify-self: center;align-self: center">
|
||||
<!-- <image class="nav-main-back-img" mode="heightFix" src="../static/n-main/yxg-icon.png" /> -->
|
||||
|
||||
<text class="nav-main-title u-text-center" :style="
|
||||
{'color':titleColor,'fontFamily':'GenYoMinJP','marginLeft':'10rpx'}">
|
||||
{{ title }}
|
||||
</text>
|
||||
</view>
|
||||
<text v-else class="nav-main-title u-text-center" :style="
|
||||
{'color':titleColor}">
|
||||
{{ title }}
|
||||
</text>
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="flex" :style="{'height':height+'px','background-attachment': 'fixed','background':bgColor }">
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</template>
|
||||
|
||||
<script>
|
||||
// import UIcon from "../uview-ui/components/u-icon/u-icon";
|
||||
export default {
|
||||
// components: {myNav},
|
||||
props: {
|
||||
bgColor: {type: String, default: "none"},
|
||||
titleColor: {type: String, default: "rgba(97, 77, 73, 1)"},
|
||||
backIcon: {type: Boolean, default: true},
|
||||
backHome: {type: Boolean, default: false},
|
||||
flex: {type: Boolean, default: false},
|
||||
title: {type: String, default: "我的"},
|
||||
delta:{type:Number,default: 1},
|
||||
tabBarPath:{type:String,default: ""},
|
||||
iconChange:{type: Boolean, default: false},
|
||||
isJcenter:{type: Boolean, default: false}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
//总高度
|
||||
height: 0,
|
||||
//胶囊位置信息
|
||||
menuButtonRect: {},
|
||||
//状态栏的高度
|
||||
statusBarHeight: 0,
|
||||
//导航栏的高度
|
||||
navBarHeight: 0
|
||||
}
|
||||
},
|
||||
created() {
|
||||
// this.height = wx.getStorageSync('navBarHeight')
|
||||
this.getHeight();
|
||||
},
|
||||
methods: {
|
||||
//获取屏幕导航栏高度
|
||||
getHeight() {
|
||||
if (uni.canIUse('getMenuButtonBoundingClientRect')) {
|
||||
let sysInfo = uni.getSystemInfoSync(); //状态栏的高度
|
||||
this.statusBarHeight = sysInfo.statusBarHeight;
|
||||
// 胶囊位置信息
|
||||
let rect = uni.getMenuButtonBoundingClientRect();
|
||||
|
||||
this.menuButtonRect = JSON.parse(JSON.stringify(rect));
|
||||
// 导航栏高度
|
||||
let navBarHeight = (rect.top - sysInfo.statusBarHeight) * 2 + rect.height;
|
||||
this.navBarHeight = navBarHeight;
|
||||
// 自定义导航栏的高度
|
||||
this.height = sysInfo.statusBarHeight + navBarHeight;
|
||||
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '您的微信版本过低,界面可能会显示不正常',
|
||||
icon: 'none',
|
||||
duration: 4000
|
||||
});
|
||||
}
|
||||
},
|
||||
//返回
|
||||
back() {
|
||||
if (this.backHome) {
|
||||
uni.reLaunch({
|
||||
url: '/pages/index/index'
|
||||
})
|
||||
return
|
||||
}
|
||||
if (this.tabBarPath){
|
||||
uni.reLaunch({
|
||||
url: this.tabBarPath
|
||||
});
|
||||
}else{
|
||||
uni.navigateBack({
|
||||
delta: this.delta
|
||||
})
|
||||
}
|
||||
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
.levelcenter{
|
||||
justify-content: center;
|
||||
}
|
||||
.status_bar {
|
||||
// height: var(--status-bar-height);
|
||||
width: 100%;
|
||||
// background:#ff0;
|
||||
|
||||
}
|
||||
.flex { display: flex;align-items: center; }
|
||||
.nav-main {
|
||||
width: 100%;
|
||||
.nav-main-back {
|
||||
position: absolute;
|
||||
color: #eef5fd;
|
||||
height: 40px;
|
||||
width: 50px;
|
||||
}
|
||||
.nav-main-back-img {
|
||||
margin-left: 40rpx;
|
||||
height: 32rpx;
|
||||
width: 18rpx;
|
||||
}
|
||||
|
||||
.nav-main-title {
|
||||
color: #eef5fd;
|
||||
font-size: 38rpx;
|
||||
margin: auto;
|
||||
position: relative;
|
||||
letter-spacing: 0rpx;
|
||||
font-weight: 500;
|
||||
font-variation-settings: "opsz" auto;
|
||||
}
|
||||
.u-text-center {
|
||||
text-align: center;
|
||||
}
|
||||
.nav-box{
|
||||
width: 100%;
|
||||
z-index: 999;
|
||||
}
|
||||
}
|
||||
|
||||
</style>
|
||||
Reference in New Issue
Block a user