<template>
	<view class="main">
		<view class="user" @click="go('info')">
			<image :src="user.avatarUrl ? user.avatarUrl : '../../../static/favicon.png'" class="head"></image>
			<view class="con" v-if="user.id">
				<view class="nickName">微信用户</view>
				<view class="welcome">欢迎使用爱就业咨询服务平台</view>
			</view>
			<view class="con" v-else>
				<view class="nickName">你还没登录</view>
				<view class="welcome">欢迎使用爱就业咨询服务平台</view>
			</view>
			<view class="icon">&#xe62b;</view>
		</view>
		<view class="rows">
			<view class="row">
				<view class="out">
					<view class="int">
						<view class="num">12</view>
						<view class="desc">全职投递</view>
					</view>
				</view>
			</view>
			<view class="row">
				<view class="out">
					<view class="int">
						<view class="num">0</view>
						<view class="desc">兼职投递</view>
					</view>
				</view>
			</view>
			<view class="row">
				<view class="out">
					<view class="int">
						<view class="num">0.00</view>
						<view class="desc">账户余额</view>
					</view>
				</view>
			</view>
		</view>
		<!--政务服务-->
		<view class="mtt">政务服务</view>
		<view class="menu">
			<view class="cd">
				<view class="out">
					<view class="int">
						<view class="icon" style="background-color: #f44336">&#xe6be;</view>
						<view class="title">失业登记</view>
					</view>
				</view>
			</view>
			<view class="cd">
				<view class="out">
					<view class="int">
						<view class="icon" style="background-color: #4581fb">&#xe64a;</view>
						<view class="title">就业补贴</view>
					</view>
				</view>
			</view>
			<view class="cd">
				<view class="out">
					<view class="int">
						<view class="icon" style="background-color: #ff9800">&#xe73c;</view>
						<view class="title">培训指导</view>
					</view>
				</view>
			</view>
			<view class="cd">
				<view class="out">
					<view class="int">
						<view class="icon" style="background-color: #00bcd4">&#xe998;</view>
						<view class="title">法务服务</view>
					</view>
				</view>
			</view>
		</view>
		<view v-if="user.type == 1">
			<view class="mtt">企业服务</view>
			<view class="menu">
				<view class="cd">
					<view class="out">
						<view class="int">
							<view class="icon" style="background-color: #03a9f4">&#xe627;</view>
							<view class="title">职位管理</view>
						</view>
					</view>
				</view>
				<view class="cd">
					<view class="out">
						<view class="int">
							<view class="icon" style="background-color: #03a9f4">&#xe627;</view>
							<view class="title">企业信息</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<view class="mtt">求职服务</view>
		<view class="menu">
			<view class="cd" @click="go('/pages/user/resume/index')">
				<view class="out">
					<view class="int">
						<view class="icon" style="background-color: #3f51b5">&#xe606;</view>
						<view class="title">我的简历</view>
					</view>
				</view>
			</view>
			<view class="cd">
				<view class="out">
					<view class="int">
						<view class="icon" style="background-color: #4caf50">&#xe605;</view>
						<view class="title">面试邀约</view>
					</view>
				</view>
			</view>
			<view class="cd">
				<view class="out">
					<view class="int">
						<view class="icon" style="background-color: #607d8b">&#xe68a;</view>
						<view class="title">投递历史</view>
					</view>
				</view>
			</view>
		</view>
		<view class="mtt">更多服务</view>
		<view class="menu">
			<view class="cd" @click="go('index')">
				<view class="out">
					<view class="int">
						<view class="icon" style="background-color: #ffc107">&#xe725;</view>
						<view class="title">结算广场</view>
					</view>
				</view>
			</view>
			<view class="cd">
				<view class="out">
					<view class="int">
						<view class="icon" style="background-color: #2196f3">&#xe680;</view>
						<view class="title">设置</view>
					</view>
				</view>
			</view>
			<view class="cd">
				<view class="out">
					<view class="int">
						<view class="icon" style="background-color: #ff5722">&#xe616;</view>
						<view class="title">分享有利</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>
<script>
export default {
	data() {
		return {
			ip: this.http.ip,
			user: {}
		};
	},
	onShow() {
		/* this.user = {
				token: 'eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6ImQyYThiZTk5LThjY2MtNGFkMi05ODJlLTMzYzE3NTdiNDllOSJ9.YFzfq1YEDy1FmZ-2bynRDgQai6qMdfGFsgQCDMiStba-m4AdoqKx6hmfd7F5n2t9l1bgcxE9VVpC7M6TdWN72Q'
			};
			uni.setStorageSync('user', this.user); */
		if (this.hasLogin()) {
			this.getUserInfo();
		}
	},
	methods: {
		getUserInfo() {
			this.http.request({
				url: '/app/user/info',
				success: (res) => {
					this.user = res.data.data;
					if (res.data.data.type == null) {
						uni.navigateTo({ url: '/pages/user/switch' });
					}
				}
			});
		},
		go(url) {
			if (this.hasLogin()) {
				uni.navigateTo({ url: url });
			} else {
				uni.navigateTo({ url: '/pages/user/login' });
			}
		},
		//退出登录
		exit(url) {
			uni.showModal({
				title: '提示',
				content: '确定退出登录?',
				success: (res) => {
					if (res.confirm) {
						this.http.request({
							url: this.http.urls.logout,
							success: (res) => {
								uni.removeStorageSync('user');
								uni.$emit('top');
								uni.switchTab({
									url: '/pages/index/index'
								});
							}
						});
					}
				}
			});
		}
	}
};
</script>
<style lang="scss">
.main {
	padding: 5px 15px 25px 15px;
	.user {
		overflow: hidden;
		image {
			float: left;
			width: 60px;
			height: 60px;
			border-radius: 50%;
		}
		.con {
			float: left;
			padding-left: 15px;
			.nickName {
				padding-top: 5px;
			}
			.welcome {
				font-size: 13px;
				padding-top: 5px;
				color: #989898;
			}
		}
		.icon {
			float: right;
			margin-top: 14px;
		}
	}
	.rows {
		overflow: hidden;
		margin-top: 10px;
		.row {
			float: left;
			width: 33%;
			text-align: center;
			.out {
				.int {
					padding: 5px;
					.num {
						font-weight: bold;
					}
					.desc {
						padding-top: 5px;
						font-size: 14px;
					}
				}
			}
		}
	}
	.mtt {
		margin-top: 10px;
	}
}
</style>
