69 lines
1.8 KiB
Vue
69 lines
1.8 KiB
Vue
<template>
|
||
<view class="hd" :style="{ paddingTop: status + 'px' }">
|
||
<view class="bar">
|
||
<view class="left" @click="onLeft">
|
||
<text v-if="leftLabel" class="leftlab">{{ leftLabel }}</text>
|
||
<text v-else-if="back" class="back">‹</text>
|
||
<text class="title">{{ title }}</text>
|
||
</view>
|
||
<view class="right">
|
||
<slot name="right" />
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</template>
|
||
|
||
<script>
|
||
export default {
|
||
name: 'FyHeader',
|
||
props: {
|
||
title: { type: String, default: '' },
|
||
back: { type: Boolean, default: false },
|
||
leftLabel: { type: String, default: '' }
|
||
},
|
||
data() {
|
||
return { status: 20 }
|
||
},
|
||
created() {
|
||
try {
|
||
this.status = uni.getSystemInfoSync().statusBarHeight || 20
|
||
} catch (_) {}
|
||
},
|
||
methods: {
|
||
onLeft() {
|
||
if (this.leftLabel) {
|
||
this.$emit('left')
|
||
return
|
||
}
|
||
if (this.back) {
|
||
const pages = getCurrentPages()
|
||
if (pages.length > 1) uni.navigateBack()
|
||
else uni.switchTab({ url: '/pages/tabs/messages' })
|
||
}
|
||
}
|
||
}
|
||
}
|
||
</script>
|
||
|
||
<style scoped>
|
||
.hd {
|
||
background: rgba(250, 248, 255, 0.96);
|
||
border-bottom: 1rpx solid rgba(0, 0, 0, 0.04);
|
||
position: sticky;
|
||
top: 0;
|
||
z-index: 20;
|
||
}
|
||
.bar {
|
||
height: 88rpx;
|
||
padding: 0 24rpx;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
}
|
||
.left { display: flex; align-items: center; min-width: 0; }
|
||
.back { font-size: 48rpx; line-height: 1; margin-right: 8rpx; color: #131b2e; width: 48rpx; }
|
||
.leftlab { font-size: 30rpx; color: #131b2e; margin-right: 16rpx; }
|
||
.title { font-size: 36rpx; font-weight: 600; color: #131b2e; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 420rpx; }
|
||
.right { display: flex; align-items: center; gap: 8rpx; }
|
||
</style>
|