<template>
	<view class="app">
		<view class="title">
			<image src="/static/pagesB/jibenxinxi.png" mode=""></image>
			<view class="text">
				基本信息
			</view>
		</view>
		<view class="name">
			<view class="text">
				{{list.residentName?list.residentName:''}}
			</view>
			<view class="card" v-for='item in list.crowdsName'>
				{{item?item:''}}
			</view>
		</view>
		<view class="item">
			{{list.gender=='2'?'女':''}}{{list.gender=='1'?'男':''}}&nbsp;&nbsp;&nbsp; {{list.age? list.age +'岁':''}}
		</view>
		<view class="item">
			{{list.phone?list.phone:''}}
		</view>
		<view class="item">
			{{list.identity?list.identity:''}}
		</view>
		<view class="item">
			{{list.address?list.address:''}}
		</view>
		<view class="border">
		</view>
		<view class="title">
			<image src="@/static/pagesB/qianyuexinxi.png" mode=""></image>
			<view class="text">
				签约信息
			</view>
		</view>
		<view class="item">
			年限：{{list.signTime?list.signTime:''}} 至 {{list.signDeadline?list.signDeadline:''}}
		</view>
		<view class="item">
			机构：
			{{list.orgName?list.orgName:''}}
		</view>
		<view class="item flexitem">
			<view class="left">
				医生：
				{{list.dutyDoctorName?list.dutyDoctorName:''}}
			</view>
			<view class="right" @tap="goseekadvicefrom">
				<image src="@/static/pagesB/zixun.png" mode=""></image>
				<text>
					咨询
				</text>
			</view>
		</view>
		<view class="lookbtn" @tap='gomyfamilydoctorteam'>
			查看我的家庭医生团队
		</view>
		<view class="border">
		</view>
		<view class="title">
			<image src="@/static/pagesB/wodefuwubao.png" mode=""></image>
			<view class="text">
				我的服务包
			</view>
		</view>
		<view class="item" v-for='item in list.packagesName'>
			{{item?item:''}}
		</view>
		<view class="lookbtn" @tap='goperformancedetails'>
			查看履约详情
		</view>
		<view class="border">
		</view>
		<view class="btns">
			<view class="leftbtn" @tap='maskshow = true'>
				申请解约
			</view>
			<view class="rightbtn" @tap='gocontractsigningprotocol'>
				查看签约协议
			</view>
		</view>
		<u-popup v-model="maskshow" mode="center" length="90%" closeable height="50%">
			<view class="mask" @tap.stop=''>
				<view class="titletext">
					<text>解约类型：</text>
					<view class="select" @tap='maskshowtwo=true'>
						<text v-if="list.rescindName"
							style="font-size: 26rpx;color: #303133;">{{list.rescindName}}</text>
						<text v-else>请选择解约类型</text>
						<image src="../../static/huijiantou.png" mode=""></image>
					</view>
				</view>
				<view class="titletext">
					<text>解约原因：</text>
					<textarea name="" id="" cols="30" rows="10" style="width: 60%;height: 200rpx;" placeholder="请输入解约原因"
						v-model="list.rescindReason"></textarea>
				</view>
				<view class="btnss">
					<view class="cancel" @click="maskshow=false">
						取消
					</view>
					<view class="Rescind" @click="rescindapplysaveinfo">
						解约
					</view>
				</view>
			</view>
		</u-popup>
		<u-toast ref="uToast" />
		<u-select v-model="maskshowtwo" mode="single-column" :list="maskshowtwolist" @confirm="maskshowtwoconfirm"
			z-index='10076'></u-select>
	</view>
</template>

<script>
	import {
		getHospitalPersonInfo
	} from '@/api/pagesC/contractsigningprotocol/index.js'
	import {
		consultationInfo,
		rescindapplysave
	} from '@/api/pagesB/mysigning/index.js'
	import {
		detail,
	} from '@/api/pages/homepage/homepage.js'
	export default {
		data() {
			return {
				list: {},
				maskshow: false,
				maskshowtwo: false,
				maskshowtwolist: [{
						value: 1,
						label: '主动解约'
					},
					{
						value: 2,
						label: '迁出'
					}, {
						value: 3,
						label: '死亡'
					}, {
						value: 4,
						label: '到期'
					}, {
						value: 5,
						label: '其他'
					},
				],
				formdata: {
					address: '',
					patientId: '',
					patientName: '',
					cardNo: '',
					phone: '',
					doctorId: '',
					doctorName: '',
					consultationType: 'ONLINE_CONSULTATION',
				},
			};
		},
		methods: {
			//解约
			rescindapplysaveinfo() {
				rescindapplysave(this.list).then(res => {
					if (res.code == 200) {
						this.$refs.uToast.show({
							title: '解约申请提交成功',
							type: 'success',
						})
						setTimeout(() => {
							uni.switchTab({
								url: "/pages/homepage/homepage"
							})
						}, 2000)
					} else {
						this.$refs.uToast.show({
							title: res.msg,
							type: 'error',
						})
					}
				})
			},
			// 签约信息
			detailinfo() {
				detail(uni.getStorageSync('userinfo').cardNo).then(res => {
					if (res.code == 200) {
						this.list = res.data
						this.list.rescindType = null
						this.list.rescindName = null
						this.list.rescindReason = null
						this.list.crowdsName = this.list.crowdsName.split(',')
						this.list.packagesName = this.list.packagesName.split(',')
						getHospitalPersonInfo(res.data.dutyDoctorNo, '1').then(resp => {
							this.formdata.doctorName = resp.data.personName
							this.formdata.doctorId = resp.data.id
						})
					}
				})
			},
			//我的家庭医生团队
			gomyfamilydoctorteam() {
				uni.navigateTo({
					url: `/pagesB/myfamilydoctorteam/myfamilydoctorteam?teamNo=${this.list.teamNo}`
				})
			},
			// 履约详情
			goperformancedetails() {
				uni.navigateTo({
					url: "/pagesB/performancedetails/performancedetails"
				})
			},
			//签约协议
			gocontractsigningprotocol() {
				uni.navigateTo({
					url: `/pagesC/contractsigningprotocol/contractsigningprotocol?orgNo=${this.list.orgNo}&cardNo=${this.list.identity}`
				})
			},
			//咨询
			goseekadvicefrom() {
				consultationInfo(this.formdata).then(res => {
					if (res.code == 200) {
						uni.navigateTo({
							url: `/pagesC/seekadvicefrom/seekadvicefrom?item=${JSON.stringify(res.data)}`
						})
					} else if (res.code == 500) {
						this.$refs.uToast.show({
							title: res.msg,
							type: 'error',
							duration: '1500',
						})
					}
				})
			},
			maskshowtwoconfirm(e) {
				this.list.rescindType = e[0].value
				this.list.rescindName = e[0].label
			},
		},
		onLoad(options) {
			this.formdata.address = uni.getStorageSync('userinfo').address
			this.formdata.patientId = uni.getStorageSync("patientId")
			this.formdata.consultationType = 'ONLINE_CONSULTATION'
			this.formdata.patientName = uni.getStorageSync('userinfo').patientName
			this.formdata.cardNo = uni.getStorageSync('userinfo').cardNo
			this.formdata.phone = uni.getStorageSync('userinfo').phone
			this.detailinfo();
		}
	}
</script>

<style lang="scss">
	@import './mysigning.scss';
</style>