<template>
	<mobile-frame>
		<view class="main">
			<view class="one">
				<scroll-view scroll-y="true" class="scroll-view" @scrolltolower="toPage">
					<view class="list-scroll-view">
						<view class="list" v-for="(item,index) in list" :key="index">
							<view class="name">
								<text>{{item.name}}</text>
								<text>{{item.phone}}</text>
							</view>
							<view class="address">
								<text>{{item.province}}</text>
								<text>{{item.city}}</text>
								<text>{{item.area}}</text>
								<text>{{item.address}}</text>
								<text>{{item.number}}</text>
							</view>
							<view class="btn">
								<view class="btn_1" v-if="item.is_default==false">
									<button type="default" size="mini" @click="toDefa(item)">设为默认</button>
								</view>
								<view class="btn_1">
									<button type="default" size="mini" @click="toCommon(item)">编辑</button>
								</view>
								<view class="btn_1">
									<button type="default" size="mini" @click="toDel(item)">删除</button>
								</view>
							</view>
							<view class="default" v-if="item.is_default==true">
								<text>默认</text>
							</view>
						</view>
					</view>
				</scroll-view>
			</view>
			<view class="two">
				<view class="two_1">
					<button type="default">获取微信地址</button>
				</view>
				<view class="two_1">
					<button type="default" @click="toCommon()">新增收货地址</button>
				</view>
			</view>
		</view>
	</mobile-frame>
</template>

<script>
	export default {
		data() {
			return {
				list: [ //信息列表
					{
						id: '1234567',
						name: '姓名',
						phone: '13174420325',
						province: '吉林省',
						city: '长春市',
						area: '朝阳区',
						address: '详细地址',
						number: 0,
						is_default: false
					},
					{
						id: '123456',
						name: '姓名',
						phone: '13174420325',
						province: '吉林省',
						city: '长春市',
						area: '朝阳区',
						address: '详细地址',
						number: 11,
						is_default: true
					}

				]
			};
		},
		onShow: function() {},
		methods: {
			// 分页
			toPage() {

			},
			// 设置默认
			toDefa(e) {
				uni.showModal({
					title: '提示',
					content: '确定设置该地址为默认地址吗?',
					success: function(res) {
						if (res.confirm) {
							console.log('用户点击确定');
						}
					}
				});
			},
			// 编辑
			toCommon(e) {
				uni.navigateTo({
					url: `/pagesMy/address/add?id=${e&&e.id?e.id:''}`
				})
			},
			// 删除
			toDel(e) {
				uni.showModal({
					title: '提示',
					content: '确定删除该地址吗?',
					success: function(res) {
						if (res.confirm) {
							console.log('用户点击确定');
						}
					}
				});
			}
		}
	}
</script>

<style lang="scss">
	.main {
		display: flex;
		flex-direction: column;
		width: 100vw;
		height: 100vh;

		.one {
			position: relative;
			flex-grow: 1;
			background-color: var(--f5Color);

			.list {
				position: relative;
				background: var(--fffColor);
				padding: 2vw;
				width: 92vw;
				margin: 2vw 2vw 0 2vw;
				border-radius: 5px;

				.name {
					font-size: var(--font16Size);
					margin: 0 0 1vw 0;

					text {
						padding: 0 2vw 0 0;
					}
				}

				.address {
					font-size: var(--font14Size);
					margin: 0 0 1vw 0;

					text {
						padding: 0 2vw 0 0;
					}
				}

				.btn {
					display: flex;
					flex-direction: row;
					justify-content: space-around;
					border-top: 1px solid var(--font16Size);
					padding: 2vw 0 0 0;

					.btn_1 {
						button {
							width: 100%;
							color: var(--fffColor);
							background-color: var(--f35BColor);
						}
					}

					.btn_1:nth-child(2) {
						button {
							background-color: var(--f0fColor);
						}
					}

					.btn_1:last-child {
						button {
							background-color: var(--fFB1Color);
						}
					}
				}

				.default {
					position: absolute;
					top: 0;
					right: 0;

					text {
						background: var(--ff0Color);
						color: var(--fffColor);
						font-size: var(--font12Size);
						padding: 1vw;
						border-radius: 5px;
					}
				}
			}

		}

		.two {
			display: flex;
			flex-direction: row;
			justify-content: space-between;

			.two_1 {
				width: 50vw;

				button {
					width: 100%;
					color: var(--fffColor);
					background-color: var(--f08Color);
				}


			}

			.two_1:nth-child(2) {
				button {
					background-color: var(--fFB1Color);
				}
			}
		}
	}

	.scroll-view {
		position: absolute;
		top: 0;
		left: 0;
		right: 0;
		bottom: 0;

		.list-scroll-view {
			display: flex;
			flex-direction: column;
		}
	}
</style>
