<!--
 * @Author: euzhi
 * @Description: 我的地址
-->
<template>
<view class="appCotent">
<div class="myAddress">
    <div class="address__content">
        <div class="ress__item" v-for="(vo,inx) in addressList" :key="inx" >
            <div class="item__top" @click="goPay(vo.id)">
                <span>{{vo.userName}}</span>
                <span>{{vo.telNumber}}</span>
                <span v-if="vo.defaultFlag">默认</span>
            </div>
            <div class="item__two">
                <span @click="goPay(vo.id)">{{vo.address}}&emsp;{{vo.detailInfo}}</span>
                <view @click="editAddress(vo.id)" style="height: 100rpx; width: 100rpx;padding-left: 40rpx;">
                    <image style="width: 28rpx; height: 30rpx; margin: 0 auto;
                    display: table-cell;vertical-align: middle;text-align: center;" src="@/static/my/my-address1.png" />
                </view>
            </div>
        </div>
    </div>
    <div class="love__btn" @click="add">
        <image src="@/static/move-car/love-car5.png"> 新增地址
    </div>
</div>
</view>
</template>

<script>
export default {
    data() {
        return {
			addressList: [],
			pay: '',
			carCode: '',
        }
    },
    methods: {
        add() {
            uni.navigateTo({
                url: '/pagesD/pages/personal/addAddress?type=myAddress'
            });
        },
		getAddressList(){
			let opts = { url: '/app/user/address/list', method: 'get' };
			this.http.httpTokenRequest(opts, {}).then(res => {
				if (res.data.code == 200) {
					this.addressList = res.data.data
				}
			})
		},
        editAddress(id){
            uni.navigateTo({
                url: '/pagesD/pages/personal/editAddress?id=' + id
            });
        },
		goPay(id){
			if(this.pay==1){
				let pages = getCurrentPages();
				let prevPage = pages[pages.length - 2]
				prevPage.$vm.addressId = id;
				uni.navigateBack({
					delta: 1
				})
			}else{
                this.editAddress(id)
            }
		}
    },
	onShow(){
	  this.getAddressList()
	},
	onLoad(e) {
		this.pay = e.pay
	},
}
</script>

<style lang="scss" scoped>
.myAddress {
    padding: 40rpx;

    .love__btn {
        height: 76rpx;
        background: url('@/static/move-car/love-car4.png') no-repeat;
        background-size: contain;
        font-size: 32rpx;
        font-family: PingFang SC;
        font-weight: 500;
        color: #FFFFFF;
        line-height: 76rpx;
        text-align: center;

        image {
            width: 30rpx;
            height: 30rpx;
            margin-right: 20rpx;

        }
    }

    .address__content {
        background: #FFFFFF;
        box-shadow: 0rpx 0rpx 28rpx 1rpx rgba(232, 232, 232, 0.16);
        border-radius: 20rpx;
        padding: 10rpx 30rpx;
        margin-bottom: 40rpx;

        .ress__item {
            border-bottom: 1px solid rgba(0, 0, 0, .1);
            padding: 30rpx 0;

            .item__top {
                margin-bottom: 20rpx;
                display: flex;
                align-items: center;

                >span:nth-of-type(1) {
                    font-size: 36rpx;
                    font-family: PingFang SC;
                    font-weight: bold;
                    color: #333333;
                }

                >span:nth-of-type(2) {
                    font-size: 32rpx;
                    font-family: DIN;
                    font-weight: 500;
                    color: #666666;
                    padding: 0 28rpx;
                }

                >span:nth-of-type(3) {
                    width: 66rpx;
                    height: 32rpx;
                    font-size: 24rpx;
                    font-family: PingFang SC;
                    font-weight: bold;
                    color: #F88D28;
                    line-height: 32rpx;
                    text-align: center;
                    background: url('@/static/my/my-address2.png') no-repeat;
                    background-size: contain;
                }
            }

            .item__two {
                display: flex;
                justify-content: space-between;

                >span:nth-of-type(1) {
                    font-size: 32rpx;
                    font-family: PingFang SC;
                    font-weight: 500;
                    color: #666666;
                }

                >span:nth-of-type(2) {
                    padding-left: 40rpx;
                    image {
                        width: 28rpx;
                        height: 30rpx;
                    }
                }
            }
        }

        .ress__item:nth-last-of-type(1) {
            border-bottom: none;
        }
    }
}
</style>
