|
|
|
@ -1,18 +1,23 @@
|
|
|
|
<template>
|
|
|
|
<template>
|
|
|
|
<view class="custom-navbar" :style="navbarStyle">
|
|
|
|
<view>
|
|
|
|
<view class="navbar-status-bar" :style="{ height: statusBarHeight + 'px' }"></view>
|
|
|
|
<up-navbar
|
|
|
|
<view class="navbar-body" :style="{ height: navBodyHeight + 'px' }">
|
|
|
|
:title="translatedTitle"
|
|
|
|
<view class="navbar-left">
|
|
|
|
:bgColor="navbarBgColor"
|
|
|
|
<view v-if="showBackBtn" class="back-btn" @click="handleBack">
|
|
|
|
:titleStyle="titleStyleObj"
|
|
|
|
<uni-icons type="arrow-left" :size="20" :color="textColor"></uni-icons>
|
|
|
|
:leftIcon="showBackBtn ? 'arrow-left' : ''"
|
|
|
|
</view>
|
|
|
|
:leftIconColor="navTextColor"
|
|
|
|
</view>
|
|
|
|
:leftIconSize="20"
|
|
|
|
<view class="navbar-center">
|
|
|
|
:autoBack="false"
|
|
|
|
<text class="navbar-title" :style="{ color: textColor }">{{ translatedTitle }}</text>
|
|
|
|
:placeholder="true"
|
|
|
|
</view>
|
|
|
|
:safeAreaInsetTop="true"
|
|
|
|
<view class="navbar-right">
|
|
|
|
@leftClick="handleBack"
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
<template #right>
|
|
|
|
<slot name="right"></slot>
|
|
|
|
<slot name="right"></slot>
|
|
|
|
</view>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
</up-navbar>
|
|
|
|
|
|
|
|
<view v-if="subTitle" class="navbar-subtitle-wrap">
|
|
|
|
|
|
|
|
<text class="navbar-subtitle">{{ translatedSubTitle }}</text>
|
|
|
|
</view>
|
|
|
|
</view>
|
|
|
|
</view>
|
|
|
|
</view>
|
|
|
|
</template>
|
|
|
|
</template>
|
|
|
|
@ -30,6 +35,10 @@ const props = defineProps({
|
|
|
|
type: String,
|
|
|
|
type: String,
|
|
|
|
default: ''
|
|
|
|
default: ''
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
subTitle: {
|
|
|
|
|
|
|
|
type: String,
|
|
|
|
|
|
|
|
default: ''
|
|
|
|
|
|
|
|
},
|
|
|
|
backgroundColor: {
|
|
|
|
backgroundColor: {
|
|
|
|
type: String,
|
|
|
|
type: String,
|
|
|
|
default: '#22486e'
|
|
|
|
default: '#22486e'
|
|
|
|
@ -44,17 +53,8 @@ const props = defineProps({
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
const systemInfo = uni.getSystemInfoSync()
|
|
|
|
|
|
|
|
const statusBarHeight = ref(systemInfo.statusBarHeight || 0)
|
|
|
|
|
|
|
|
const currentPagesLength = ref(1)
|
|
|
|
const currentPagesLength = ref(1)
|
|
|
|
|
|
|
|
|
|
|
|
const navBodyHeight = computed(() => {
|
|
|
|
|
|
|
|
const platform = systemInfo.platform || ''
|
|
|
|
|
|
|
|
if (platform === 'android') return 48
|
|
|
|
|
|
|
|
if (platform === 'ios') return 44
|
|
|
|
|
|
|
|
return 44
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const isLoginPage = computed(() => {
|
|
|
|
const isLoginPage = computed(() => {
|
|
|
|
const pages = getCurrentPages()
|
|
|
|
const pages = getCurrentPages()
|
|
|
|
if (pages && pages.length > 0) {
|
|
|
|
if (pages && pages.length > 0) {
|
|
|
|
@ -68,19 +68,24 @@ const showBackBtn = computed(() => {
|
|
|
|
return currentPagesLength.value > 1
|
|
|
|
return currentPagesLength.value > 1
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
const navbarStyle = computed(() => {
|
|
|
|
const navbarBgColor = computed(() => {
|
|
|
|
const bg = isLoginPage.value ? '#ffffff' : props.backgroundColor
|
|
|
|
return isLoginPage.value ? '#ffffff' : props.backgroundColor
|
|
|
|
return {
|
|
|
|
})
|
|
|
|
backgroundColor: bg,
|
|
|
|
|
|
|
|
paddingTop: '0px'
|
|
|
|
const navTextColor = computed(() => {
|
|
|
|
}
|
|
|
|
return isLoginPage.value ? '#000000' : props.textColor
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
const translatedTitle = computed(() => translateLiteral(props.title))
|
|
|
|
const translatedTitle = computed(() => translateLiteral(props.title))
|
|
|
|
|
|
|
|
|
|
|
|
const textColor = computed(() => {
|
|
|
|
const translatedSubTitle = computed(() => translateLiteral(props.subTitle))
|
|
|
|
if (isLoginPage.value) return '#000000'
|
|
|
|
|
|
|
|
return props.textColor
|
|
|
|
const titleStyleObj = computed(() => {
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
|
|
color: navTextColor.value,
|
|
|
|
|
|
|
|
fontWeight: '700',
|
|
|
|
|
|
|
|
fontSize: '34rpx'
|
|
|
|
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
onShow(() => {
|
|
|
|
onShow(() => {
|
|
|
|
@ -89,6 +94,7 @@ onShow(() => {
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
function handleBack() {
|
|
|
|
function handleBack() {
|
|
|
|
|
|
|
|
if (!showBackBtn.value) return
|
|
|
|
uni.navigateBack({
|
|
|
|
uni.navigateBack({
|
|
|
|
fail: () => {
|
|
|
|
fail: () => {
|
|
|
|
uni.reLaunch({
|
|
|
|
uni.reLaunch({
|
|
|
|
@ -100,62 +106,14 @@ function handleBack() {
|
|
|
|
</script>
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.custom-navbar {
|
|
|
|
.navbar-subtitle-wrap {
|
|
|
|
position: relative;
|
|
|
|
padding: 14rpx 24rpx 20rpx;
|
|
|
|
width: 100%;
|
|
|
|
background: #ffffff;
|
|
|
|
z-index: 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.navbar-body {
|
|
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
|
|
|
padding: 0 16rpx;
|
|
|
|
|
|
|
|
position: relative;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.navbar-left,
|
|
|
|
|
|
|
|
.navbar-right {
|
|
|
|
|
|
|
|
width: 120rpx;
|
|
|
|
|
|
|
|
flex-shrink: 0;
|
|
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.navbar-left {
|
|
|
|
|
|
|
|
justify-content: flex-start;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.back-btn {
|
|
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
|
|
padding: 8rpx 12rpx;
|
|
|
|
|
|
|
|
border-radius: 8rpx;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.back-text {
|
|
|
|
.navbar-subtitle {
|
|
|
|
font-size: 28rpx;
|
|
|
|
|
|
|
|
line-height: 1;
|
|
|
|
|
|
|
|
margin-left: 4rpx;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.navbar-center {
|
|
|
|
|
|
|
|
position: absolute;
|
|
|
|
|
|
|
|
left: 50%;
|
|
|
|
|
|
|
|
transform: translateX(-50%);
|
|
|
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
|
|
max-width: calc(100% - 240rpx);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.navbar-title {
|
|
|
|
|
|
|
|
font-size: 34rpx;
|
|
|
|
font-size: 34rpx;
|
|
|
|
font-weight: 700;
|
|
|
|
font-weight: 700;
|
|
|
|
white-space: nowrap;
|
|
|
|
color: #1a3a5c;
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.navbar-right {
|
|
|
|
|
|
|
|
justify-content: flex-end;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
</style>
|