117 lines
2.3 KiB
Vue
117 lines
2.3 KiB
Vue
<template>
|
|
<view class="apv-head" :style="headPad">
|
|
<view class="apv-head-left">
|
|
<view class="apv-back" hover-class="apv-back-active" @tap="onBack">
|
|
<FaIcon name="chevron-left" color="#1f2b48" :size="20" />
|
|
</view>
|
|
<text v-if="backText" class="apv-back-text">{{ backText }}</text>
|
|
</view>
|
|
|
|
<view class="apv-head-center">
|
|
<text class="apv-title">{{ title }}</text>
|
|
</view>
|
|
|
|
<view class="apv-head-right">
|
|
<slot name="right" />
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script setup>
|
|
import { computed } from 'vue'
|
|
import { mpHeadPad } from '@/utils/mpHead.js'
|
|
|
|
const props = defineProps({
|
|
title: { type: String, required: true },
|
|
backText: { type: String, default: '' },
|
|
beforeBack: { type: Function, default: null }
|
|
})
|
|
|
|
const emit = defineEmits(['back'])
|
|
|
|
function onBack() {
|
|
if (typeof props.beforeBack === 'function' && props.beforeBack() === false) return
|
|
emit('back')
|
|
const pages = getCurrentPages()
|
|
if (pages.length > 1) {
|
|
uni.navigateBack({ delta: 1 })
|
|
} else {
|
|
uni.reLaunch({ url: '/pages/nav/nav' })
|
|
}
|
|
}
|
|
|
|
const headPad = computed(() => mpHeadPad(8))
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
@import '@/src/styles/page-common.scss';
|
|
|
|
.apv-head {
|
|
flex-shrink: 0;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
height: 88rpx;
|
|
padding: 0 $page-padding-x;
|
|
background: $color-card;
|
|
box-shadow: $shadow-header;
|
|
position: relative;
|
|
z-index: 10;
|
|
/* #ifdef MP-WEIXIN */
|
|
padding-top: 0; /* mpHeadPad 已注入 paddingTop;这里不再叠加 */
|
|
/* #endif */
|
|
}
|
|
|
|
.apv-head-left,
|
|
.apv-head-right {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8rpx;
|
|
min-width: 120rpx;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.apv-head-right {
|
|
justify-content: flex-end;
|
|
}
|
|
|
|
.apv-head-center {
|
|
flex: 1;
|
|
min-width: 0;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
padding: 0 16rpx;
|
|
}
|
|
|
|
.apv-back {
|
|
width: 56rpx;
|
|
height: 56rpx;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
border-radius: $radius-full;
|
|
transition: background 0.2s;
|
|
}
|
|
|
|
.apv-back-active {
|
|
background: $color-bg-page;
|
|
}
|
|
|
|
.apv-back-text {
|
|
font-size: 26rpx;
|
|
color: $color-text-secondary;
|
|
white-space: nowrap;
|
|
}
|
|
|
|
.apv-title {
|
|
max-width: 100%;
|
|
font-size: 32rpx;
|
|
font-weight: 600;
|
|
color: $color-text;
|
|
white-space: nowrap;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
}
|
|
</style>
|