<template>
	<view class="addr-bar" @click="emit('click')">
		<u-icon name="map" color="#2e7d32" size="22" />
		<view v-if="address" class="addr-bar__body">
			<view class="addr-bar__head">
				<text class="addr-bar__name">{{ address.consigneeName }}</text>
				<text class="addr-bar__mobile">{{ address.mobile }}</text>
				<text v-if="address.isDefault" class="addr-bar__tag">默认</text>
			</view>
			<text class="addr-bar__detail">{{ address.fullAddress }}</text>
		</view>
		<view v-else class="addr-bar__empty">
			<text>请添加收货地址</text>
		</view>
		<u-icon name="arrow-right" color="#ccc" size="16" />
	</view>
</template>

<script setup>
defineProps({
	address: {
		type: Object,
		default: null
	}
})
const emit = defineEmits(['click'])
</script>

<style lang="scss" scoped>
.addr-bar {
	display: flex;
	align-items: center;
	padding: 24rpx;
	margin: 16rpx 24rpx;
	background: #fff;
	border-radius: 12rpx;
}
.addr-bar__body {
	flex: 1;
	margin: 0 16rpx;
	min-width: 0;
}
.addr-bar__head {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 12rpx;
}
.addr-bar__name {
	font-size: 30rpx;
	font-weight: 600;
	color: #333;
}
.addr-bar__mobile {
	font-size: 28rpx;
	color: #666;
}
.addr-bar__tag {
	font-size: 22rpx;
	color: #2e7d32;
	background: #e8f5e9;
	padding: 4rpx 10rpx;
	border-radius: 6rpx;
}
.addr-bar__detail {
	display: block;
	margin-top: 8rpx;
	font-size: 26rpx;
	color: #666;
	line-height: 1.5;
}
.addr-bar__empty {
	flex: 1;
	margin: 0 16rpx;
	font-size: 28rpx;
	color: #999;
}
</style>
