<template>
	<view class="content">
		<view class="user-info">
			<view class="user-data">
				<view class="user-name">{{userData.nickName}}</view>
				<view class="user-phone">{{userData.phone}}</view>
			</view>
			<view class="user-img">
				<u-avatar :src="userData.headImage" size="160"></u-avatar>
			</view>
		</view>
		<view class="user-handle" v-for="(item, index) in handleList" :key="index" @click="goToHandle(item)">
			<view class="handle-icon">
				<u-image :src="item.icon" mode="aspectFit" width="28px" height="28px"></u-image>
			</view>
			<view class="handle-label">{{item.label}}</view>
			<view class="handle-arrow">
				<u-icon name="arrow-right" color="#cccccc" size="32"></u-icon>
			</view>
		</view>
		<u-top-tips ref="uTips"></u-top-tips>
	</view>
</template>

<script>
	const NET = require('@/utils/request')
	const API = require('@/config/api')
	export default {
		data() {
			return {
				userData: {
					headImage: '',
					userId: '',
					nickName: '',
					userName: '',
					phone: '',
				},
				handleList: [{
						label: '我的评价',
						path: 'evaluateList',
						icon: API.getServerImg + 'pingjia.png'
					},
					{
						label: '补课记录',
						path: 'extraLessonsList',
						icon: API.getServerImg + 'dingdanguanli.png'
					},
					{
						label: '请假记录',
						path: 'leaveLessonsList',
						icon: API.getServerImg + 'qingjia.png'
					},
					{
						label: '续费率/签到率排行',
						path: 'ratioRank',
						icon: API.getServerImg + 'paihang.png'
					},
					{
						label: '续费提醒',
						path: 'renewList',
						icon: API.getServerImg + 'xufeitixing.png'
					},
					{
						label: '签到提醒',
						path: 'signList',
						icon: API.getServerImg + 'xiaoxi.png'
					},
					{
						label: '退出登录',
						path: 'logout',
						icon: API.getServerImg + 'xiaoxi.png'
					},
				]
			}
		},
		onLoad() {
			if (uni.getStorageSync('userData')) {
				this.userData = uni.getStorageSync('userData')
			}
		},
		methods: {
			//  跳转我的各列表界面
			goToHandle(site) {
				if(site.path == 'logout'){
					uni.removeStorageSync('token')
					uni.navigateTo({
						url: '/pages/login/index'
					});
				}else{
					uni.navigateTo({
						url: '/pagesMain/' + site.path
					});
				}
			},
		}
	}
</script>

<style lang='scss'>
	@import "@/static/css/themes.scss";

	.content {
		width: 100%;
		height: 100vh;
		float: left;

		.user-info {
			width: 100%;
			height: 110px;
			margin-bottom: 20px;
			float: left;
			background-color: $mainColor;

			.user-data {
				width: calc(100% - 110px);
				height: 110px;
				padding: 15px 0 15px 15px;
				float: left;

				.user-name {
					width: 100%;
					float: left;
					font-size: 24px;
					color: #FFFFFF;
					line-height: 30px;
					margin: 10px 0;
					white-space: nowrap;
					overflow: hidden;
					text-overflow: ellipsis;
				}

				.user-phone {
					width: 100%;
					color: #FFFFFF;
					line-height: 20px;
					float: left;
					white-space: nowrap;
					overflow: hidden;
					text-overflow: ellipsis;
				}
			}

			.user-img {
				width: 110px;
				height: 110px;
				padding: 15px;
				float: left;
				display: flex;
				align-items: center;
				justify-content: center;
			}
		}

		.user-handle {
			width: 100vw;
			height: 40px;
			float: left;
			padding: 0 15px;
			margin-bottom: 10px;
			display: flex;
			align-items: center;

			.handle-icon {
				width: 40px;
				height: 40px;
				text-align: center;
				line-height: 40px;
				display: flex;
				align-items: center;
			}

			.handle-label {
				height: 40px;
				flex: 1;
				margin-left: 10px;
				line-height: 40px;
				font-size: 15px;
			}

			.handle-arrow {
				line-height: 40px;
			}
		}
	}
</style>