156 lines
3.1 KiB
Vue
156 lines
3.1 KiB
Vue
<template>
|
||
<view class="credit-header" :class="{ 'is-curved': curved }">
|
||
<view :style="{ height: statusBarHeight + 'px' }"></view>
|
||
<view class="nav-bar">
|
||
<view v-if="showBack && canBack" class="back-btn" @tap="handleBack">
|
||
<view class="back-arrow"></view>
|
||
</view>
|
||
</view>
|
||
<view v-if="showBadge" class="zm-badge">
|
||
<view class="zm-logo"><text class="zm-logo-text">芝</text></view>
|
||
<text class="zm-text">芝麻信用</text>
|
||
</view>
|
||
<view class="hero-title">
|
||
<text class="hero-slash">///</text>
|
||
<text class="hero-text">{{ title }}</text>
|
||
<text class="hero-slash">///</text>
|
||
</view>
|
||
<slot></slot>
|
||
</view>
|
||
</template>
|
||
|
||
<script setup>
|
||
import { ref, onMounted } from 'vue'
|
||
|
||
defineProps({
|
||
title: {
|
||
type: String,
|
||
default: ''
|
||
},
|
||
// 是否显示「芝麻信用」标识(押金页不显示)
|
||
showBadge: {
|
||
type: Boolean,
|
||
default: false
|
||
},
|
||
showBack: {
|
||
type: Boolean,
|
||
default: true
|
||
},
|
||
// 底部是否做成弧形(下单页)
|
||
curved: {
|
||
type: Boolean,
|
||
default: false
|
||
}
|
||
})
|
||
|
||
const statusBarHeight = ref(0)
|
||
const canBack = ref(false)
|
||
|
||
onMounted(() => {
|
||
statusBarHeight.value = uni.getSystemInfoSync().statusBarHeight || 0
|
||
|
||
// 支付宝端用透明原生导航栏自带的返回按钮(pages.json 里 navigationBarTextStyle 已设为白色),
|
||
// 这里不再画第二个箭头;其他端没有原生导航栏,自己画。
|
||
// #ifdef MP-ALIPAY
|
||
canBack.value = false
|
||
// #endif
|
||
// #ifndef MP-ALIPAY
|
||
canBack.value = getCurrentPages().length > 1
|
||
// #endif
|
||
})
|
||
|
||
function handleBack() {
|
||
if (getCurrentPages().length > 1) {
|
||
uni.navigateBack()
|
||
}
|
||
}
|
||
</script>
|
||
|
||
<style>
|
||
.credit-header {
|
||
position: relative;
|
||
padding-bottom: 72rpx;
|
||
background: linear-gradient(180deg, #4a90ff 0%, #1e6bff 100%);
|
||
color: #ffffff;
|
||
}
|
||
|
||
/* 下单页:底部弧形,并给悬浮的品牌卡片留出上半部分高度 */
|
||
.credit-header.is-curved {
|
||
padding-bottom: 140rpx;
|
||
border-radius: 0 0 50% 50% / 0 0 96rpx 96rpx;
|
||
}
|
||
|
||
.nav-bar {
|
||
display: flex;
|
||
align-items: center;
|
||
height: 88rpx;
|
||
padding: 0 24rpx;
|
||
}
|
||
|
||
.back-btn {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
width: 72rpx;
|
||
height: 72rpx;
|
||
}
|
||
|
||
.back-arrow {
|
||
width: 22rpx;
|
||
height: 22rpx;
|
||
margin-left: 8rpx;
|
||
border-left: 4rpx solid #ffffff;
|
||
border-bottom: 4rpx solid #ffffff;
|
||
transform: rotate(45deg);
|
||
}
|
||
|
||
.zm-badge {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
margin-top: 8rpx;
|
||
}
|
||
|
||
.zm-logo {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
width: 40rpx;
|
||
height: 40rpx;
|
||
border-radius: 50%;
|
||
background: #ffffff;
|
||
}
|
||
|
||
.zm-logo-text {
|
||
font-size: 22rpx;
|
||
font-weight: 600;
|
||
color: #1e6bff;
|
||
}
|
||
|
||
.zm-text {
|
||
margin-left: 12rpx;
|
||
font-size: 26rpx;
|
||
color: rgba(255, 255, 255, 0.95);
|
||
}
|
||
|
||
.hero-title {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
margin-top: 20rpx;
|
||
}
|
||
|
||
.hero-text {
|
||
font-size: 40rpx;
|
||
font-weight: 600;
|
||
letter-spacing: 4rpx;
|
||
}
|
||
|
||
.hero-slash {
|
||
margin: 0 20rpx;
|
||
font-size: 32rpx;
|
||
font-style: italic;
|
||
color: rgba(255, 255, 255, 0.55);
|
||
}
|
||
</style>
|