12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- <template>
- <up-navbar :title="title" :bgColor="bgColor" :titleStyle="titleStyle">
- <template #left>
- <view class="u-nav-slot" slot="left" style="display: flex;background-color: transparent;">
- <image v-if="showback" src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/19/27b15a2d-2974-4f2e-a06e-8d13c0519113.png" style="width: 40rpx;height: 40rpx;" @tap="toBack(backUrl)"></image>
- </view>
- </template>
- </up-navbar>
- </template>
- <script setup lang="ts">
- import { ref } from 'vue'
- // 定义组件属性
- const props = defineProps({
- title: {
- type: String,
- default: ''
- },
- showback: {
- type: Boolean,
- default: true
- },
- backUrl: {
- type: String,
- default: ''
- },
- bgColor: {
- type: String,
- default: '#ffffff'
- },
- leftIconColor: {
- type: String,
- default: '#111111'
- },
- titleStyle: {
- type: Object,
- default: () => ({
- fontSize: '36rpx',
- fontWeight: 'bold',
- color: '#111111'
- })
- },
- backAlert: {
- type: Boolean,
- default: false
- }
- })
- // 定义组件状态
- const tabUrls = ref([
- '/pages/home',
- '/pages/nonprofit',
- '/pages/my'
- ])
- // 导出方法供模板使用
- const toBack = (url: string) => {
- if (props.backAlert) {
-
- } else {
- dealBack(url)
- }
- }
- const dealBack = (url: string) => {
- if (!url) {
- if (uni.getStorageSync('options')) {
- const options = JSON.parse(decodeURIComponent(uni.getStorageSync('options')))
- uni.redirectTo(options)
- uni.removeStorageSync('options')
- return
- }
- const pages = getCurrentPages()
- if (pages && pages.length > 1) {
- uni.navigateBack()
- } else {
- uni.reLaunch({ url: '/pages/home' })
- }
- } else {
- if (tabUrls.value.find(u => u === url)) {
- uni.reLaunch({ url })
- } else {
- uni.redirectTo({ url })
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .u-navbar--fixed {
- z-index: 99999 !important;
- }
- </style>
|