<template>
	<view>

		<!-- #ifdef MP-WEIXIN -->
		<view v-if="type=='index'" :style="{height: `${statusBarHeight + 20}px`}"></view>
		<!-- #endif -->

		<!-- #ifdef APP -->
		<view v-if="type=='index'" :style="{height: `${statusBarHeight}px`}"></view>
		<!-- #endif -->
		<view>
			<view class="top-view flex-row" :style="'padding-top:'+statusBarHeight+'px;background:'+bgColor+';'">
				<view class="navHei" :style="{'height':`calc(${navabarHeight}rpx)`,'width':'100%',}">
					<view  :class="[type=='carDetail'?'car-detail-style':'','left']" @tap="bindReturnView">
						<img v-if="type!='active'" class="return-view"
							:src="'https://qiniu.bms16.com/'+((type=='select'||type=='login')?'FjhcWGFGsI56rLZRu7_OnhGtpoUs':(type=='carDetail'?'Fjpnr3cH9ZqTQrGlw3Ywp3qbJGIG':'FnHXbzly7aXi8zLghrTU5BZdwH5_'))" />
					</view>
					<text class="top-text">{{name}}</text>
				</view>
			</view>
			<view :class="(bgColor!='#FFF'||type==('active'||'noBottom'))?'':'view-height'"
				:style="{'height':`calc(${statusBarHeight}px + ${navabarHeight}rpx)`}"></view>
		</view>

	</view>
</template>

<script>
	export default {
		props: {
			name: {
				type: String,
				default: ''
			},
			type: {
				type: String,
				default: 'my'
			},
			bgColor: {
				type: String,
				default: 'rgba(255,255,255)'
			},
			left: {
				type: String,
				default: '32'
			}
		},
		data() {
			return {
				statusBarHeight: 0,
				navabarHeight: 0,
			}
		},
		mounted() {
			this._getCustomBar()
		},
		methods: {
			_getCustomBar() {
				const sysinfo = uni.getSystemInfoSync()
				// let GAP = 8
				// // #ifdef MP-ALIPAY
				// GAP = 0
				// // #endif
				// // #ifdef APP-PLUS

				// // #endif
				// // #ifdef MP-WEIXIN
				// const clientRect = uni.getMenuButtonBoundingClientRect()
				// const navabarHeight = (clientRect.bottom - sysinfo.statusBarHeight) + (clientRect.top - sysinfo.statusBarHeight) + GAP
				// this.navabarHeight = navabarHeight
				// // #endif

				this.statusBarHeight = sysinfo.statusBarHeight
				this.navabarHeight = 100
			},

			bindReturnView() {
				uni.navigateBack({
					delta: 1,
				}) // 返回上一页
			},
		}
	}
</script>

<style scoped>
	.navHei{
		display: flex;
		align-items: center;
		justify-content: center;
		position: relative;
	}
	.left{
		width: 40rpx;
		height: 40rpx;
		position: absolute;
		left: 0;
	}
	.top-view {
		background: #ffffff;
		width: 100%;
		position: fixed;
		z-index: 10;
		left: 0;
		top: 0;
		align-items: center;
		padding: 0 26rpx;
		text-align: center;
	}

	.return-view {
		width: 40rpx;
		height: 40rpx;
		/* margin-top: 24rpx; */
		/* 		margin-left: 32rpx; */
	}

	.top-text {
		color: #060809;
		font-size: 36rpx;
		font-weight: 600;
		line-height: 36rpx;
		text-align: center;
		font-style: normal;
		font-family: PingFangSC, PingFang SC;
	}

	.view-height {
		/* border-bottom:2rpx solid #060809 ; */
		/* margin-bottom: 32rpx; */
	}

	.car-detail-style {
		width: 56rpx;
		height: 56rpx;
		background: rgba(0, 0, 0, 0.4);
		border-radius: 16rpx 0rpx 16rpx 0rpx;
		padding-left: 6rpx;
	}
</style>