<template>
	<view class="content">
		<view class="banner">
			<div class="custom-nav">我的</div>	
			<div class="user-container">
				<view class="avatar">
					<image v-if="user.userAvatar" class="photo" :src="user.userAvatar" mode="widthFix" @error="userAvatar=defaultAvatar"></image>
					<image v-else class="photo" :src="defaultAvatar" mode="widthFix"></image>
				</view>
				<view class="bottom">
					<view class="name">
						<text>{{user.userName}}</text>
					</view>	
					<div class="phone">{{user.userPhone}}</div>
				</view>						
			</div>
		</view>
		<view class="zhcx-table">
			<uni-list>
				<uni-list-item title="个人资料"></uni-list-item>
<!-- 					to="/pages/myCenter/personalData/personalData" showArrow -->					
				<uni-list-item title="部门":rightText="user.groupName"></uni-list-item>
				<uni-list-item title="岗位":rightText="user.positionName"></uni-list-item>
				<uni-list-item title="介绍":note="user.userIntro" :ellipsis="3"></uni-list-item>
			</uni-list>			
		</view>	
		<div class="logoutBt" @click="logout">退出登录</div>		
	</view>
</template>

<script>
	import {logout} from '@/api/system/user.js'	
	export default{
		data(){
			return{
				defaultAvatar:"/static/components/avatar.png",
				user:{
					groupName: "",
					ocName: "",
					positionName: "",
					roleName: "",
					userAvatar: "",
					userIntro: "",
					userName: "",
					userPhone: "",
					userPhoto: "",
					userRealName: ""					
				}
			}
		},	
		onShow() {
			this.init();
		},	
		methods:{			
			init(){
				let user=uni.getStorageSync('accountInfo');
				if(user){
					user=JSON.parse(user)	
					this.user=user
				}			
			},
			logout(){
				uni.showModal({
					title:'提示！',
					content:"是否要退出登录",
					success(res) {
						if (res.confirm) {
							logout().then(()=>{
								uni.clearStorageSync()
								uni.reLaunch({
									url:'/pages/login/index'
								})							
							})
						}					
					}
				})
			}			
		}
	}
</script>

<style lang="scss" scoped>
	.content{
		 position: relative;
		.banner{
			height: 580upx;
			background-image: url('/static/center/bg.png');
			background-repeat: no-repeat;
			background-size: 100% 100%;
			position: relative;	
			&::after{
				position: absolute;
				content: "";
				display: block;
				width: 440rpx;
				height: 632rpx;
				right: 0;
				top: 20px;
				background-image:url('/static/center/bgmask.png');
				background-repeat: no-repeat;
				background-size: 100% 100%;
				z-index: 1;
			}
			.custom-nav{
				position: fixed;
				text-align: center;
				top: 24px;
				left: var(--window-left);
				right: var(--window-right);
				height: 88rpx;
				line-height: 88rpx;
				z-index: 998;
				color: #333333;
				background-color: transparent;
				font-size: 32rpx;
				font-weight: 400;
				box-sizing: border-box;
				font-family: PingFang SC;
			}			
			.user-container{
				&{
					display: flex;
					justify-content: flex-start;
					align-items: center;
					position: absolute;
					bottom: 190rpx;
					left: 40rpx;
				}
				.avatar{
					width: 120rpx;
					height: 120rpx;
					border-radius: 50%;
					display: block;
					overflow: hidden;
					background: rgba(255,255,255,0.39);
					border: 2rpx solid #707070;
					.photo{
						width: 120rpx;
						height: 120rpx;
						border-radius: 50%;						
					}
				}
				.bottom{
					&{
						padding-left: 20rpx;
					}
					.name{
						font-size: 36rpx;
						font-family: PingFang SC;
						font-weight: bold;
						line-height: 50rpx;
						color: #FFFFFF;					
					}
					.phone{
						font-size: 28rpx;
						font-family: PingFang SC;
						font-weight: 400;
						line-height: 40rpx;
						color: #FFFFFF;	
						padding-top: 14rpx;
					}
				}
			}
		}
		.zhcx-table{
			width: 710rpx;
			position: absolute;
			left: 20rpx;
			top: 440rpx;
			background-color: #fff;
			z-index: 99;
			border-radius: 12px;
			overflow: hidden;
		}
		.logoutBt{
			width: 424rpx;
			height: 72rpx;
			line-height: 72rpx;	
			text-align: center;			
			position: fixed;
			bottom: 130rpx;
			left: 50%;
			transform: translateX(-50%);					
			background:#3D90F4;
			border-radius: 42rpx;	
			font-size: 32rpx;
			font-family: PingFang SC;
			font-weight: 400;
			color: #FFFFFF;
			z-index: 999;
		}
		.faceRecord-box{
			position: fixed;
			top: 0;
			bottom: 0;
			left: 0;
			right: 0;
			z-index: 9999;
			background-color: #fff;
			display: flex;
			justify-content: center;
			align-items: center;
			flex-direction: column;
			.camera,.facePhoto{
				width: 450rpx;
				height: 450rpx;
				border-radius: 50%;
				border:2rpx solid #eaeaea;
			}
			.takePhotoBt{
				display: inline-block;
				margin: 40rpx 0;
			}
			.camera-submit{
				width: 424rpx;
				height: 72rpx;
				line-height: 72rpx;	
				text-align: center;							
				background:#3D90F4;
				border-radius: 42rpx;	
				font-size: 32rpx;
				font-family: PingFang SC;
				font-weight: 400;
				color: #FFFFFF;	
				margin: 40rpx auto;
				&.cancel{
					color: #fff;
					background-color: #ED834A;
					border-color: #ED834A;
					margin: 0 auto 50rpx;
				}
			}
		}
	}
</style>
