<template name="address">
	<view class="address-template">
		 <!-- 地址 -->
		 <navigator :url="addressSrc" class="address-section">
			<view class="address-empty" v-if="isEmpty">
			 	<text>添加收货地址</text><text class="iconfont icon-tianjiadizhi"></text>
			</view>
		 	<view class="address-content" v-else>
		 		<view class="address-cen">
		 			<view class="top">
		 				<view class="name">{{addressData.receiver !== undefined ? addressData.receiver : ''}}</view>
		 				<view class="mobile">{{addressData.mobile !== undefined ? addressData.mobile : ''}}</view>
		 			</view>
		 			<view class="address">
						<view class="address-icon">
							<text class="iconfont icon-shouhuodizhi"></text>
						</view>
						<view class="address-text">
							{{addressData.province !== undefined ? addressData.province : ''}}
							{{addressData.city !== undefined ? addressData.city : ''}}
							{{addressData.town !== undefined ? addressData.town : ''}}
							{{addressData.address !== undefined ? addressData.address : ''}}
						</view>
					</view>
					<view class="nexpage"><text class="iconfont icon-genghuan"></text></view>
		 		</view>
		 	</view>
		 </navigator>
		 <image  src="../../../static/temp/line@3x.png" mode=""></image>
	</view>
</template>

<script>
	export default{
		name:"address",
		props:{
			addressData:{
				type:Object
			}
		},
		data() {
			return{
				isEmpty:false,
				addressSrc:'',
			}
		},
		created(){
			this.initData(this.addressData)
		},
		computed: {

		},
		watch:{
			addressData:{
				handler:function(val){
					this.initData(val)
				}
			}
		},
		methods:{
			initData(res) {
				if(Object.keys(res).length == 0){
					this.isEmpty = true
					this.addressSrc = '/pages/user/address/addressManage'
				}else{
					this.isEmpty = false
					this.$parent.isFreight = false
					this.addressSrc = '/pages/user/address/address?type=select'
				}
			}
		}
	}
</script>

<style lang="scss">
	.address-template{
		width: 100%;
		height: auto;
		background: #FFFFFF;
		border-top: 1px solid #F8F8F8;
		image{
			float: left;
			width: 100%;
			height: 16rpx;
		}
	}
	.address-section {
		width: 100%;
		height: auto;
		float: left;
		position: relative;
		
		.address-empty{
			width: 100%;
			height: 100rpx;
			line-height: 100rpx;
			color: $color-system;
			text-align: center;
			font-size: $font-size-26;
			font-weight: bold;
			background: #fff;
			float: left;
			.icon-tianjiadizhi{
				font-size: 30rpx;
				margin: 0 8rpx;
			}
		}
		.address-content {
			display: flex;
			align-items: center;
			padding:20rpx 24rpx;
			background: #fff;
		}
		
		.icon-shouhuodizhi {
			flex-shrink: 0;
			display: flex;
			align-items: center;
			justify-content: center;
			width: 40rpx;
			color: $color-system;
			font-size: 46rpx;
			margin-right: 10rpx;
		}	
		.address-cen {
			width: 100%;
			height: auto;
			position: relative;
			.top{
				padding-left: 50rpx;
				height: 42rpx;
				line-height: 42rpx;
				text-align: left;
				font-size: $font-size-30;
				color: $text-color;
				padding-bottom: 8rpx;
				display: flex;
				float: left;
				.name{
					font-weight: bold;
					margin-right: 48rpx;
				}
				.mobile{
					margin-right: 40rpx;
					font-weight: bold;
				}
			}
			.address {
				width: 100%;
				height: auto;
				float: left;
				.address-icon{
					width: 40rpx;
					height: auto;
					float: left;
					line-height: 40rpx;
				}
				.address-text{
					width: 610rpx;
					padding-left: 10rpx;
					float: left;
					line-height: 40rpx;
					font-size: $font-size-28;
					color: $text-color;
					text-align: left;
					-o-text-overflow: ellipsis;
					text-overflow: ellipsis;
					display: -webkit-box;
					word-break: break-all;
					-webkit-box-orient: vertical;
					-webkit-line-clamp: 2;
					overflow: hidden;
				}
			}
			.nexpage{
				text-align: right;
				font-size: $font-size-30;
				color: $color-system;
				position: absolute;
				right: 0;
				top: 45rpx;
				.icon-genghuan{
					font-size: $font-size-30;
				}
			}
		}
		.icon-xiangyou {
			font-size: 32rpx;
			color: $text-color;
			margin-right: 30rpx;
		}
		.a-bg {
			position: absolute;
			left: 0;
			bottom: 0;
			display: block;
			width: 100%;
			height: 5rpx;
		}
	}
</style>
