<template>
	<view class="top-cont">
		<view class="content">
			<view class="user-info">
				<view class="left">
					<view class="name-phone">
						<view class="name" v-if="user!=null">{{user.nickName}}</view>
						<view class="phone" v-if="user!=null">{{$parsePhone(user.phonenumber)}}</view>
					</view>
				</view>
				<view class="msg-box"  v-if="user!=null" >
					 {{user.deptName}}
				</view>
			</view>
			<!-- 常用工具 -->
			<view class="used-tools">
				<view class="title">常用工具</view>
				<view class="tools-list">
					<view class="item"  @click="navTo('/pages_company/couponList?isShare=1&couponType=5')">
						<image src="https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/shop/image/icon_my_coupon.png" mode=""></image>
						<text class="text">私域疗法券</text>
					</view>
					<view class="item"  @click="navTo('/pages_company/couponList?isShare=1&couponType=2')">
						<image src="https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/shop/image/icon_my_coupon.png" mode=""></image>
						<text class="text">中药免单券</text>
					</view>
					<view class="item"  @click="navTo('/pages_company/couponList?isShare=1&couponType=4')">
						<image src="https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/shop/image/icon_my_coupon.png" mode=""></image>
						<text class="text">中药打折券</text>
					</view>
					<view class="item" @click="navTo('/pages_company/packageList')">
						<image src="https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/shop/image/icon_company_2.png" mode=""></image>
						<text class="text">疗法</text>
					</view>
					<view class="item" @click="navTo('/pages_order/inquirySelectType?companyId='+companyId+'&companyUserId='+companyUserId+'&isShare=1')">
					 	<image src="https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/shop/image/icon_company_3.png" mode=""></image>
					 	<text class="text">会诊</text>
					</view>
					<view class="item" @click="navTo('/pages_order/inquirySelect?inquiryType=3&companyId='+companyId+'&companyUserId='+companyUserId+'&isShare=1')">
					 	<image src="https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/shop/image/icon_company_3.png" mode=""></image>
					 	<text class="text">按方开药</text>
					</view>
					<view class="item" @click="navTo('/pages_company/packageOrderList')">
					 	<image src="https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/shop/image/icon_company_3.png" mode=""></image>
					 	<text class="text">套餐订单</text>
					</view>
					<view class="item" @click="navTo('/pages_company/inquiryOrderList')">
					 	<image src="https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/shop/image/icon_company_3.png" mode=""></image>
					 	<text class="text">问诊订单</text>
					</view>
					<view class="item" @click="navTo('/pages_company/storeOrderList')">
					 	<image src="https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/shop/image/icon_company_3.png" mode=""></image>
					 	<text class="text">药品订单</text>
					</view>
					<view class="item" @click="navTo('/pages_user/healthRecords/index')">
						<image src="https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/shop/image/icon_company_3.png" mode=""></image>
						<view class="text">健康档案</view>
					</view>
					<view class="item" @click="navTo('/pages_company/bindInfo')">
					 	<image src="https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/shop/image/icon_company_3.png" mode=""></image>
					 	<text class="text">公司码</text>
					</view>
				</view>
			</view>
			<!-- 退出登录按钮 -->
			<view class="logout" @click="logout">退出登录</view>
		</view>
		
	</view>
</template>

<script>
	import {getUserInfo,getQrImg} from '@/api/companyUser'
	export default {
		data() {
			return {
				companyId:null,
				companyUserId:null,
				user:null,
			};
		},
		onLoad() {
		},
		onShow() {
			this.companyId=uni.getStorageSync('companyId');
			this.companyUserId=uni.getStorageSync('companyUserId');	
			console.log(this.companyUserId)
			this.getUserInfo()
		},
		onShareAppMessage(res) {
			return {
				title: "问诊",
				path: '/pages/TUIKit/TUIPages/TUIConversation/index',
				imageUrl: 'https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/app/newImages/sharelogo.png' //分享图标，路径可以是本地文件路径、代码包文件路径或者网络图片路径.支持PNG及JPG。显示图片长宽比是 5:4
			}
			
		},
		methods: {
			navTo(url){
				uni.navigateTo({
					url: url
				})
			},
			getUserInfo(){
				var data={}
				getUserInfo(data).then(
					res => {
						if(res.code==200){
							  this.user=res.data;
						}
						else{
							uni.setStorageSync('CompanyUserToken',null);
							uni.showToast({
								icon:'none',
								title: res.msg,
							});
							uni.navigateBack({
								delta:-1
							})	
						}
					},
					rej => {}
				);
			},
			logout(){
			 	uni.showModal({
			 		title:"提示",
			 		content:"确认退出登录吗?",
			 		showCancel:true,
			 		cancelText:'取消',
			 		confirmText:'确定',
			 		success:res=>{
			 			if(res.confirm){
			 				uni.setStorageSync('CompanyUserToken',null);
			 				uni.navigateBack({
			 					delta:-1
			 				})							
			 			}else{
			 			}
			 		}
			 	})
			 },
			 
			// 跳转页面
			navgetTo(url) {
				this.$isLogin().then(res => {
					if(res){
						uni.navigateTo({
							url: url
						})
					}
				})
			},
		}
	}
</script>

<style lang="scss">
	.content{
		padding: 20upx;
		.user-info{
			padding: 30upx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			.left{
				position: relative;
				display: flex;
				.head-img{
					width: 120upx;
					height: 120upx;
					border-radius: 50%;
					overflow: hidden;
					margin-right: 30upx;
					border: 4upx solid #FFFFFF;
					box-shadow: 0px 5px 15px 2px rgba(0,0,0,0.1);
					image{
						width: 100%;
						height: 100%;
					}
				}
				.name-phone{
					padding-top: 15upx;
					.name{
						font-size: 36upx;
						font-family: PingFang SC;
						font-weight: bold;
						color: #111111;
						line-height: 1;
					}
					.phone{
						font-size: 28upx;
						font-family: PingFang SC;
						font-weight: 500;
						color: #666666;
						line-height: 1;
						margin-top: 30upx;
					}
				}
			}
			.msg-box{
				padding: 10rpx 20upx;
				font-size: 28upx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #FFFFFF;
				border-radius: 8rpx;
				background-color: #2583EB;
			}
		}
		.used-tools{
			box-sizing: border-box;
			background: #FFFFFF;
			border-radius: 16upx;
			padding: 40upx 30upx;
			
			.title{
				font-size: 32upx;
				font-family: PingFang SC;
				font-weight: bold;
				color: #222222;
				line-height: 1;
			}
			.tools-list{
				margin-top: 50upx;
				display: flex;
				flex-wrap: wrap;
				width: 100%;
				.item{
					box-sizing: border-box;
					width: 25%;
					display: flex;
					flex-direction: column;
					align-items: center;
					justify-content: center;
					margin-bottom: 50upx;
					position: relative;
					image{
						width: 44upx;
						height: 44upx;
					}
					.text{
						font-size: 24upx;
						font-family: PingFang SC;
						font-weight: 500;
						color: #111111;
						line-height: 1;
						margin-top: 20upx;
					}
					.share-btn{
						display: inline-block;
						position: absolute;
						top: 0;
						left: 0;
						width: 100%;
						height: 100%;
						opacity: 0;
					}
				}
			}
		}
		.logout{
			height: 80upx;
			line-height: 80upx;
			text-align: center;
			font-size: 26upx;
			font-family: PingFang SC;
			font-weight: 500;
			color: #666666;
			background: #FFFFFF;
			border-radius: 16upx;
			margin-top: 20upx;
		}
	}
</style>
