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

		<text class="wbp-title" :style="{color:titleColor}">{{title}}</text>
		<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"
			},
			customOnBack: {
				type: Boolean,
				default: false
			},
			showBack: {
				type: Boolean,
				default: true
			}
		},
		data() {
			return {

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

<style lang="scss" scoped>

	.wbpNavBar {
		/* #ifdef MP-WEIXIN */
		padding-right: 200rpx;
		width: 550rpx;
		/* #endif */
		/* #ifdef APP-PLUS */
		width: 750rpx;
		/* #endif */
		background-color: #FFFFFF;
		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 {
			font-size: 36rpx;
			width: 470rpx;
			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>
