<template>
	<view class="u-f-ajc u-f-jsb wbpNavBar" :style="{backgroundColor: bgColor}">
		<view class="wbp-back-content" @click="onBack">
			<image :src="bgColor!='#ffffff'?'/static/news/back_icon20.png':'/static/common/back.png'" class="wbp-back"></image>
		</view>

		<view v-if="title.length" style="display: flex; flex-direction: row; align-items: center; justify-content: center;">
			<image style="width: 32rpx; height: 32rpx;" src="../../static/questionnaire/top_time_icon.png"></image>
			<text class="wbp-title" :style="{color:titleColor}">{{title}}</text>
		</view>
		
		<view v-if="rightTitle.length > 0" class="wbp-right-icon">
			<view v-for="(item,index) in rightTitle" :src="item" :data-index="index" @click="rightTap">
				<text>{{item}}</text>
			</view>
		</view>
		<view v-else class="wbp-right-icon">
			<view v-for="(item,index) in rightIcons" :src="item" :data-index="index" @click="rightTap">
				<image :src="item"></image>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			title: {
				type: String,
				default: ""
			},
			rightIcons: {
				type: Array,
				default: () => {
					return []
				}
			},
			rightTitle: {
				type: Array,
				default: () => {
					return []
				}
			},
			bgColor: {
				type: String,
				default: "#ffffff"
			},
			titleColor: {
				type: String,
				default: "#0A0204"
			},
			backgroundImage:{
				type: String,
				default: "#0A0204"
			},
			customBack: {
				type: Boolean,
				default: false
			}
		},
		data() {
			return {

			};
		},
		methods: {
			onBack() {
				if (!this.customBack) {
					uni.navigateBack({
						animationType: 'pop-out',
						animationDuration: 200
					});
				} else {
					this.$emit('backTap');
				}
			},
			rightTap(e) {
				this.$emit("rightTap", {
					index: e.currentTarget.dataset.index
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.wbpNavBar {
		background-color: #FFFFFF;
		width: 750rpx;
		height: 88rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;

		.wbp-back-content {
			width: 140rpx;
			height: 100%;
			display: flex;
			justify-content: flex-start;
			align-items: center;

			.wbp-back {
				width: 40rpx;
				height: 40rpx;
				margin-left: 30rpx;
			}
		}


		.wbp-title {
			margin-left: 10rpx;
			font-size: 32rpx;
			text-align: center;
			color: #0A0204;
			white-space: nowrap;
			text-overflow: ellipsis;
			overflow: hidden;
			word-break: break-all;
		}

		.wbp-right-icon {
			display: flex;
			width: 140rpx;
			flex-direction: row;
			justify-content: flex-end;
			align-items: center;
			height: 100%;

			image {
				width: 40rpx;
				height: 40rpx;
				margin-right: 30rpx;
			}

			text {
				margin-right: 30rpx;
				color: #DF0E14;
				font-size: 32rpx;
			}


		}
	}
</style>
