<template>
	<view class="page">

		<view class="top">

			<image class="img" :src="baseUrl" @click="chooseImage" ></image>

			<view class="top_right">

				<text class="top_right_text1">{{name}}</text>
				<text class="top_right_text2">{{orgName}}</text>
			</view>

		</view>

		<view class="user-item-bg">
			<UserItem src='https://supervise.yxtsoft.com/img/user/wdxm.png' text="我的项目" @click="click" clickId="0">
			</UserItem>
		</view>

		<!-- 	<view class="user-item-bg">
			<UserItem src='https://supervise.yxtsoft.com/img/user/smxx.png' text="实名信息" notes="完善信息" @click="click" clickId="1"></UserItem>

		</view> -->

		<view class="user-item-bg">
			<UserItem src='https://supervise.yxtsoft.com/img/user/sz.png' text="设置" @click="click" clickId="2">
			</UserItem>
		</view>
		<!-- #ifdef APP-PLUS -->
		<!-- <view class="user-item-bg"> -->
			<!-- <UserItem src='https://supervise.yxtsoft.com/img/user/zzjg.png' text="组织结构" @click="click" clickId="3"></UserItem>
			<UserItem src='https://supervise.yxtsoft.com/img/user/xmgl.png' text="项目管理" @click="click" clickId="4"></UserItem>
			<UserItem src='https://supervise.yxtsoft.com/img/user/ycgl.png' text="云仓管理" @click="click" clickId="5"></UserItem>
			<UserItem src='https://supervise.yxtsoft.com/img/user/xtgl.png' text="系统管理" @click="click" clickId="6"></UserItem> -->
			<!-- <UserItem src='https://supervise.yxtsoft.com/img/user/xtgl.png' text="检查更新" :notes="version" @click="click"
				clickId="7">
			</UserItem> -->
		<!-- </view> -->
		<!-- #endif -->
	</view>
</template>

<script>
	import APPUpdate, {
		getCurrentNo
	} from '../../plugins/APPUpdate/index.js'

	export default {
		data() {
			return {
				baseUrl: "",
				name: "",
				orgName:"",
				version: ""
			};
		},
		onLoad() {
			/*  #ifdef APP-PLUS */
			let that = this;
			getCurrentNo(version => {
				that.version = version.version
				console.log("version", version)
				console.log("qqqq", that.version)
			})

			/* #endif */
		},
		onShow() {

			console.log('onShow', getApp().globalData.isLogin)

			let token = uni.getStorageSync("Global-Auth-Token")
			if (token != null && token.length != 0) {
				getApp().globalData.token = token
			}
			let isLogin = uni.getStorageSync("isLogin")
			if (isLogin != null && isLogin == 1) {
				getApp().globalData.isLogin = isLogin
			}
			let sid = uni.getStorageSync("sid")
			if (sid != null && sid.length != 0) {
				getApp().globalData.sid = sid
			}

			console.log('用户Sid', getApp().globalData.sid)
			console.log('token', getApp().globalData.token)
			console.log('是否登陆', getApp().globalData.isLogin)

			// setTimeout(() => {
			if (getApp().globalData.isLogin) {
				var userSid = getApp().globalData.sid
				var headImage = getApp().globalData.headImage
				var username = getApp().globalData.username
				var orgNamePath = getApp().globalData.orgNamePath
				console.log(">>>>>", userSid)
				console.log(">>>>>",  headImage)
				console.log(">>>>>", username)
				console.log(">>>>>", orgNamePath)
				
				this.name = username==""?"用户名称":username
				this.orgName = orgNamePath==""?"暂无部门信息":orgNamePath
				this.baseUrl = headImage==""?"https://supervise.yxtsoft.com/img/user/userImage.png":headImage
				
				
				// this.getData(userSid, true)
				// uni.setTabBarBadge({ //显示数字
				// 	index: 0, //tabbar下标
				// 	text: '100' //数字
				// })
			} else {

				/*  #ifdef  MP-WEIXIN */
				this.WxSilentLogin()
				/* #endif */

				/*  #ifdef APP-PLUS */
				uni.redirectTo({
					url: '../login/login'
				})
				/* #endif */
			}

		},
		methods: {
			chooseImage(){
				uni.navigateTo({
					url: '../index/SetUp2'
				});
			},
			click(id) {
				
				switch (id) {
					case "0":
						uni.navigateTo({
							url: '../index/MyProject'
						});
						break;
					case "1":
						break;
					case "2":
						uni.navigateTo({
							url: '../index/SetUp'
						});
						
						// uni.navigateTo({
						// 	url: '../index/DeviceException?sid=994d75b6-eb29-4733-bd48-dcfdf9f7dd47'
						// });
						break;
					case "3":
						break;
					case "4":
						break;
					case "5":
						break;
					case "6":
						break;
					case "7":
						APPUpdate(true);
						break;
				}
			},

		}
	}
</script>

<style lang="scss">
	.page {
		width: 100%;
		height: 100%;

		.top {
			display: flex;
			flex-direction: row;
			align-items: center;
			padding:15px 25px;

			.img {
				margin-top: 10px;
				margin-left: 10px;
				width: 60px;
				height: 60px;
				border-radius: 5px;
			}

			.top_right {
				margin-top: 10px;
				flex: 1;
				margin-left: 20px;
				display: flex;
				flex-direction: column;

				.top_right_text1 {
					width: 100%;
					font-size: 20px;
					font-weight: 800;
					font-family: sans-serif;
					overflow: hidden;
					text-overflow: ellipsis;
					display: -webkit-box;
					-webkit-line-clamp: 1;
					-webkit-box-orient: vertical;

				}

				.top_right_text2 {
					margin-top: 5px;
					font-size: 15px;
				}

			}
		}

		.user-item-bg {
			background-color: #FFFFFF;
			margin-top: 26rpx;
		}

	}
</style>