<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">{{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%;color: gray;" placeholder="请输入解决原因"
						v-model="list.rescindReason"></textarea>
				</view>
				<view class="btnss">
					<view class="cancel" @click="maskshowtwo=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 {
		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: '其他'
					},
				],
			};
		},
		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)
					}
				})
			},
			// 签约信息
			detailinfo() {
				// detail(uni.getStorageSync('userinfo').cardNo, this.region).then(res => {
				detail('372424194703207523', '1').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(',')
					}
				})
			},
			//我的家庭医生团队
			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() {
				uni.navigateTo({
					url: `/pagesB/imagetextConsultation/imagetextConsultation`
				})
				// uni.navigateTo({
				// 	url: `/pagesC/seekadvicefrom/seekadvicefrom?item=${JSON.stringify(this.list)}`
				// })
			},
			maskshowtwoconfirm(e) {
				this.list.rescindType = e[0].value
				this.list.rescindName = e[0].label
			},
		},
		onLoad(options) {
			this.detailinfo();
		}
	}
</script>

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