<template>
	<view  class="column">
		<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 v-if="!usertoken" class="fs40 bold" @click="loginto" >
							立即登录
						</view>
						<view class="username">{{user}}</view>
					</view>
				</view>
			</view>
			
			<view class="company" v-if="user!=null">
				<image :src="imgPath+'/app/images/icon_comp.png'"></image>
				<view class="name">{{'暂无数据'}}</view>
			</view>
		</view>
		<view class="p20">
			<view class="menu-box" style="margin-top: -40rpx;">
				<view class="title-box">
					<image class="icon" :src="imgPath+'/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="imgPath+'/app/images/menu_info.png'"></image>
						<view class="m-name">销售管理</view>
					</view>
			 	</view>
			</view>
		</view>
		<view class="p20">
			<view class="btn-box" v-if="usertoken">
				<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>
	</view>
</template>

<script>
	import { getwxuser } from '@/api/user.js'
	export default {
		data() {
			return {
				statusBarHeight: uni.getSystemInfoSync().statusBarHeight,
				user:[],
				show:false,
				title:'提示',
				content:'确认退出吗？',
				usertoken:''
			}
		},
		mounted() {
			this.usertoken=uni.getStorageSync('AppToken_MYfby')
			this.user=uni.getStorageSync('phoneNumber')
		},
		computed: {
		    imgPath() {
		      return this.$store.state.imgpath
		    }
		  },
		methods: {
			loginto(){
				uni.navigateTo({
					url:'/pages/auth/wxlogin'
				})
			},
			showLogout(){
				uni.removeStorageSync('AppToken_MYfby')
				// uni.removeStorageSync('AppToken_MYfby')
				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'
					})
				}
				
			},
		}
	}
</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{
	background: linear-gradient(to bottom, #dae9ff, #e1e1fd);
	    border-radius: 0px 0px 30px 30px;
	padding: 30rpx;
	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>
