customNav.vue 1.82 KB
<template>
    <view class="custom-nav" :style="{ height: statusBarHeight + 'px' }">
        <view :style="{ height: statusBarHeight + 'px' }"></view>
        <view class="nav-content">
            <view class="nav-left" @click="onBack">
                <uni-icons type="left" size="24" color="#333" />
            </view>
            <view class="nav-title">收车偏好设置</view>
        </view>
    </view>
</template>
<script lang="ts">
import { Vue, Component, Prop } from 'vue-facing-decorator';

@Component({})
export default class customNav extends Vue {
    // 状态栏高度(微信小程序中由系统提供)
    @Prop({ type: Number, required: false, default: 48 })
    statusBarHeight: number;
    onBack() {
        uni.showModal({
            title: '提示',
            content: '偏好未完成填写,稍后可在「我的-收车偏好」中继续填写',
            success: (res) => {
                if (res.confirm) {
                    uni.navigateBack();
                } else if (res.cancel) {
                    console.log('用户点击取消');
                }
            }
        })
    }
}
</script>

<style scoped lang="scss">
.custom-nav {
    width: 100%;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 999; // 确保在页面内容上方
}

.nav-content {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    height: 44px;
}

.nav-left {
    position: absolute;
    left: 2px;
    width: 80rpx;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.back-icon {
    font-size: 36rpx;
    color: #333;
}

.nav-title {
    font-size: 32rpx;
    color: #333;
    font-weight: 400;
}

.nav-right {
    position: absolute;
    right: 16rpx;
    height: 100%;
    display: flex;
    align-items: center;
}
</style>