<template>
	<view class="app">
		<view class="user">
			<view class="img" v-if="appPersonallist.avatar==''||!appPersonallist.avatar">
				<image style="height: 110rpx;" src="../../static/person.png" mode=""></image>
			</view>
			<view class="img" v-else>
				<image :src="baseurl+appPersonallist.avatar" mode=""></image>
			</view>
			<!-- <view class="phone">
				{{appPersonallist.phonenumber}}
			</view> -->
			<view class="nickname">
				{{appPersonallist.userName}}
			</view>
			<view class="modify" @tap='updatainfo()'>
				修改信息
				<u-icon name="arrow-right" color="#ffffff" size="32"></u-icon>
			</view>
		</view>
		<view class="information">
			<view class="item">
				姓名：{{appPersonallist.nickName}}
			</view>
			<view class="item">
				电话：{{appPersonallist.phonenumber }}
			</view>
			<view class="item" style="border:none;border-radius:0 0 20rpx 20rpx;"
				v-if="appPersonallist.nurseStationSysUserVOList">
				护理站: {{appPersonallist.nurseStationSysUserVOList[0].nurseStationName}}
			</view>
			<view class="signout" @tap='remove'>
				退出账号
			</view>
		</view>
		<!-- <view class="External" style="margin: 100rpx auto 0;">
			<view class="lefttext">
				我的设备
			</view>
			<image src="../../static/jiantou.png" mode=""></image>
		</view> -->
		<!-- <view class="External">
			<view class="lefttext">
				修改密码
			</view>
			<image src="../../static/jiantou.png" mode=""></image>
		</view> -->

		<u-toast ref="uToast" />
	</view>
</template>

<script>
	import {
		nursePerson,
	} from '@/api/personnal/personal.js';
	import baseurl from '@/api/baseurl.js'
	export default {
		data() {
			return {
				baseurl: '', //url
				phonenumber: '',
				avatar: '',
				password: '',
				userId: '',
				appPersonallist: [], //获取个人信息
				nurseStationSysUserVOList: [],
			}

		},
		onShow() {
			this.baseurl = baseurl;
			let that = this
			try {
				const value = uni.getStorageSync('phonenumber');
				const value2 = uni.getStorageSync('password');
				if (value && value2) {
					that.phonenumber = value
					that.password = value2
					that.myInfo()
				}
			} catch (e) {}
		},
		onLoad(options) {},
		methods: {
			//退出
			remove() {
				let that = this
				uni.showModal({
					title: '提示',
					content: '确认要退出此账号吗',
					success: function(res) {
						if (res.confirm) {
							uni.removeStorageSync("phonenumber")
							uni.removeStorageSync("password")
							uni.removeStorageSync("nursePersonId")
							that.$refs.uToast.show({
								title: '退出账号成功',
								type: 'success',
								duration: '1000'
							})
							setTimeout(e => {
								uni.reLaunch({
									url: '/pages/login/login'
								})
							}, 1000)
						} else if (res.cancel) {
							that.$refs.uToast.show({
								title: '退出账号失败',
								type: 'error',
								duration: '1000'
							})
						}
					}
				});
			},
			myInfo() {
				nursePerson(this.phonenumber, this.password).then(res => {
					this.appPersonallist = res.data
					console.log(this.appPersonallist)
				})
			},
			updatainfo() {
				console.log()
				uni.navigateTo({
					url: `/pages/Modifyinformation/Modifyinformation`
				})
			}
		}
	}
</script>

<style lang="scss">
	.app {
		padding: 0;
		font-size: 35rpx;
		height: 100vh;

		.signout {
			// position: absolute;
			// bottom: 60rpx;
			// width: 94%;
			background: #FFFFFF;
			margin-top: 50rpx;
			height: 80rpx;
			line-height: 80rpx;
			// left:3%;
			border-radius: 20rpx;
			text-align: center;
		}

		.External {
			width: 94%;
			height: 100rpx;
			line-height: 100rpx;
			margin: 20rpx auto;
			padding-left: 5%;
			background: #FFFFFF;
			box-shadow: 0px 9rpx 31rpx 9rpx rgba(0, 0, 0, 0.03);
			border-radius: 20rpx;
			position: relative;


			image {
				width: 18rpx;
				height: 27rpx;
				position: absolute;
				right: 5%;
				top: 50%;
				transform: translateY(-50%);
			}

			.lefttext {
				display: inline-block;
			}
		}

		.information {
			width: 98%;
			border-radius: 20rpx;
			position: absolute;
			top: 20%;
			left: 1%;
			color: #000000;
			overflow: hidden;
			font-size: 35rpx;

			.item {
				// height: 110rpx;
				line-height: 110rpx;
				background: #FFFFFF;
				padding-left: 3%;
				box-shadow: 0px 9rpx 31rpx 9rpx rgba(0, 0, 0, 0.03);
				border-bottom: 1rpx solid #D8D4D4;

				.address {
					height: 40rpx;
					// font-size: 30rpx;
					line-height: 40rpx;
					display: inline-block;
					width: 80%;
					margin-left: 30rpx;
					margin-top: 30rpx;
				}
			}
		}

		.user {
			width: 100%;
			height: 500rpx;
			background: #4C7BC9;
			position: relative;
			color: #FFFFFF;

			.modify {
				font-size: 32rpx;
				position: absolute;
				right: 3%;
				top: 18%;
			}

			.nickname {
				position: absolute;
				top: 18%;
				left: 28%;
			}

			.phone {
				position: absolute;
				top: 13%;
				left: 28%;
			}

			.img {
				width: 120rpx;
				height: 120rpx;
				position: absolute;
				top: 10%;
				left: 5%;

				image {
					border-radius: 50%;
					width: 120rpx;
					margin-left: 50%;
					margin-top: 50%;
					transform: translate(-50%, -50%);
					height: 120rpx;
				}
			}
		}
	}
</style>
