<template>
	<view class="app">
		<view class="centercontent">
			<view class="Commodity">
				头像
				<image class="picture" src="../../static/head.png" mode=""></image>
				<image class="pictureA" src="../../static/jiantou.png" mode=""></image>
			</view>
			<view class="content">
				<view class="name">昵称：
					<input type="text" placeholder="请输入" />
				</view>
				<view class="name">姓名:
					<input type="text" placeholder="请输入" v-model="appPersonallist.patientName" />
				</view>
				<view class="name">电话：
					<input type="text" placeholder="请输入" v-model="appPersonallist.phone" />
				</view>
				<view class="name">地址：
					<input type="text" placeholder="请输入" v-model="appPersonallist.address" />
				</view>
				<view class="nursetype name" style="border: none;" @tap="godisease">
					疾病类型:
					<span class="" style="padding-left: 25rpx;text-overflow: ellipsis;"
						v-for="(item,index) in patientDiseaseInfoList">
						{{item.diseaseName}}
					</span>
				</view>
			</view>
			<view class="finish" @tap="submit()">完成
			</view>
		</view>
	</view>
</template>

<script>
	import {
		updateInformation,
	} from '@/api/modify/modify.js';
	import baseurl from '@/api/baseurl.js'
	export default {
		data() {
			return {
				patientId: '',
				appPersonallist: {
					patientId: '',
					patientName: '',
					phone: '',
					address: '',
					cardNo: ' ',
					areaCode: '',
					headPictureUrl: '',

				},
				patientDiseaseInfoList: [], //获取个人信息
			}
		},
		onLoad(options) {
			this.appPersonallist = JSON.parse(options.appPersonallist)
			this.patientDiseaseInfoList = this.appPersonallist.patientDiseaseInfoList
			this.patientDiseaseInfoList.forEach(e => {
				e.id = e.diseaseId
			})
			console.log(this.patientDiseaseInfoList)

		},
		methods: {
			godisease() {
				uni.navigateTo({
					url: `/pages/disease/disease?diseaseInfoList=${JSON.stringify(this.patientDiseaseInfoList)}`,
				})
			},
			submit() {
				this.appPersonallist.patientDiseaseInfoList = this.patientDiseaseInfoList
				updateInformation(this.appPersonallist).then(res => {
					if (res.code == 200) {
						uni.showToast({
							title: '修改成功',
							duration: 1500
						});
						that.show = false;
						setTimeout(e => {
							that.goodsList()
						}, 1500)
					}
				})
			}

		},
		//带参返回
		onShow() {
			let that = this
			uni.$on('disease', function(data) {
				that.patientDiseaseInfoList = JSON.parse(data.disease)
				that.patientDiseaseInfoList.forEach(e => {
					e.diseaseId = e.id
				})
				console.log(that.patientDiseaseInfoList)
			})
		}
	}
</script>

<style lang="scss">
@import "./modify.scss"
</style>
