<!-- 账号信息 -->
<template>
	<view class="account-info">
		<view class="main" v-if="!isShowInfo">
			<view class="title">个人信息</view>
			<view class="info" v-for="item in list" :key="item.id">
				<view class="title-icon">
					<image :src="item.icon" style="width: 48rpx;height: 48rpx;margin-right: 12rpx;"  mode=""></image>
					<text class="name">{{item.name}}</text>
				</view>
				<view style="margin-left: 40rpx;">{{item.value}}</view>
			</view>
		</view>
		
		<view class="button" @click="changePage('accountBound')">{{isShowInfo ? '绑定' : '重新绑定'}}</view>
		<view class="button-bottom">
			<view class="button button-left" @click="changePage('register')">用户注册</view>
			<view class="button button-right" @click="changePage('changePassword')">修改密码</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [
					{
						id: 'username',
						name: '用户名:',
						value: '',
						icon: '../../static/mine/username.png'
					},
					{
						id: 'name',
						name: '姓名:',
						value: '',
						icon: '../../static/mine/name.png'
					},
					{
						id: 'sex',
						name: '性别:',
						value: '',
						icon: '../../static/mine/sex.png'
					},
					{
						id: 'phone',
						name: '手机号:',
						value: '',
						icon: '../../static/mine/phone.png'
					},
					{
						id: 'email',
						name: '电子邮箱:',
						value: '',
						icon: '../../static/mine/email.png'
					},
					{
						id: 'region',
						name: '地区:',
						value: '',
						icon: '../../static/mine/region.png'
					},
					{
						id: 'address',
						name: '详细地址:',
						value: '',
						icon: '../../static/mine/address.png'
					},
				],
				isShowInfo: true,
			}
		},
		mounted() {
			this.getData();
		},
		methods: {
			getData() {
				this.$set(this.list, 0, {
					id: 'username',
					name: '用户名:',
					value: '123123',
					icon: '../../static/mine/username.png'
				});
				this.$set(this.list, 1, {
					id: 'name',
					name: '姓名:',
					value: 'ddd',
					icon: '../../static/mine/name.png'
				},);
				this.$set(this.list, 2, {
					id: 'sex',
					name: '性别:',
					value: '女',
					icon: '../../static/mine/sex.png'
				},);
				this.$set(this.list, 3, {
					id: 'phone',
					name: '手机号:',
					value: '12345678978',
					icon: '../../static/mine/phone.png'
				},);
				this.$set(this.list, 4, {
					id: 'email',
					name: '电子邮箱:',
					value: '123123246@qq.com',
					icon: '../../static/mine/email.png'
				},);
				this.$set(this.list, 5, {
					id: 'region',
					name: '地区:',
					value: '北京市海淀区',
					icon: '../../static/mine/region.png'
				});
				this.$set(this.list, 6, {
					id: 'address',
					name: '详细地址:',
					value: '某街道某小区1号楼6单元102区1号楼6单元1区1号楼6单元1区1号楼6单元1区1号楼6单元1',
					icon: '../../static/mine/address.png'
				},);
				this.isShowInfo = this.list.every(item => {
					return item.value === '';
				});
				console.log(this.isShowInfo)
			},
			changePage(val) {
				let url = `/pages/${val}/${val}`
				wx.navigateTo({
					url: url
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.account-info {
		padding: 40rpx 20rpx;
		width: 100%;
		height: 100%;
		box-sizing: border-box;
		.main {
			padding: 20rpx;
			box-sizing: border-box;
			background-color: #fff;
			border-radius: 16rpx;
			.title {
				width: 100%;
				text-align: center;
				font-size: 36rpx;
				font-weight: 600;
				margin-bottom: 50rpx;
			}
			.info {
				display: flex;
				justify-content: space-between;
				align-items: center;
				margin: 32rpx 0;
				.title-icon {
					display: flex;
					align-items: center;
					font-size: 30rpx;
					font-weight: 600;
					white-space: nowrap;
				}
			}
		}
		.button {
			width: 100%;
			display: flex;
			justify-content: center;
			align-items: center;
			padding: 20rpx;
			color: #fff;
			font-weight: 600;
			letter-spacing: 4rpx;
			background-color: #0096e0;
			border: 2rpx solid #0096e0;
			border-radius: 10rpx;
			margin: 64rpx 0 32rpx 0;
			white-space: nowrap;
			box-sizing: border-box;
			&:active {
				background-color: #fff;
				color: #0096e0;
			}
		}
		.button-bottom {
			display: flex;
			flex-direction: row;
			justify-content: space-between;
			align-items: center;
			.button-left {
				width: fit-content;
				padding: 20rpx 40rpx;
				margin-top: 0;
			}
			.button-right {
				width: fit-content;
				padding: 20rpx 40rpx;
				margin-top: 0;
			}
		}
	}
</style>
<style lang="scss">
	.account-info {
		.u-button--primary {
			font-weight: 600;
			letter-spacing: 4rpx;
			background-color: #0096e0 !important;
			border-color: #0096e0 !important;
			margin: 64rpx 0 32rpx 0;
		}
		.u-button--normal {
			padding: 0 32rpx !important;
		}
		.u-button {
			width: fit-content !important;
		}
	}
</style>
