<template>
	<view class="main">
		<view class="user" @click="go('/pages/user/auth')">
			<image :src="user.avatarUrl ? user.avatarUrl : '../../static/favicon.png'" class="head"></image>
			<view class="con" v-if="user.id">
				<view class="nickName">{{ user.type == 0 ? '个人用户' : '企业用户' }}</view>
				<view class="welcome">
					<text class="icon" v-if="user.isAuthentication == 0">&#xec72;</text>
					<text class="icon" v-else>&#xe607;</text>
					<text>{{ user.isAuthentication == 0 ? '未实名，点击去认证' : '已实名认证' }}</text>
				</view>
			</view>
			<view class="con" v-else>
				<view class="nickName">你还没登录</view>
				<view class="welcome">欢迎使用爱就业咨询服务平台</view>
			</view>
			<view class="icon edit">&#xe62b;</view>
		</view>
		<!--企业用户-->
		<view class="rows" v-if="user.type == 1">
			<view class="row">
				<view class="out">
					<view class="int">
						<view class="num">{{ user.receive || 0 }}</view>
						<view class="desc">收到简历</view>
					</view>
				</view>
			</view>
			<view class="row">
				<view class="out">
					<view class="int">
						<view class="num">{{ user.ask || 0 }}</view>
						<view class="desc">面试邀请</view>
					</view>
				</view>
			</view>
			<view class="row">
				<view class="out">
					<view class="int">
						<view class="num">{{ user.agree || 0 }}</view>
						<view class="desc">面试人数</view>
					</view>
				</view>
			</view>
		</view>
		<!--个人用户-->
		<view class="rows" v-else>
			<view class="row">
				<view class="out">
					<view class="int">
						<view class="num">{{ user.fullTime || 0 }}</view>
						<view class="desc">全职投递</view>
					</view>
				</view>
			</view>
			<view class="row">
				<view class="out">
					<view class="int">
						<view class="num">{{ user.partTime || 0 }}</view>
						<view class="desc">兼职投递</view>
					</view>
				</view>
			</view>
			<view class="row">
				<view class="out">
					<view class="int">
						<view class="num">{{ user.invite || 0 }}</view>
						<view class="desc">面试次数</view>
					</view>
				</view>
			</view>
		</view>
		<!--政务服务-->
		<view class="mtt" style="display: none">政务服务</view>
		<view class="menu" style="display: none">
			<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" @click="go('/pages/job/position/manage/list')">
					<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" @click="go('/pages/user/resume/deliver/receive/index')">
					<view class="out">
						<view class="int">
							<view class="icon" style="background-color: #03a9f4">&#xe627;</view>
							<view class="title">收到简历</view>
							<view class="bage" v-if="user.noRead > 0">{{ user.noRead > 99 ? '99+' : user.noRead }}</view>
						</view>
					</view>
				</view>
				<view class="cd" @click="go('/pages/user/enterprise/index')">
					<view class="out">
						<view class="int">
							<view class="icon" style="background-color: #03a9f4">&#xe646;</view>
							<view class="title">企业信息</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<view v-else>
			<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" @click="go('/pages/user/resume/deliver/invite')">
					<view class="out">
						<view class="int">
							<view class="icon" style="background-color: #4caf50">&#xe605;</view>
							<view class="title">面试邀约</view>
							<view class="bage" v-if="user.accept > 0">{{ user.accept > 99 ? '99+' : user.accept }}</view>
						</view>
					</view>
				</view>
				<view class="cd" @click="go('/pages/user/resume/deliver/list')">
					<view class="out">
						<view class="int">
							<view class="icon" style="background-color: #607d8b">&#xe652;</view>
							<view class="title">投递历史</view>
						</view>
					</view>
				</view>
				<view class="cd" @click="go('/pages/job/position/favorite')">
					<view class="out">
						<view class="int">
							<view class="icon" style="background-color: #ff9800">&#xe626;</view>
							<view class="title">我的收藏</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<view class="mtt">更多功能</view>
		<view class="menu">
			<view class="cd" @click="go('/pages/statement/index/index')">
				<view class="out">
					<view class="int">
						<view class="icon" style="background-color: #03a9f4">&#xe63c;</view>
						<view class="title">结算广场</view>
					</view>
				</view>
			</view>
			<view class="cd" @click="go('/pages/statement/index/index')">
				<view class="out">
					<view class="int">
						<view class="icon" style="background-color: #03a9f4">&#xe6b0;</view>
						<view class="title">通知公告</view>
					</view>
				</view>
			</view>
			<view class="cd">
				<view class="out">
					<button class="int share" open-type="feedback" hover-class="none">
						<view class="icon" style="background-color: #ffc107">&#xe648;</view>
						<view class="title">建议反馈</view>
					</button>
				</view>
			</view>
			<view class="cd">
				<view class="out">
					<button class="int share" open-type="share" hover-class="none">
						<view class="icon" style="background-color: #ff5722">&#xe637;</view>
						<view class="title">分享应用</view>
					</button>
				</view>
			</view>
			<view class="cd">
				<view class="out">
					<button class="int share" open-type="contact" hover-class="none">
						<view class="icon" style="background-color: #8bc34a">&#xe632;</view>
						<view class="title">联系客服</view>
					</button>
				</view>
			</view>
			<view class="cd" @click="go('/pages/other/setting')">
				<view class="out">
					<view class="int">
						<view class="icon" style="background-color: #9e9e9e">&#xe63a;</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.eyJsb2dpbl91c2VyX2tleSI6ImZmMGFmYTBhLTMxYTEtNDQwNi05ZGJhLTFmY2VkOThjZGUwMSJ9.GM13dG-grVsPVjAHamhajix9jKIgkBzMyl1uGT14O_j2AGU_1hvxIxb1ZtlRbJOCkYm9oG4n0u_Kp1w1nmD29g'
			};
			uni.setStorageSync('user', this.user); */

		if (this.hasLogin()) {
			this.getUserInfo();
		} else {
			this.user = {};
		}
	},
	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' });
						return;
					}
				}
			});
		},
		go(url) {
			if (this.hasLogin()) {
				uni.navigateTo({ url: url });
			} else {
				uni.navigateTo({ url: '/pages/user/login' });
			}
		}
	},
	onShareAppMessage: function (res) {
		return {
			title: '爱就业咨询服务平台',
			path: '/pages/index/index',
			imageUrl: '../../static/favicon.png',
			success: (res) => {},
			fail: (res) => {}
		};
	}
};
</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: 14px;
				padding-top: 5px;
				color: #989898;
				.icon {
					padding-right: 3px;
				}
			}
		}
		.edit {
			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>
