<template>
	<view class="app">
		<image class="circular" :src="beijingurl" mode=""></image>
		<view class="user" v-if="Personallist">
			<image class="img" :src="baseurl+Personallist.avatar" mode=""></image>
			<view class="phone" v-if="Personallist.nursePersonName">
				{{Personallist.nursePersonName}}
			</view>
			<view class="nickname" style="top:245rpx" v-if="Personallist.phone">
				{{Personallist.phone}}
			</view>
			<view class="nickname" v-if="Personallist.evaluateStarCount>=0">
				<u-rate :count="5" v-model="Personallist.evaluateStarCount" disabled active-color='#F4EA2A'></u-rate>
			</view>
			<view class="modify" @tap='goModifyinformation'>
				<image src="../../static/xg.png" mode="" style="padding-right: 15rpx;"></image>
				修改信息
			</view>
		</view>
		<view class="user" v-else>
			<image class="img" src="../../static/user.png" mode=""></image>
			<view class="login" @tap='gologin'>
				登录
			</view>
		</view>
		<view class="topitems">
			<view class="topitem" @tap="tapstatus('ONLINE')">
				<image src="../../static/kaishi2.png" mode="" v-if="Personallist.workStatus=='ONLINE'"></image>
				<image src="../../static/kaishi.png" mode="" v-else></image>
				<view class="">
					在线
				</view>
			</view>
			<view class="topitem" @tap="tapstatus('BE_BUSY')">
				<image src="../../static/manglu2.png" mode="" v-if="Personallist.workStatus=='BE_BUSY'"></image>
				<image src="../../static/manglu.png" mode="" v-else></image>
				<view class="">
					忙碌
				</view>
			</view>
			<view class="topitem" @tap="tapstatus('OFFLINE')">
				<image src="../../static/lixian2.png" mode="" v-if="Personallist.workStatus=='OFFLINE'"></image>
				<image src="../../static/lixian.png" mode="" v-else></image>
				<view class="">
					离线
				</view>
			</view>
		</view>
		<view class="bottomitems">
			<view class="bottomitem" @tap='goMyBenefits'>
				<image src="../../static/shouyi.png" mode=""></image>
				<view class="">
					我的收益
				</view>
			</view>
			<view class="bottomitem">
				<image src="../../static/xuexi.png" mode=""></image>
				<view class="">
					我的学习
				</view>
			</view>
			<view class="bottomitem">
				<image src="../../static/kaoshi.png" mode=""></image>
				<view class="">
					我的考试
				</view>
			</view>
			<view class="bottomitem">
				<image src="../../static/shezhi.png" mode=""></image>
				<view class="">
					设置
				</view>
			</view>
		</view>
		<u-toast ref="uToast" />
	</view>
</template>

<script>
	import {
		nurseAppletPersonCenter,
		updateNursePersonWorkStatus
	} from '@/api/personnal/personal.js';
	import baseurl from '@/api/baseurl.js'
	export default {
		data() {
			return {
				beijingurl: null, //背景
				nursePersonId: null, //护理员id
				baseurl: null, //url
				Personallist: null, //获取个人信息
			}
		},
		onShow() {
			this.beijingurl = baseurl + '/profile/nursePersonAppletPicture/person_center.png'
			this.baseurl = baseurl;
			let that = this
			const value = uni.getStorageSync('nursePersonId');
			if (value) {
				that.nursePersonId = value
				that.myInfo()
			} else {}
		},
		onLoad(options) {},
		methods: {
			//点击状态
			tapstatus(item) {
				const value = uni.getStorageSync('nursePersonId');
				if (value) {
					var obj = {
						id: this.nursePersonId,
						workStatus: item
					}
					updateNursePersonWorkStatus(obj).then(res => {
						if (res.code == 200) {
							this.myInfo()
						}
					})
				} else {
					this.gologin();
				}
			},
			myInfo() {
				nurseAppletPersonCenter(this.nursePersonId).then(res => {
					if (res.code == 200) {
						this.Personallist = res.data
					} else {
						this.$refs.uToast.show({
							title: '账号异常,请重新登录',
							type: 'error',
							duration: '1500'
						})
						setTimeout(e => {
							uni.reLaunch({
								url: '/pages/login/login'
							})
						}, 1500)
					}
				})
			},
			//跳登录
			gologin() {
				uni.navigateTo({
					url: '/pages/login/login'
				})
			},
			//跳修改
			goModifyinformation() {
				uni.navigateTo({
					url: '/pages/Modifyinformation/Modifyinformation'
				})
			},
			//我的收益
			goMyBenefits() {
				const value = uni.getStorageSync('nursePersonId');
				if (value) {
					uni.navigateTo({
						url: '/pages/MyBenefits/MyBenefits'
					})
				} else {
					this.gologin();
				}
			},
			//去登陆
			gologin() {
				this.$refs.uToast.show({
					title: '您未登录,请先登录',
					type: 'error',
					duration: '1000',
					url: '/pages/login/login'
				})
			},
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #fff;
	}

	.app {
		padding: 0;
		font-size: 32rpx;
		height: 100vh;

		.bottomitems {
			width: 100%;
			margin-top: 30rpx;

			.bottomitem {
				width: 85%;
				margin: 0 auto;
				height: 120rpx;
				position: relative;
				border-bottom: 1rpx solid #F3F3F3;

				view {
					display: inline-block;
					font-size: 35rpx;
					color: #333333;
					line-height: 120rpx;
					margin-left: 80rpx;
				}

				image {
					position: absolute;
					top: 50%;
					transform: translateY(-50%);
					display: inline-block;
					width: 50rpx;
					height: 50rpx;
				}
			}
		}

		.topitems {
			z-index: 999;
			padding: 45rpx 0 35rpx;
			width: 94%;
			margin: 0 auto;
			display: flex;
			background: #FFFFFF;
			box-shadow: 0rpx 3rpx 18rpx 0rpx rgba(79, 108, 254, 0.43);
			border-radius: 5rpx;
			justify-content: space-around;
			text-align: center;

			.topitem {
				view {
					font-size: 32rpx;
					margin-top: 10rpx;
				}

				image {
					width: 90rpx;
					height: 90rpx;
				}
			}
		}

		.user {
			width: 100%;
			height: 400rpx;
			position: relative;
			color: #FFFFFF;
			font-size: 38rpx;

			.modify {
				position: absolute;
				right: 3%;
				top: 250rpx;
				font-size: 28rpx;

				image {
					width: 23rpx;
					height: 23rpx;
					padding-left: 10rpx;
				}
			}

			.login {
				text-align: center;
				position: absolute;
				top: 220rpx;
				left: 35%;
				font-size: 36rpx;
				width: 180rpx;
				line-height: 70rpx;
				border: 1rpx solid #fff;
				height: 70rpx;
				border-radius: 20rpx;
			}

			.nickname {
				position: absolute;
				top: 300rpx;
				left: 35%;
				font-size: 28rpx;
			}

			.phone {
				position: absolute;
				top: 180rpx;
				left: 35%;
			}

			.img {
				width: 160rpx;
				height: 160rpx;
				border-radius: 50%;
				background: #F6F6F6;
				position: absolute;
				top: 170rpx;
				left: 8%;
				border: 4px solid #6DD8FC;
			}
		}

		.circular {
			z-index: -1;
			width: 100%;
			height: 500rpx;
			position: absolute;
			top: 0;
		}
	}
</style>
