<template>
	<view class="page-mine" :style="{'backgroundImage': 'url('+bg+')'}">
		<view class="status_bar"></view>
		<view class="user-info">
			<view class="title">个人中心</view>	
				<div class="user">
					<image class="head" 
					:src="user.userPhoto?user.userPhoto:userPhoto"
					 @error="user.userPhoto=userPhoto"
					 alt="" />
					<text class="name">{{user.userName}}</text>
				</div>
		</view>
		<div class="form">
			<div class="item">
				<div class="item-title">
					<image class="icon" src="/static/icon/location.png" mode="widthFix"></image>
					<div class="namme">行政区划</div>
				</div>
				<div class="cont">{{user.ocName}}</div>
			</div>
			<div class="item">
				<div class="item-title">
					<image class="icon" src="/static/icon/user-group.png" mode="widthFix"></image>
					<div class="namme">所属部门</div>
				</div>
				<div class="cont">{{user.groupName}}</div>
			</div>
			<div class="item"  @click="linkTo">
				<div class="item-title">
					<image class="icon" src="/static/icon/unlock.png" mode="widthFix"></image>
					<div class="name">修改密码</div>
				</div>
				<div class="cont"><image class="rt-icon" src="/static/icon/rt_icon.png" mode="widthFix"></image></div>
			</div>
		</div>
		<button type="default" class="btn-submit" @click="logout">退出登陆</button>
	</view>
</template>

<script>
	import {logout} from '@/api/user.js'	
	export default {
		data() {
			return {
				user:{
					userName:"--",
					userRealName:"--",
					groupName:"--",
					ocName:"--",
					userPhoto:require('./image/head.png')
				},
				userPhoto:require('./image/head.png'),
				bg:require('./image/bg.png')
			}
		},
		onShow() {
			this.init()
		},
		methods: {
			init(){
				let accountInfo=uni.getStorageSync('accountInfo')
				if(accountInfo){
					this.user=accountInfo
				}
			},
			linkTo(){
				uni.navigateTo({
					url:'/pages/mine/password/password'
				})
			},
			logout(){
				uni.showModal({
					title:'提示！',
					content:"是否要退出登录",
					success(res) {
						if (res.confirm) {
							logout().then(()=>{
								uni.clearStorageSync()
								uni.navigateTo({
									url:'/pages/login/login'
								})							
							})
						}					
					}
				})
			}				
		}
	}
</script>

<style lang="scss" scoped>
.page-mine{
	background-size: 100% 504rpx;
	background-repeat: no-repeat;
	background-color: #fff;
		height: 100vh;
	/* #ifdef H5 */
	height: calc(100vh - 50px);
	/* #endif */
	box-sizing: border-box;
	position: relative;
	.user-info{
		padding-left:30upx;
		.user{
			display: flex;
			align-items: center;
			padding:106upx 0 140upx;
			.head{
				display: block;
				width: 112upx;
				height: 112upx;
				border-radius: 50%;
			}
			.name{
				font-family: 'Abhaya Libre';
				font-style: normal;
				font-weight: 700;
				font-size: 38rpx;
				line-height: 54upx;
				color: #151515;
				padding-left: 30upx;
			}
		}
	}
	.form{
		padding: 0 48upx 0 36upx;
		background-color: #fff;
		.item{
			height: 120upx;
			display: flex;
			justify-content: space-between;
			align-items: center;
			.item-title{
				display: flex;
				align-items: center;
				.icon{
					display: block;
					width: 48upx;
					height: 48upx;
				}
				.name{
					font-family: 'Abhaya Libre';
					font-style: normal;
					font-weight: 400;
					font-size: 32upx;
					line-height:48upx;
					text-align: center;
					color: #151515;					
					margin-left: 10upx;
				}
			}
			.cont{
					font-family: 'Abhaya Libre';
					font-style: normal;
					font-weight: 400;
					font-size: 32upx;
					line-height:48upx;
					text-align: center;
					color: #151515;					
					margin-left: 10upx;	
				    .rt-icon{
						display: block;
						width: 15upx;
						height: 15upx;
					}
			}
		}
	}
	.title{
		font-family: 'Abhaya Libre';
		font-style: normal;
		font-weight: 700;
		font-size: 34upx;
		line-height: 40upx;
		color: #151515;
	}
	.btn-submit{
		width: 654upx;
		height: 88upx;
		font-family: 'Abhaya Libre';
		font-style: normal;
		font-weight: 400;
		font-size: 32upx;
		line-height: 88upx;
		text-align: center;
		color: #999999;
		background: #F2F2F2;
		border-radius: 4px;
		text-align: center;
		position: absolute;
		bottom: 150upx;
		margin-left: 50%;
		transform: translateX(-50%);
	}
}
</style>
