intelligentGroup/components/navigation-bar.vue

98 lines
1.9 KiB
Vue

<template>
<view class="navigation-bar" :style="{'paddingTop':statusBarHeight+'px'}">
<view class="navigation-bar-left" @click="navigateBack">
<!-- <view class="navigation-bar-icon navigation-bar-home" v-if="prevPage">
<uni-icons type="home" size="18" color="#fff"></uni-icons>
</view> -->
<view class="navigation-bar-icon">
<uni-icons type="back" size="24" color="#fff"></uni-icons>
</view>
</view>
<view class="navigation-title">详情</view>
</view>
</template>
<script>
export default {
data() {
return {
statusBarHeight: 0,
prevPage: true
}
},
mounted() {
uni.getSystemInfo({
success: (res) => {
this.statusBarHeight = res.statusBarHeight;
}
});
let pages = getCurrentPages()
let prevPage = pages[pages.length - 2]
if (prevPage && prevPage.route != 'pages/index/index') {
this.prevPage = false
}
console.log("prevPage",prevPage, this.prevPage)
console.log("statusBarHeight", this.statusBarHeight)
},
methods: {
navigateBack() {
if (!this.prevPage) {
uni.navigateBack({
delta: 1
})
} else {
uni.switchTab({
url: "/pages/index/index"
});
}
}
}
};
</script>
<style scoped>
.navigation-bar {
display: flex;
align-items: center;
height: 44px;
position: fixed;
width: 100%;
top: 0;
z-index: 999;
background-color: #345A9B;
}
.navigation-bar-left {
display: flex;
align-items: center;
margin-left: 3px;
font-size: 14px;
color: #fff;
position: absolute;
width: 40%;
z-index: 99;
}
.navigation-bar-home {
background-color: #ccc;
width: 28px;
height: 28px;
border-radius: 50%;
text-align: center;
line-height: 28px;
}
.navigation-bar {
width: 100%;
margin-right: 0px;
}
.navigation-title {
color: #fff;
margin: auto;
position: absolute;
width: 100%;
text-align: center;
}
</style>