<template>
	<view class="u-des-row" :class="{'border': border, 'click': isCilck}" @click="$emit('click')">
		<slot name="left" />
		<view class="label">
			{{label}}
		</view>
		<view class="value">
			<slot name="value" :isOpen="isOpen">
				{{value}}
			</slot>
		</view>
		<!--  -->
		<view class="right-icon" v-if="forward">
			<uni-icons type="forward" size="12" color="#9FA5BA" />
		</view>
		<view class="right-icon" v-else-if="eye" @click="isOpen=!isOpen">
			<image v-if="isOpen" src="/static/open_icon.png" style="width: 28rpx;height: 20rpx;" mode=""></image>
			<image v-else src="/static/no_open.png" style="width: 28rpx;height: 11rpx;" mode=""></image>
		</view>

	</view>
</template>

<script>
	export default {
		name: "u-des-row",
		props: {
			label: {
				type: [String, Number],
				default: ''
			},
			value: {
				type: [String, Number],
				default: ''
			},
			border: {
				type: Boolean,
				default: false
			},
			forward: { // 向右箭头
				type: Boolean,
				default: false
			},
			eye: { // 眼睛 可视？
				type: Boolean,
				default: false
			},
		},
		data() {
			return {
				isOpen: false
			}
		},
		computed: {
			isCilck() {
				return Boolean(this.$listeners['click'])
			}
		}

	}
</script>

<style lang="scss" scoped>
	.u-des-row {
		display: flex;
		justify-content: space-between;
		align-items: center;
		height: 100rpx;


		&.border {
			border-bottom: 1px solid #F5F7FA;
		}

		&.click {
			cursor: pointer;

			&:hover {
				background: #F5F7FA;
			}
		}

		.label {
			font-size: 28rpx;
			margin-right: 16rpx;
			color: #333333;
			font-weight: bold;
		}

		.value {
			flex: 1;
			text-align: right;
			font-size: 28rpx;
			font-weight: 400;
			color: #333333;

			//超过一行省略号 one-line
			overflow: hidden;
			text-overflow: ellipsis;
			white-space: nowrap;
		}

		.right-icon {
			height: 36rpx;
			width: 36rpx;
			display: flex;
			align-items: center;
			justify-content: flex-end;
			cursor: pointer;
		}
	}
</style>
