<template>
	<view>
		<view class="cu-custom" :style="[{ height: tovw(CustomBar + parseFloat(heighten)) }]">
			<slot name="head"></slot>
			<view class="cu-bar fixed" :style="style" :class="[bgImage != '' ? 'none-bg text-white bg-img' : '', bgColor]">
				<view class="action" @tap="BackPage" v-if="isBack">
					<text class="cuIcon-back"></text>
					<slot name="backText"></slot>
				</view>
				<view class="content" :style="[{ top: tovw(StatusBar) }]">
					<slot name="content"></slot>
				</view>
				<slot name="right"></slot>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			StatusBar: this.StatusBar,
			CustomBar: this.CustomBar
		};
	},
	name: 'cu-custom',
	computed: {
		style() {
			var StatusBar = this.StatusBar;
			var CustomBar = this.CustomBar;
			var bgImage = this.bgImage;
			var style = `height:${this.tovw(CustomBar + parseFloat(this.heighten))};padding-top:${this.tovw(StatusBar)};`;
			if (this.bgImage) {
				style = `${style}background-image:url(${bgImage});`;
			}
			return style
		}
	},
	props: {
		heighten: {
			type: String,
			default: "0"
		},
		bgColor: {
			type: String,
			default: ''
		},
		isBack: {
			type: [Boolean, String],
			default: false
		},
		bgImage: {
			type: String,
			default: ''
		},
	},
	methods: {
		BackPage() {
			uni.navigateBack({
				delta: 1
			});
		},
		getHeight() {
			return this.tovw(parseFloat(this.CustomBar) + parseFloat(this.heighten))
		}
	}
}
</script>

<style></style>
