<template>
	<u-navbar class="nav" :title="title" :leftIconSize="36" :bgColor="bgColor" leftIconColor="#fff"
		:titleStyle="titleStyle">
		<view class="u-nav-slot" slot="left">
			<u-icon name="arrow-left" size="44" color='#fff' @tap="toBack(backUrl)"></u-icon>
		<!-- 	<u-line v-if="showHome" direction="column" color='#fff' :hairline="false" length="0"
				margin="0 15rpx"></u-line>
			<u-icon v-if="showHome" name="home" color='#fff' size="48" @tap="toHome"></u-icon> -->
		</view>
	</u-navbar>
</template>

<script>
	export default {
		options: {
			styleIsolation: 'shared'
		},
		props: {
			title: {
				typeof: String,
				default: ''
			},
			showHome: {
				typeof: Boolean,
				default: true
			},
			backUrl: {
				typeof: String,
				default: ''
			},
			bgColor: {
				typeof: String,
				default: '#007A69'
			}
		},
		data() {
			return {
				titleStyle: {
					fontSize: '36rpx',
					fontWeight: "bold",
					color: "#fff"
				},
				tabUrls: [
					'/pages/index/index',
					'/pages/touristMap/index',
					'/pages/oneCodePass/index',
					'/pages/service/index',
					'/pages/my/index'
				]
			}
		},
		methods: {
			toBack(url) {
				console.log(url, 'url');
				if (!url) {
					let canNavBack = getCurrentPages();
					if (canNavBack && canNavBack.length > 1) uni.navigateBack();
					else uni.redirectTo({
						url
					});
				} else {
					if (this.tabUrls.find(u => u == url)) uni.reLaunch({
						url
					});
					else uni.redirectTo({
						url
					});
				}
			},
			toHome() {
				uni.reLaunch({
					url: '/pages/index/index'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	::v-deep .u-nav-slot {
		display: flex;
		padding: 8rpx 16rpx 8rpx 0;
		width: 150rpx;
		// background-color: rgba(0, 0, 0, 0.2);
		border-radius: 30rpx;
		color: #fff;
	}


	.nav {
		color: #fff;
		background-color: transparent;
	}

	.u-navbar__content {
		color: #fff !important;
		background-color: transparent !important;
	}

	.u-status-bar {
		color: #fff !important;
		background-color: transparent !important;
	}

	.u-navbar__content__title {
		color: #fff !important;
	}
</style>