<template>
	<view v-if="!loadding">
		<view v-if="listData.length > 0" class="pbenv">
			<view class="address-list">
				<view class="address-item" v-for="(item, index) in listData" :key="index">
					<view class="info flex-1 mb10">
						<view class="pt10 f24 gray9" style="line-height: 1.5;">
							<view>{{ item.pkProvinceVal }}{{ item.pkCityVal }}{{ item.pkCountyVal }}</view>
							<view class=" pt10 f30 gray1f">{{ item.address }}</view>
							<view class="icon-box plus d-e-c  " @click="editAddress(item)">
								<image class="add_icon_img edit " src="/static/icon/add-edit.png" mode="aspectFill"></image>
							</view>
						</view>
						<view class="user pt10 f28 d-b-c">
							<text>{{ item.accountName }} <text class="gray9 f28 ml10 ">{{ item.phone }}</text></text>
						</view>
					</view>
				</view>
			</view>
		</view>
		 <view v-else>
			<view class="none_add"><image class="no_add" src="/static/no_adress.png" mode="aspectFill"></image></view>
			<view class="tc mb30 gray9 f28">{{ $t('MY_TH_5') }}</view>
		</view> 
	</view>
</template>

<script>
export default {
	data() {
		return {
			/*是否加载完成*/
			loadding: true,
			indicatorDots: true,
			autoplay: true,
			interval: 2000,
			duration: 500,
			/*数据*/
			listData: [],
			/*默认地址id*/
			default_id: '0',
			options: {}
		};
	},
	onLoad: function(options) {
		this.options = options;
	},
	onShow: function() {
		uni.showLoading({
			title:this.$t('MN_F_6')
		});
		/*获取地址列表*/
		this.getData();
	},
	methods: {
		/*编辑地址*/
		editAddress(e) {
			this.gotoPage(`/pages/user/gift/edit?pkId=${e.pkId}&pkProvince=${e.pkProvince}&pkCity=${e.pkCity}&pkCounty=${e.pkCounty}&address=${e.address}&showName=${e.pkProvinceVal}${e.pkCityVal}${e.pkCountyVal}&accountName=${e.accountName}&phone=${e.phone}`);
		},
		/*获取数据*/
		getData() {
			let self = this;
			self.loadding = true;
			self._get('member/api/member-gift/member-gift-list', {}, function(res) {
				self.listData = res.data;
				self.loadding = false;
				uni.hideLoading();
			});
		},
	   gotoPage(path) {
    		uni.navigateTo({
     			 url: path
    });
  },
	}
};
</script>

<style lang="scss">
page {
	background: #f2f2f2;
}

.address-list {
	padding-bottom: 90rpx;
}

.address-item {
	background: #ffffff;
	border-radius: 0;
	padding: 28rpx 30rpx;
	margin-bottom: 21rpx;
	display: flex;
	align-items: center;
}

.foot-btns {
	padding: 0;
}

.foot-btns .btn-red {
	width: 100%;
	height: 90rpx;
	line-height: 90rpx;
	border-radius: 0;
}

.none_add {
	padding: 214rpx 0 60rpx 0;
}

.no_add {
	width: 362rpx;
	height: 285rpx;
	margin: 0 auto;
}

.no_add_add {
	width: 320rpx;
	height: 80rpx;
	border: 2rpx solid #fb3024;
	border-radius: 15rpx;
	text-align: center;
	line-height: 80rpx;
	font-size: 32rpx;
	font-family: PingFang SC;
	font-weight: 500;
	border-color: #fb3024;
	color: #fb3024;
	margin: 0 auto;
}

.add_add {
	height: 64rpx;
	line-height: 64rpx;
	font-size: 26rpx;
	font-family: PingFang SC;
	font-weight: 500;
	color: #fb3024;
	padding: 0 35rpx;
	border-bottom: 1rpx solid #fb3024;
}

.defaul_add {
	background: #fb3024;
	font-size: 22rpx;
	font-family: PingFang SC;
	font-weight: 500;
	color: #ffffff;
}

.add_icon_img.edit {
	width: 34rpx;
	height: 34rpx;
}

.add_icon_img.delete {
	width: 34rpx;
	height: 34rpx;
}

.none_line {
	width: 1rpx;
	height: 44rpx;
	background: #d9d9d9;
}

.add_add-btn {
	position: fixed;
	bottom: calc(env(safe-area-inset-bottom) + 20rpx);
	width: 690rpx;
	margin: 20rpx 30rpx;
	box-sizing: border-box;
	font-size: 28rpx;
	height: 80rpx;
	border-radius: 15rpx;
	display: flex;
	justify-content: center;
	align-items: center;
	background-color: #fb3024;
	color: #fff;
}

.pbenv {
	padding-bottom: calc(env(safe-area-inset-bottom) + 120rpx);
	box-sizing: border-box;
}
</style>
