<template>
	<view>
		<scroll-view scroll-y class="page">
			<cu-custom bgColor="bg-blue" :isBack="true"><block slot="backText">返回</block><block slot="content">个人信息</block></cu-custom>
			<view class="photoView">
				<view class="photoImage">
					<open-data type="userAvatarUrl"></open-data>
				</view>
			</view>
			<form action="">
				<view class="cu-form-group">
					<view class="title">医院名称</view>
					<input :value="hospital" disabled="disabled"></input>
				</view>
				<view class="cu-form-group">
					<view class="title">分院名称</view>
					<input :value="sortHospital" disabled="disabled"></input>
				</view>
				<view class="cu-form-group">
					<view class="title">科室名称</view>
					<input :value="department" disabled="disabled"></input>
				</view>
				<view class="cu-form-group">
					<view class="title">职务名称</view>
					<input :value="duty" disabled="disabled"></input>
				</view>
				<view class="cu-form-group margin-top">
					<view class="title">姓名</view>
					<input :value="name" name="name" @input="getName"></input>
				</view>
				<view class="cu-form-group">
					<view class="title">联系电话</view>
					<input :value="phone" name="phone" @input="getPhone"></input>
				</view>
			</form>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				hospital: '',
				sortHospital: '',
				department: '',
				duty: '',
				name: '',
				phone: ''
			}
		},
		created() {
			this.hospital = getApp().globalData.hospital
			this.sortHospital = getApp().globalData.sortHospital
			this.department = getApp().globalData.department
			this.duty = getApp().globalData.duty
			this.name = getApp().globalData.name
			this.phone = getApp().globalData.phone
		},
		methods: {
			getName: function(e){
				this.name = e.target.value
			},
			getPhone: function(e){
				this.phone = e.target.value
			},
			buttonClick(e) {
				let new_that = this;
				uni.request({
					url: 'https://lekapi.opmonitor.com/?c=app_api&a=getUserInfoUpdate',
					data: {
						name: new_that.name,
						phone: new_that.phone,
						openid: getApp().globalData.openid
					},
					header: {
						'Content-type': 'application/x-www-form-urlencoded'
					},
					method: 'POST',
					success: function(res){
						//重新赋值
						getApp().globalData.name = res.data.data.name
						getApp().globalData.phone = res.data.data.phone
						uni.navigateTo({
							url: '/pages/index/index'
						})
					},
					fail: () => {
						console.info('小程序域名不正确，请检查域名正确性')
					}
				})
			}
		}
	}
</script>

<style>
	.page {
		width: 100vw;
		height: 120Vh;
	}
	.photoView {
		padding-top: 50rpx;
		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);
	}
	.cu-form-group .title{
		min-width: calc(4em + 15px);
		font-weight: 600;
	}
	.picker {
		text-align: left;
	}
</style>
