<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 v-else>
			<view  class="top-view flex-row" :style="'padding-top:'+statusBarHeight+'rpx;background-color:'+bgColor+';'">
			<view class="flex-row" :style="'height:'+navabarHeight+'rpx;'">
				<view :class="['flex-row',type=='carDetail'?'car-detail-style':'']" :style="{'margin-left': `${left}rpx`}"  @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:'+( navabarHeight + statusBarHeight )+'rpx;'"></view>
		</view>
		
	</view>
</template>

<script>
	export default {
		props: {
			name: {
				type: String,
				default:''
			},
			type:{
				type:String,
				default:'my'
			},
			bgColor:{
				type:String,
				default:'#FFF'
			},
			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
				this.statusBarHeight = sysinfo.statusBarHeight
				this.navabarHeight = 100
				// #endif
				// #ifdef MP-WEIXIN
				const clientRect = uni.getMenuButtonBoundingClientRect()
				const navabarHeight = (clientRect.bottom - sysinfo.statusBarHeight) + (clientRect.top - sysinfo.statusBarHeight) + GAP
				this.navabarHeight = navabarHeight
				// #endif
			},
			
			bindReturnView() {
				uni.navigateBack({
					delta: 1,
				}) // 返回上一页
			},
		}
	}
</script>

<style scoped>
	.top-view {
		background: #ffffff;
		width: 100%;
		/* height: 170rpx; */
		position: fixed;
		z-index: 10;
		align-items: baseline;
	}
	
	.return-view {
		width: 40rpx;
		height: 40rpx;
		/* margin-top: 24rpx; */
/* 		margin-left: 32rpx; */
	}
	
	.top-text {
		color: #060809;
		margin-left: 230rpx;
		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>