<template>
	<view class="addressList">
		<view class="item" v-for="(item,index) in addressList" :key="index">
			<view class="a">{{item.name}} {{item.phone}}<text>默认</text></view>
			<view class="b">
				<view class="d">
					{{item.detail}}
				</view>
				<image src="/static/order/edit.png" @click="editAddress(item)"></image>
			</view>
		</view>
		<view class="footer">
			<view class="operaBtn" @click="addAddress">
				新增收货地址
			</view>
		</view>
	</view>
</template>

<script>
	import * as AddressApi from '@/api/address'
	export default {
		data() {
			return {
				addressList: []
			};
		},
		onShow() {
			this.getAddressList()
		},
		methods: {
			
			getAddressList() {
				const that = this
				return new Promise((resolve, reject) => {
					AddressApi.list()
						.then(result => {
							that.addressList = result.data.list
						})
						.catch(reject)
				})
			},
			editAddress(item){
				// 编辑收货地址
				uni.navigateTo({
					url:'/pages/news/park/addressEdit?addressDetail=' + JSON.stringify(item)
				})
			},
			addAddress(){
				uni.navigateTo({
					url:'/pages/news/park/addressEdit'
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.addressList {
		padding: 0 0 0 50rpx;
		background-color: #FFFFFF;
		overflow: hidden;

		.item {
			padding: 35rpx 0;
			overflow: hidden;
			border-bottom: 1px solid #EEEEEE;

			.a {
				font-size: 32rpx;
				font-weight: 500;
				color: #1E1E1E;
				padding-bottom: 20rpx;
				display: flex;
				align-items: center;

				text {
					width: 66rpx;
					line-height: 34rpx;
					background: #F32020;
					border-radius: 4rpx;
					text-align: center;
					display: block;
					margin-left: 10rpx;
					font-size: 24rpx;
					font-weight: 400;
					color: #FFFFFF;
					border-radius: 5rpx;
				}
			}

			.b {
				display: flex;
				align-items: flex-start;
				justify-content: space-between;

				.d {
					font-size: 32rpx;
					font-weight: 400;
					color: #979797;
					max-width: 600rpx;
				}

				image {
					width: 36rpx;
					height: 36rpx;
					margin-right: 50rpx;
				}
			}
		}
	}
	.footer{
		display: flex;
		width: 100%;
		height: 120rpx;
		justify-content: center;
		position: fixed;
		bottom: 0;
		left: 0;
		.operaBtn{
			width: 686rpx;
			height: 92rpx;
			background: #F34A40;
			border-radius: 8rpx 8rpx 8rpx 8rpx;
			opacity: 1;
			line-height: 92rpx;
			font-size: 28rpx;
			font-family: PingFang SC, PingFang SC;
			font-weight: 600;
			color: #FFFFFF;
			text-align: center;
		}
	}
</style>