<template name="components">
	<view>
		<scroll-view scroll-y class="page">
		  <view class="UCenter-bg">
		    <view class="photoView">
				<view class="photoImage">
					<open-data type="userAvatarUrl"></open-data>
				</view>
			</view>
		    <view class="text-xl">{{name}}
		    </view>
		    <view class="margin-top-sm">
		      <text>{{duty}}</text>
		    </view>
		    <!--<image src="https://raw.githubusercontent.com/weilanwl/ColorUI/master/demo/images/wave.gif" mode="scaleToFill" class="gif-wave"></image>-->
		  </view>
		  <!-- 今日数据统计 -->
		  <view class="stats-container">
		    <view class="stat-card stat-count">
		      <view class="stat-icon">📊</view>
		      <view class="stat-value">{{myBasisInfo.today_count}}</view>
		      <view class="stat-label">今日数量</view>
		    </view>
		    <view class="stat-card stat-weight">
		      <view class="stat-icon">⚖️</view>
		      <view class="stat-value">{{myBasisInfo.today_sum}}</view>
		      <view class="stat-label">今日重量</view>
		    </view>
		    <view class="stat-card stat-abnormal">
		      <view class="stat-icon">⚠️</view>
		      <view class="stat-value">{{myBasisInfo.today_abnormal}}</view>
		      <view class="stat-label">今日异常</view>
		    </view>
		  </view>
		  <view class="cu-list menu card-menu margin-top-xl margin-bottom-xl shadow-lg radius">
			<view class="cu-item arrow">
			  <navigator class="content" url="/pages/main/inventory" hover-class="none">
			    <text class="cuIcon-deletefill text-blue"></text>
			    <text class="text-grey">科室汇总</text>
			  </navigator>
			</view>
			<!-- <view class="cu-item arrow">
			  <navigator class="content" url="/pages/main/warning" hover-class="none">
			    <text class="cuIcon-warnfill text-cyan"></text>
			    <text class="text-grey">异常预警</text>
			  </navigator>
			</view> -->
			<view class="cu-item arrow">
			  <navigator class="content" url="/pages/plugin/handList" hover-class="none">
			    <text class="cuIcon-selectionfill text-blue"></text>
			    <text class="text-grey">交接列表</text>
			  </navigator>
			</view>
		    <view class="cu-item arrow">
		      <navigator class="content" url="/pages/plugin/personalInformation" hover-class="none">
		        <text class="cuIcon-myfill text-blue"></text>
		        <text class="text-grey">个人信息</text>
		      </navigator>
		    </view>
			<view class="cu-item arrow">
			  <navigator class="content" hover-class="none" @click="buttonClick">
			    <text class="cuIcon-myfill text-blue"></text>
			    <text class="text-grey">退出登录</text>
			  </navigator>
			</view>
		  </view>
		  <view class="cu-tabbar-height"></view>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				myBasisInfo: [],
				hospital: '',
				sortHospital: '',
				department: '',
				name: '',
				duty: ''
			}
		},
		mounted(){
			// console.info(getApp().globalData.openid)
			// if(getApp().globalData.openid == '' || getApp().globalData.openid == undefined){
			// 	uni.reLaunch({
			// 		url: '/pages/register/registerRegulatory'
			// 	})
			// }
			// 获取全局变量中的数据
			this.hospital = getApp().globalData.hospital
			this.sortHospital = getApp().globalData.sortHospital
			this.department = getApp().globalData.department
			this.name = getApp().globalData.name
			this.duty = getApp().globalData.duty
			this.getMyBasisInfo()
		},
		methods:{
			getMyBasisInfo(){
				let that = this;
				uni.request({
					url: 'https://lekapi.opmonitor.com/?c=app_api&a=getMyBasisInfo',
					data: {hospital: that.hospital, sortHospital: that.sortHospital, department: that.department, duty: that.duty},
					header: {
						'Content-type': 'application/json'
					},
					success: function(res){
						that.myBasisInfo = res.data.data
					},
					fail: () => {
						console.info('小程序域名不正确，请检查域名的正确性')
					}
				})
			},
			buttonClick(){
				console.info(getApp().globalData)
				uni.reLaunch({
					url: '/pages/register/login'
				})
				// 将数据库中的数据清空
				// let that = this;
				// uni.request({
				// 	url: 'https://lekapi.opmonitor.com/?c=app_api&a=clearData',
				// 	data: {openid: getApp().globalData.openid},
				// 	header: {
				// 		'Content-type': 'application/json'
				// 	},
				// 	success: function(res){
				// 		// 将globalData清空并刷新
				// 		getApp().globalData.openid = ''
				// 		console.info(getApp().globalData)
				// 		// 跳转到首页
				// 		uni.reLaunch({
				// 			url: '/pages/plugin/home'
				// 		})
				// 	},
				// 	fail: () => {
				// 		console.info('小程序域名不正确，请检查域名的正确性')
				// 	}
				// })
				
			}
		}
	}
</script>

<style>
	.page {
		width: 100vw;
		height: 100Vh;
	}
	
	.UCenter-bg {
	  background:-webkit-linear-gradient(right,#4a90e2,#357abd);
	  background-size: cover;
	  height: 550rpx;
	  display: flex;
	  justify-content: center;
	  padding-top: 40rpx;
	  overflow: hidden;
	  position: relative;
	  flex-direction: column;
	  align-items: center;
	  color: #fff;
	  font-weight: 300;
	  text-shadow: 0 0 3px rgba(0, 0, 0, 0.3);
	}
	
	.UCenter-bg text {
	  opacity: 0.8;
	}
	
	.UCenter-bg image {
	  width: 200rpx;
	  height: 200rpx;
	}
	
	.UCenter-bg .gif-wave{
	  position: absolute;
	  width: 100%;
	  bottom: 0;
	  left: 0;
	  z-index: 99;
	  mix-blend-mode: screen;  
	  height: 100rpx;   
	}
	
	map,.mapBox{
	  left: 0;
	  z-index: 99;
	  mix-blend-mode: screen;  
	  height: 100rpx;   
	}
	
	map,.mapBox{
	  width: 750rpx;
	  height: 300rpx;
	}
	
	.png1 {
		border-radius: 50%;
	}
	
	.box {
		margin: 20upx 0;
	}
	
	.photoView {
			padding-top: 100rpx;
			position: relative;
			color: #fff;
			display: flex;
			flex-direction: column;
			align-items: center;
		}
		.photoImage {
			overflow:hidden;
			display: block;
			width: 200rpx;
			height: 200rpx;
			margin: 20rpx;
			border-radius: 50%;
			border: 2px solid #fff;
			box-shadow: 3px 3px 10px rgba(0, 0, 0, 0.2);
		}

	/* 统计数据容器 */
	.stats-container {
		display: flex;
		justify-content: space-around;
		padding: 40rpx 20rpx;
		margin: -80rpx 30rpx 30rpx 30rpx;
		background: rgba(255, 255, 255, 0.95);
		border-radius: 24rpx;
		box-shadow: 0 8rpx 32rpx rgba(0, 0, 0, 0.12);
		position: relative;
		z-index: 10;
		backdrop-filter: blur(10rpx);
		border: 1px solid rgba(255, 255, 255, 0.6);
	}

	/* 统计卡片 */
	.stat-card {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		padding: 24rpx 20rpx;
		border-radius: 20rpx;
		width: 200rpx;
		position: relative;
		overflow: hidden;
		transition: all 0.3s ease;
	}

	.stat-card::before {
		content: '';
		position: absolute;
		top: -50%;
		right: -50%;
		width: 100%;
		height: 100%;
		background: radial-gradient(circle, rgba(255,255,255,0.2) 0%, transparent 70%);
		border-radius: 50%;
	}

	/* 今日数量卡片 */
	.stat-count {
		background: linear-gradient(135deg, #4a90e2 0%, #357abd 100%);
		box-shadow: 0 6rpx 24rpx rgba(74, 144, 226, 0.35);
	}

	.stat-count .stat-icon {
		font-size: 44rpx;
		margin-bottom: 8rpx;
		filter: drop-shadow(0 2rpx 8rpx rgba(0, 0, 0, 0.15));
	}

	.stat-count .stat-value {
		font-size: 48rpx;
		font-weight: 800;
		color: #fff;
		margin-bottom: 6rpx;
		text-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.2);
	}

	.stat-count .stat-label {
		font-size: 24rpx;
		color: rgba(255, 255, 255, 0.85);
		font-weight: 500;
	}

	/* 今日重量卡片 */
	.stat-weight {
		background: linear-gradient(135deg, #27ae60 0%, #1e8449 100%);
		box-shadow: 0 6rpx 24rpx rgba(39, 174, 96, 0.35);
	}

	.stat-weight .stat-icon {
		font-size: 44rpx;
		margin-bottom: 8rpx;
		filter: drop-shadow(0 2rpx 8rpx rgba(0, 0, 0, 0.15));
	}

	.stat-weight .stat-value {
		font-size: 48rpx;
		font-weight: 800;
		color: #fff;
		margin-bottom: 6rpx;
		text-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.2);
	}

	.stat-weight .stat-label {
		font-size: 24rpx;
		color: rgba(255, 255, 255, 0.85);
		font-weight: 500;
	}

	/* 今日异常卡片 */
	.stat-abnormal {
		background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
		box-shadow: 0 6rpx 24rpx rgba(231, 76, 60, 0.35);
	}

	.stat-abnormal .stat-icon {
		font-size: 44rpx;
		margin-bottom: 8rpx;
		filter: drop-shadow(0 2rpx 8rpx rgba(0, 0, 0, 0.15));
	}

	.stat-abnormal .stat-value {
		font-size: 48rpx;
		font-weight: 800;
		color: #fff;
		margin-bottom: 6rpx;
		text-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.2);
	}

	.stat-abnormal .stat-label {
		font-size: 24rpx;
		color: rgba(255, 255, 255, 0.85);
		font-weight: 500;
	}
</style>
