<template>
	<view class="m-title-box">
		<text class="m-title" :style="getTitleStyle">{{title}}</text>
		<view class="m-title-end-box" @click="commit">
			<text class="m-subTitle" :style="getSubTitleStyle">{{subTitle}}</text>
			<image v-show="showRow" class="m-title-row" src="/static/ic_login_right_row.svg" mode="widthFix">
			</image>
		</view>
	</view>
</template>

<script>
	export default {
		// 通用title
		name: "m-title",
		props: {
			color: {
				type: String,
				default: "#333333"
			},
			fontWeight: {
				type: String,
				default: "500"
			},
			height: {
				type: String,
				default: "auto"
			},
			titleSize: {
				type: String,
				default: "28rpx"
			},
			subTitleSize: {
				type: String,
				default: "28rpx"
			},
			title: {
				type: String,
				default: ""
			},
			subTitle: {
				type: String,
				default: ""
			},
			showRow: {
				type: Boolean,
				default: true
			},
		},
		computed: {
			getTitleStyle() {
				return "height:" + this.height + ";color:" + this.color + ";font-weight:" + this.fontWeight +
					";font-size:" + this.titleSize + ";"
			},
			getSubTitleStyle() {
				return "font-size:" + this.subTitleSize + ";"
			},
		},
		data() {
			return {

			};
		},
		methods: {
			commit(index) {
				this.$emit("click", index)
			}
		}
	}
</script>

<style lang="scss" scoped>
	.m-title-box {
		width: 100%;
		height: 100%;
		display: flex;
		flex-direction: row;
		align-items: center;
	}

	.m-title {
		font-family: 'PingFang SC';
		font-style: normal;
		line-height: 20px;
		display: flex;
		align-items: center;
		text-align: center;
		letter-spacing: 0.02em;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
	}

	.m-title-end-box {
		flex: 1;
		height: 100%;
		display: flex;
		align-items: center;
		flex-direction: row;
		justify-content: flex-end;
	}

	.m-subTitle {
		font-family: 'PingFang SC';
		font-style: normal;
		font-weight: 400;
		text-align: right;
		letter-spacing: 0.02em;
		color: #999999;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
	}

	.m-title-row {
		width: 32rpx;
		height: 32rpx;
	}
</style>
