<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="padding flex text-center text-grey bg-white shadow-warp">
		    <view class="flex flex-sub flex-direction solid-right">
		      <view class="text-xxl text-green">{{myBasisInfo.today_sum}}</view>
		      <view class="margin-top-sm">今日重量</view>
		    </view>
		    <view class="flex flex-sub flex-direction solid-right">
		      <view class="text-xxl text-blue">{{myBasisInfo.today_count}}</view>
		      <view class="margin-top-sm">今日数量</view>
		    </view>
		    <view class="flex flex-sub flex-direction">
		      <view class="text-xxl text-red">{{myBasisInfo.today_abnormal}}</view>
		      <view class="margin-top-sm">今日异常</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-cyan"></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-cyan"></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-cyan"></text>
		        <text class="text-grey">个人信息</text>
		      </navigator>
		    </view>
		    <view class="cu-item arrow">
		      <navigator class="content" url="/pages/plugin/about" hover-class="none">
		        <text class="cuIcon-medalfill text-cyan"></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-cyan"></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)
				
				// 将数据库中的数据清空
				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,#15D2BB,#2CC9E9);
	  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);
		}
</style>
