head.vue 1.93 KB
Newer Older
huahua committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
<template>
	<view :style="{ height: height + 'px', background:background}" style="position: fixed; z-index: 888;">
		<view class="head" :style="{ height: height + 'px', background:background}">
			<view class="back" @click="back" v-if="backShow" :style="{ top: top + 'px', color:color }">
				<image src="../../../static/recommend/icon_back_black.png" mode="aspectFit" 
				style="width: 32upx; height: 32upx; margin-top: calc((32px - 39upx)/2);margin-left: auto; margin-right: auto;"></image>
			</view>
			<view class="title" v-if="titleShow" :style="{ top: top + 'px', color:color, 'font-size': size + 'rpx' }">{{title}}</view>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			title: {
				type: String,
				default: '自定义标题'
			},
			size:{
				type: String,
				default: '32'
			},
			color:{
				type: String,
				default: '#000'
			},
			titleShow: {
				type: Boolean,
				default: true
			},
			backShow: {
				type: Boolean,
				default: true
			},
			background:{
				type: String,
				default: "linear-gradient(to right, #43e97b 0%, #38f9d7 100%)"
			}
		},
		data() {
			return {
				height :0,
				top:0,
			}
		},
		mounted() {
			
		},
		created() {
			//设备信息
			let app = uni.getSystemInfoSync();
			//胶囊信息
			let menuButtonInfo = uni.getMenuButtonBoundingClientRect();
			this.height  = app.statusBarHeight + menuButtonInfo.height + (menuButtonInfo.top - app.statusBarHeight)*2
			this.top = menuButtonInfo.top;
		},
		methods: {
			back(){
				uni.navigateBack();
			}
		},
		onLoad(options) {
			
		},
		onShow() {
			
		}
	}
</script>

<style>
.head{
	position: fixed;
	width: 750rpx;
	z-index: 888;
	align-items: center;
}
.title{
	position: fixed;
	width: 750rpx;
	text-align: center;
	line-height: 32px;
	height: 32px;
}
.back{
	position: fixed;
	width: 81rpx;
	text-align: center;
	line-height: 32px;
	height: 32px;
	font-size: 32rpx;
	font-weight: 900;
	z-index: 9;
	align-items: center;
}
</style>