<template>
	<div class="center">
		<!-- 用户信息 -->
		<div class="user-info">
			<div class="user-box">
				<div class="user-img">
					<image :src="userInfo.headImage" mode="aspectFill"></image>
				</div>
				<div class="base">
					<div class="user-name" v-if="userInfo.auth">{{ userInfo.auth.name }}</div>
					<!-- <div class="user-project">高新区项目一队项目1</div> -->
					<view class="user-project" v-if="userInfo.team">{{ userInfo.team.name }}</view>
				</div>
			</div>
			<image class="user-bg"
				src="/static/image/center/1.png" mode="widthFix">
			</image>
		</div>

		<!-- 菜单 -->
		<div class="menus">
			<uv-cell-group :border="false">
				<uv-cell @click="clickMenu(1)" title="打卡记录" isLink arrow-direction="right" center>
					<template v-slot:icon>
						<image style="width: 30rpx;height: 30rpx;"
							src="/static/image/center/2.png"
							mode="aspectFill"></image>
					</template>
				</uv-cell>
				<uv-cell @click="clickMenu(2)" icon="setting-fill" isLink arrow-direction="right" title="实名认证" center>
					<template v-slot:icon>
						<image style="width: 30rpx;height: 30rpx;"
							src="/static/image/center/2.png"
							mode="aspectFill"></image>
					</template>
				</uv-cell>
				<uv-cell @click="$store.commit('logout')" icon="setting-fill" isLink arrow-direction="right"
					title="退出登录" center>
					<template v-slot:icon>
						<image style="width: 30rpx;height: 30rpx;"
							src="/static/image/center/3.png"
							mode="aspectFill"></image>
					</template>
				</uv-cell>
				<uv-cell @click="clickMenu" icon="integral-fill" title="版本" value="版本1.0" center>
					<template v-slot:icon>
						<image style="width: 30rpx;height: 30rpx;"
							src="/static/image/center/4.png"
							mode="aspectFill"></image>
					</template>
				</uv-cell>
				<uv-cell @click="setting" 
				v-if="userInfo.adminFlag"
				icon="integral-fill" title="项目管理" isLink center>
					<template v-slot:icon>
						<image style="width: 30rpx;height: 30rpx;"
							src="/static/image/center/4.png"
							mode="aspectFill"></image>
					</template>
				</uv-cell>
			</uv-cell-group>
		</div>

		<tabbar :select="1"></tabbar>
	</div>
</template>

<script>
	import tabbar from '../../components/base/tabbar.vue'
	import {
		mapState
	} from 'vuex'
	export default {
		name: "Center",
		components: {
			tabbar
		},
		data() {
			return {

			}
		},
		onShow() {
			this.$store.commit('getUserInfo')
		},
		computed: {
			...mapState(['teamList', 'userInfo']),
		},
		methods: {
			clickMenu(index) {
				if (index == 1) {
					uni.navigateTo({
						url: "/pages/subPack/record/record"
					})
				} else if (index == 2) {
					uni.navigateTo({
						url: "/pages/subPack/autonym/autonym"
					})
				}
			},
			setting(){
				// 美国纽约 42.6511674, -73.754968
				// uni.chooseLocation({
				// 	latitude: 73.754968,
				// 	longitude: 42.6511674,
				// 	success(res) {
				// 		uni.showModal({
				// 			title: JSON.stringify(res)
				// 		})
				// 	}
				// })
				
				uni.navigateTo({
					url: '/pages/subPack/projectManage/projectManage'
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.center {

		// 用户信息
		.user-info {
			display: flex;
			align-items: center;
			position: relative;
			height: 325rpx;
			overflow: hidden;
			padding-top: var(--status-bar-height);

			.user-box {
				display: flex;
				width: 90%;
				position: absolute;
				left: 50%;
				transform: translateX(-50%);
				z-index: 10;
				color: white;

				.user-img {
					width: 130rpx;
					height: 130rpx;
					overflow: hidden;

					image {
						width: 130rpx;
						height: 130rpx;
						border-radius: 20rpx;
					}
				}

				.base {
					width: calc(100% - 150rpx);
					display: flex;
					flex-direction: column;
					justify-content: space-around;
					box-sizing: border-box;
					padding: 10rpx 0rpx 10rpx 10rpx;

					.user-name {
						font-size: 36rpx;
					}

					.user-project {
						font-size: 30rpx;
					}
				}
			}

			.user-bg {
				width: 750rpx;
				position: absolute;
				left: 0;
				top: 0;
			}
		}

		// 菜单
		.menus {
			width: 90%;
			margin: 0rpx auto;
		}
	}
</style>