<template>
	<scroll-view scroll-y="true" class="body">
		<view class="user-info">
			<view class="state-bar"></view>
			<view class="avatar-name">
				<image class="avatar"></image>
				<view v-if="userInfo.token" class="text">
					<view class="nick-name">{{userInfo.nickname}}</view>
					<view class="account">{{userInfo.username}}</view>
				</view>
				<view v-else class="text">
					<navigator url="/pages/user/login" class="nick-name">登录解锁更多功能</navigator>
					<navigator url="/pages/user/login" class="account">点击登录</navigator>
				</view>
			</view>
		</view>
		<view v-if="userInfo.token" class="menu-group">
			<view class="menu-item"><text>偏好设置</text><text class="iconfont">&#xe63a;</text></view>
			<view class="menu-item"><text>企业信息</text><text class="iconfont">&#xe63a;</text></view>
			<view class="menu-item"><text>套餐额度</text><text class="iconfont">&#xe63a;</text></view>
			<view class="menu-item"><text>消费记录</text><text class="iconfont">&#xe63a;</text></view>
			<view class="menu-item"><text>设备管理</text><text class="iconfont">&#xe63a;</text></view>
			<view class="menu-item"><text>账号托管</text><text class="iconfont">&#xe63a;</text></view>
			<view class="menu-item"><text>修改密码</text><text class="iconfont">&#xe63a;</text></view>
		</view>
		<view v-if="userInfo.token" class="menu-group">
			<view @tap="userLogout()" class="menu-item"><text>退出登录</text><text class="iconfont">&#xe63a;</text></view>
		</view>
	</scroll-view>
</template>

<script>
	export default {
		data() {
			return {
				
			};
		},
		methods: {
			/**
			 * 退出登录
			 */
			userLogout(){
				uni.showModal({
					title: '退出登录',
					content: '确实要登出这个账号吗？',
					success: (res) => {
						if(res.confirm){
							this.$store.commit('logout')
						}
					}
				})
				
			}
		},
		computed: {
			userInfo() {
				return this.$store.getters.userInfo
			}
		}
	}
</script>

<style scoped>
.body{
	.menu-group{
		/* box-shadow: 0 0 6rpx 0 #00000011; */
		margin-top: 24rpx;
		.menu-item{
			display: flex;
			align-items: center;
			justify-content: space-between;
			background-color: white;
			padding: 36rpx 48rpx;
			.iconfont{
				color: #949494;
				font-size: 28rpx;
			}
			&:active{
				background-color: #f6f6f6;
			}
			&:not(:last-child){
				border-bottom: 1rpx solid #f0f0f0;
			}
		}
	}
	.user-info{
		/* box-shadow: 0 0 6rpx 0 #00000011; */
		padding: 160rpx 48rpx 48rpx;
		background-color: white;
		.avatar-name{
			display: grid;
			grid-template-columns: auto 1fr;
			grid-gap: 20px;
			.avatar{
				border-radius: 16rpx;
				background-color: #eeeeee;
				width: 130rpx;
				height: 130rpx;
			}
			.text{
				display: flex;
				flex-direction: column;
				justify-content: space-between;
				padding: 8rpx 0;
				.nick-name{
					font-weight: 600;
					font-size: 38rpx;
				}
				.account{
					font-size: 30rpx;
					color: #767676;
				}
			}
		}
	}
}
</style>