<template>
	<view class="main">
		<view class="user" @click="go('/pages/user/info')">
			<image :src="user.avatarUrl ? user.avatarUrl : '../../static/favicon.png'" class="head"></image>
			<view class="con" v-if="user.token">
				<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="cmd">
			<view class="s_item" @click="go('/pages/authentication/index')">
				<text class="icon ic">&#xe600;</text>
				<text class="title">我的认证</text>
				<text class="icon arrow">&#xe62b;</text>
			</view>
			<view class="s_item" @click="go('/pages/activity/up')">
				<text class="icon ic">&#xe6ed;</text>
				<text class="title">我的签约</text>
				<text class="icon arrow">&#xe62b;</text>
			</view>
			<view class="s_item" @click="go('/pages/goods/order')">
				<text class="icon ic">&#xe623;</text>
				<text class="title">关联企业</text>
				<text class="icon arrow">&#xe62b;</text>
			</view>
			<view class="s_item" @click="go('/pages/notice/index')">
				<text class="icon ic">&#xe604;</text>
				<text class="title">我的接包</text>
				<text class="icon arrow">&#xe62b;</text>
			</view>
		</view>
	</view>
</template>
<script>
export default {
	data() {
		return {
			user: {}
		};
	},
	onShow() {
/* 		  this.user = {
			token: 'eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6IjI2NTFjMmU4LTAxNzEtNDQwYS04YjA2LTcwOWI3N2ZhNGZiZCJ9.zb2gQaeHZApJkbo4LoSeZfnVVsJJ-QabY7FnsVn13Kf1KUgKeBQ82bwhzD-CqchI1dhUOQFoVh__zeJaJHFWGg'
		};
		uni.setStorageSync('user', this.user); */
		if (this.hasLogin()) {
			this.user = this.getUser();
		}
	},
	methods: {
		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: 20px;
}
.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;
	}
}
.exit {
	width: 40%;
	margin-top: 20px;
}
</style>
