<template>
	<view style="height: 100vh; width: 100vw; background-color: #eee;">
		<view class="home">
			<!-- 个人信息 -->
			<u-toast ref="uToast"></u-toast>
			
			<u-toast ref="uToast1"></u-toast>
			
		<view class="infoUser">
			<view class="logo">
				<img  :src="imgSrc" alt="" />
			</view>
			
			<view class="box-title">
				<span class="box-title1">手机号：{{userInfo.phone || ''}}</span>	
				<view class="box-view" style="margin-top: 20rpx;">
					<span v-if="userInfo.hospital">{{userInfo.hospital || ''}}</span>
					<span v-if="userInfo.type === 1">操作人员</span>
					<span v-if="userInfo.type === 2">跟车人员</span>
				</view>
			</view>
		</view>
		
		<!-- 智能建档 地图导航 -->
		<view class="box-function">
			<view class="box1" @click="getpack">
				<img src="/static/zhineng.png" alt="" />
				<view>
					<view>智能建档</view>
					<view style="font-size: 24rpx;">一键上传患者信息</view>
				</view>
			</view>
			<view class="box2" @click="getpackList">
				<img src="/static/ditu.png" alt="" />
				<view>
					<view>地图导航</view>
				</view>
			</view>
		</view>
			<CustomTabbar></CustomTabbar>
		</view>
	</view>
</template>

<script>
import CustomTabbar from '@/components/CustomTabbar.vue';
 import {request,BASE_UL} from '../../request/request.js'
 
	export default {
		components:{
			CustomTabbar
		},
		data(){
			return{
				userInfo:{
					
				},
				icon1:'https://thirdwx.qlogo.cn/mmopen/vi_32/POgEwh4mIHO4nibH0KlMECNjjGxQUq24ZEaGT4poC6icRiccVGKSyXwibcPq4BWmiaIGuG1icwxaQX6grC9VemZoJ8rg/132',
				imgSrc:'', // 图片
				show:false,
				getfirstList:[],
				patientForm:{}
			}
		},

		mounted() {
			this.getInfoList()	
			this.getPatient()
			this.getfirstList1()
		},
		 onShow() {

		},
		methods:{
			onPullDownRefresh(){
				// 在页面显示时触发的逻辑，可以在这里更新数据
				this.getPatient()
				this.getInfoList()
				this.getfirstList1()
				  // 数据加载完毕后，停止下拉刷新动画
				    setTimeout(() => {
				      uni.stopPullDownRefresh();
				    }, 1000);
				},
					//获取急救列表
					async getfirstList1(){
						this.getfirstList = await request({url:'/dispatchOrder'})
					},
					async	getPatient	(){
					const res = await request({url:'/patient'})
					this.patientForm = res
					},
			// 跳转页面
			getpack(){
					if(this.patientForm){
						uni.navigateTo({
							url:'/PagesA/Intelligent/index'
						})	
					} else {
						this.$refs.uToast.show({message: '当前没有发布急救任务请发布',type: 'error',});
					}	
			},
		getpackList(){
			if(this.getfirstList.length === 0 ){
			this.$refs.uToast.show({message: '当前还没有正在进行的急救任务',type: 'error',});	
			}else {
			uni.navigateTo({
				url:'/PagesA/mapLIst/map'
			})
			}
		
		},

			// 获取个人信息
		async getInfoList(){
		    const res = await request({url:'/user/info'})
			this.userInfo = res
			this.setImage(res.icon)
		},
	// 查看图片是否可以链接
		setImage(icon){
		   // 获取图片信息
			uni.getImageInfo({
				src: icon,
				success: (res) => {
				// 判断是否是微信默认图片
				        if (icon === this.icon1 ) {
				            // 将默认图片路径赋值给imgSrc，用于显示默认图片
				            this.imgSrc = '/static/doctor.png';
				        } else {
							// 将获取到的图片路径赋值给imgSrc，用于显示图片
							this.imgSrc = icon;
				}
				},
				fail: () => {

					// 示例：将默认图片路径赋值给imgSrc，用于显示默认图片
					this.imgSrc = '/static/doctor.png';
			
				}
			});
		},
		}
	}
</script>

<style scoped lang="scss">
	.home{
		overflow-x: hidden;
		width: 100vw;
		// height: 100%;
		background: linear-gradient(to bottom, #418FF9, #4175F9,#e6ecf4);
		padding-top:20rpx ;
		padding-bottom: 20rpx;
	}
	.infoUser{
		margin: 0 30rpx;
		display: flex;
		align-items: center;
		.box-title{
			color: #FFFFFF;
			.box-title1{
				font-size: 32rpx;
			}
			.box-view{
				span {
					width: 256rpx;
					height: 33rpx;
					background: rgba(255,255,255,.2);
					border-radius: 17rpx 17rpx 17rpx 17rpx;
					font-size: 24rpx;
					padding: 10rpx;
					margin-right: 10rpx;
				}
			}
		}
	}
	
  .infoUser	.logo{
	  
		width: 134rpx;
		height: 134rpx;
		border-radius: 50%;
		background: #FFFFFF;	
		display: flex;
		align-items: center;
		justify-content: center;
		margin-right: 30rpx;
		 img{
			width: 134rpx;
			height: 134rpx;
			border-radius: 50%;
		 }
	}
	
	.box-function{
		width: 690rpx;
		height: 210rpx;
		background: #FFFFFF;
		border-radius: 20rpx 20rpx 20rpx 20rpx;
		margin: 40rpx 30rpx;
		margin-top: 80rpx;
		
		display: flex;
		justify-content:space-evenly;
		align-items: center;
		.box1 ,.box2{
			width: 311rpx;
			height: 131rpx;
			background: #F5F9FD;
			display: flex;
			justify-content:space-evenly;
			align-items: center;
			img {
				width: 80rpx;
				height: 80rpx;
			}
			
			view{
				font-family: SourceHanSansSC, SourceHanSansSC;
				font-weight: 400;
				font-size: 28rpx;
				color: #272726;
				line-height: 36rpx;
				text-align: left;
				font-style: normal;
				text-transform: none;
			}
		}

	}
</style>