<template>
	<view>
		<view class="top-content ">
			<view class="status_bar" :style="{height: statusBarHeight+'px'}"></view>
			<!-- 这里是状态栏 -->
			<view class="top-title">我的</view>
		</view>
		<view class="user-cont" :style="{marginTop: `calc(${statusBarHeight}px + 88rpx)`}">
			<view class="user-box" v-if="user!=null">
				<view class="left">
					<u-avatar :src="user.avatar" size="50"></u-avatar>
					<view class="user" >
						<view class="username">{{user.nickName}}</view>
						<view class="account">{{user.email}}</view>
					</view>
				</view>
			</view>
			<view class="company" v-if="user!=null">
				<image src="https://fbylive.obs.cn-southwest-2.myhuaweicloud.com:443/app/images/icon_comp.png"></image>
				<view class="name">{{user.createBy||'暂无数据'}}</view>
			</view>
		</view>
		<view class="p20">
			<view class="menu-box" style="margin-top: -40rpx;">
				<view class="title-box">
					<image class="icon" src="https://fbylive.obs.cn-southwest-2.myhuaweicloud.com:443/app/manergevip/chang.png"></image>
					<view class="title">常用功能</view>
				</view>
				<view class="line"></view>
				<view class="menus">
					<view class="menu-item" @click="navTo()">
						<image src="https://fbylive.obs.cn-southwest-2.myhuaweicloud.com:443/app/images/menu_info.png"></image>
						<view class="m-name">销售管理</view>
					</view>
			 	</view>
			</view>
		</view>
		<view class="p20">
			<view class="btn-box" >
				<view class="sub-btn" @click="this.show=!this.show">退出登录</view>
			</view>
		</view>
		<u-modal :show="show" @confirm="showLogout" :title="title" :content='content' :showCancelButton="true"
		@cancel='this.show=!this.show'></u-modal>
		<tabbar :actindex="1"></tabbar>
	</view>
</template>

<script>
	import tabbar from '@/components/tabbar/tabbar.vue'
	import { getwxuser } from '@/api/user.js'
	export default {
		components: {
			tabbar
		},
		data() {
			return {
				statusBarHeight: uni.getSystemInfoSync().statusBarHeight,
				user:[],
				show:false,
				title:'提示',
				content:'确认退出吗？'
			}
		},
		onShow() {
			this.getCompanyUsers()
		},
		methods: {
			showLogout(){
				uni.removeStorageSync('UserToken')
				uni.removeStorageSync('userInfo')
				uni.navigateTo({
					url:'/pages/auth/wxlogin'
				})
			},
			navTo(url){
				if(uni.getStorageSync('AppToken')){
					uni.switchTab({
						url:'/pages/index/index'
					})
				}else{
					uni.navigateTo({
						url:'/pages/auth/login'
					})
				}
				
			},
			getCompanyUsers(){
				var data = {
				};
				getwxuser(data).then(res => {
					if(res.code==200){
						this.user=res.user;
					}else{
						
					}
				});
			},
		}
	}
</script>

<style scoped lang="scss">
.top-content {
	width: 100%;
	z-index: 10;
	position: fixed;
	top: 0;
	left: 0;
	background-color: #FFFFFF;
	.top-title {
		height: 88rpx;
		line-height: 88rpx;
		font-size: 42rpx;
		font-family: Source Han Sans CN;
		font-weight: bold;
		color: #222222;
		padding-left: 41rpx;
		background-color: #FFFFFF;
	}
}
.menu-box{
	box-shadow: 0px 0px 5px 2px rgba(0,0,0,0.05);
	width: 100%;
	margin-top: 30rpx;
	padding: 30rpx;
	background-color: #fff;
	border-radius: 15rpx;
	.title-box{
		display: flex;
		align-items: center;
		justify-content: flex-start;
		.icon{
			width: 40rpx;
			height:40rpx;
		}
		.title{
			margin-left: 10rpx;
			font-size: 28rpx;
			font-family: PingFang SC;
			color: #111;
		}
	}
	.line{
		margin-top: 15rpx;
		height: 0.5rpx;
		width: 100%;
		background-color: #efefef;
	}
	.menus{
		margin-top: 30rpx;
		display: flex;
		align-items: center;
		justify-content: flex-start;
		flex-wrap: wrap;
	}
	.menu-item{
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		width: 25%;
		margin-bottom: 20rpx;
		image{
			width:60rpx;
			height:60rpx;
		}
		.m-name{
			margin-top: 10rpx;
			font-size: 24rpx;
			font-family: PingFang SC;
			color: #111;
		}
	}
	
}
.user-cont{
	// box-shadow: 0px 0px 5px 2px rgba(0,0,0,0.05);
	background: linear-gradient(to bottom, #dae9ff, #e1e1fd);
	    border-radius: 0px 0px 30px 30px;
	padding: 30rpx;
	// background-color: #fff;
	border-radius: 15rpx;
	.user-box{
		width: 100%;
		display: flex;
		align-items: center;
		justify-content: flex-start;
		.left{
			flex:1;
			display: flex;
			align-items: center;
			justify-content: flex-start;
			image{
				border-radius: 50%;
				width:120rpx;
				height:120rpx;
			}
			.user{
				margin-left: 20rpx;
				width: calc(100% - 140rpx);
				display: flex;
				flex-direction: column;
				align-items: flex-start;
				justify-content: flex-start;
				.username{
					font-size: 38rpx;
					font-family: PingFang SC;
					color: #111;
					font-weight: bold;
				}
				.account{
					padding: 5rpx 0rpx;
					border-radius: 30rpx;
					margin-top: 20rpx;
					font-size: 24rpx;
					font-family: PingFang SC;
					color: #515151;
				}
			}
		}
	}
	.company{
		margin-top: 30rpx;
		display: flex;
		align-items: center;
		justify-content: flex-start;
		image{
			width:40rpx;
			height:40rpx;
		}
		.name{
			margin-left: 15rpx;
			font-size: 28rpx;
			color: #111;
		}
	}
}
.btn-box{
		margin: 30rpx 0rpx 30rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		.sub-btn{
			box-shadow: 0px 0px 5px 2px rgba(0,0,0,0.05);
			border: 1rpx solid #f8f8f8;
			background: #FFFFFF;
			width: 100%;
			border-radius: 10rpx;
			height: 88upx;
			line-height: 88upx;
			text-align: center;
			font-size: 30upx;
			font-family: PingFang SC;
			color: #2979ff;
		}
	}
</style>
