<!-- 用户信息界面 -->
<template>
	<view class="personal-info bx">
		<navbar :leftClick="leftClick" 
		:title="$t('page.persionalInfo.title')"></navbar>
		
		<!-- 基本用户信息 -->
		<view class="base-info content">
			
			<view class="base-info-item">
				<view class="title">{{ $t('page.persionalInfo.profle-image') }}</view>
				<image :src="userInfo.headImage || headImage" mode="aspectFit"></image>
			</view>
			
			<view class="base-info-item">
				<view class="title">{{ $t('page.persionalInfo.username') }}</view>
				<view class="name">{{ userInfo.account }}</view>
			</view>
			
		</view>
		
		<!-- 修改用户信息按钮组 -->
		<view class="edit-user-info-btns content">
			<view @click="toModifyUser(0)" class="edit-item">
				<view class="edit-descript">{{ $t('page.persionalInfo.change-pin') }}</view>
				<uni-icons color="#B0C73B" type="right" size="30rpx"></uni-icons>
			</view>
			
			<view @click="toModifyUser(1)" class="edit-item">
				<view class="edit-descript">{{ $t('page.persionalInfo.change-password') }}</view>
				<uni-icons color="#B0C73B" type="right" size="30rpx"></uni-icons>
			</view>
		</view>
		
		
		<!-- 填写地址弹框 -->
		<u-popup :show="showAddress" mode="center" bgColor="black"
		@close="showAddress=false">
			<view class="address-content">
				<view class="address-top">
					<view class="title">{{ $t('page.center.Tips') }}</view>
					<uni-icons @click="showAddress=false" 
					class="close-icon" 
					color="#B0C73B" type="close"
						size="40rpx"></uni-icons>
				</view>
				<view class="address-detail">
					<view class="title">{{ $t('page.center.Address') }}:</view>
					<textarea
					:placeholder="$t('page.center.type-address')"></textarea>
				</view>
				<view
				class="save">{{ $t('page.center.save') }}</view>
			</view>
		</u-popup>
	</view>
</template>

<script>
	import navbar from '@/components/base/m-navbar.vue'

	export default {
		components: {
			navbar
		},
		data() {
			return {
				userInfo : {},
				username : '',
				headImage : '/static/personalInfo/user-image.png',
				showAddress : false
			}
		},
		onShow() {
			this.getUserInfo()
		},
		methods: {
			getUserInfo(){
				this.request('userInfo').then(res => {
					if(res.code == 200){
						this.userInfo = res.result.userInfo
					}
				})
			},
			leftClick() {
				uni.navigateTo({
					url: '/pages/center/center'
				})
			},
			updateUser(){
				this.request('userInfo').then(res => {
					if(res.code == 200){
						this.userInfo = res.result
					}
				})
			},
			//跳转修改用户信息页面(二合一)
			toModifyUser(type){
				this.$play()
				uni.navigateTo({
					url: `/pages/modifyUser/modifyUser?type=${type}`
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.personal-info {
		width: 750rpx;
		min-height: 100vh;
		// background-color: black;
		margin: 0 auto;
		// background-image: url('@/static/personalInfo/bg.png');
		background-size: 100%;
		background-repeat: no-repeat;
		
		.content {
			width: 96%;
			margin: 0 auto;
		}
		
		.base-info , .edit-user-info-btns{
			border: 1px solid #00000080;
			margin: 20rpx auto 30rpx auto;
			
			.base-info-item , .edit-item{
				display: flex;
				justify-content: space-between;
				align-items: center;
				height: 100rpx;
				padding: 15rpx 10rpx;
				border-bottom: 1px solid #00000080;
				
				.title , .edit-descript{
					color: $uni-bg-color-app;
					font-size: 28rpx;
				}
				
				image{
					width: 100rpx;
					height: 100rpx;
				}
				
				.name{
					color: $uni-bg-color-app;
					font-size: 28rpx;
				}
			}
		}
	}
	
	.address-content {
		box-sizing: border-box;
		border: 1px solid #00000080;
		padding: 15rpx;
	
		.address-top {
			position: relative;
			display: flex;
			align-items: center;
			justify-content: center;
			padding: 30rpx 0rpx;
	
			.title {
				font-size: 36rpx;
				color: $uni-text-color;
				font-weight: bold;
			}
	
			.close-icon {
				position: absolute;
				top: 50%;
				right: 30rpx;
				transform: translateY(-50%);
			}
		}
	
		.address-detail {
			
			.title {
				color: $uni-text-color;
				margin-bottom: 10rpx;
				font-size: 28rpx;
			}
	
			textarea {
				border: 1px solid #afc638;
				color: #afc638;
				border-radius: 25rpx;
				height: 150rpx;
				width: 560rpx;
				text-indent: 1em;
			}
	
		}
		
		.save{
			display: flex;
			align-items: center;
			justify-content: center;
			background: #afc638;
			height: 80rpx;
			margin: 20rpx auto;
			border-radius: 20rpx;
			color: black;
			font-size: 34rpx;
		}
	}
</style>