<template>
	<view class="app">
		<view class="agreement-title-box">
			家庭医生签约服务协议书
		</view>
		<view class="agreement-content-container">
			<view class="agreement-content_parta-box">
				<h4>甲方：</h4>
				<h4 class="box-line">{{list.signInfo.agencyOrgName}}</h4>
			</view>
			<view class="agreement-content_parta-box">
				<h4>乙方：</h4>
				<h4 class="box-line">{{list.signInfo.residentName?list.signInfo.residentName:''}}</h4>
			</view>
			<uni-table border stripe emptyText="暂无更多数据">
				<uni-tr>
					<uni-th>姓名</uni-th>
					<uni-th>性别</uni-th>
					<uni-th>年龄</uni-th>
					<uni-th>身份证号</uni-th>
					<uni-th>现住址</uni-th>
					<uni-th>手机号码</uni-th>
					<uni-th>选择签约基础服务包 </uni-th>
					<uni-th>选择签约个性服务包</uni-th>
				</uni-tr>
				<uni-tr>
					<uni-td>{{list.signInfo.residentName?list.signInfo.residentName:''}}</uni-td>
					<uni-td>{{list.signInfo.gender === '1' ? '男' : '女'}}</uni-td>
					<uni-td>{{list.signInfo.age?list.signInfo.age:''}}</uni-td>
					<uni-td>{{list.signInfo.identity?list.signInfo.identity:''}}</uni-td>
					<uni-td>{{list.signInfo.address?list.signInfo.address:''}}</uni-td>
					<uni-td>{{list.signInfo.phone?list.signInfo.phone:''}}</uni-td>
					<uni-td>{{list.basePackagesName?list.basePackagesName:''}} </uni-td>
					<uni-td>{{list.specialPackagesName?list.specialPackagesName:""}}</uni-td>
				</uni-tr>
			</uni-table>
			<view>
				<p style='padding-top: 30rpx;line-height: 46rpx;'>甲乙双方本着平等、尊重和自愿的原则，签订此协议，接受以下条款的约定</p>
				<p style='padding: 30rpx 0;line-height: 46rpx;'>甲乙双方共同确定
					<text class="box-line">{{list.signInfo.teamName}}</text>为乙方的家庭医生服务团队
				</p>
				<uni-table border stripe emptyText="暂无更多数据">
					<uni-tr>
						<uni-th>专病管理服务团队成员</uni-th>
						<uni-th>姓名</uni-th>
						<uni-th>职称</uni-th>
						<uni-th>固定电话</uni-th>
						<uni-th>联系电话</uni-th>
					</uni-tr>
					<uni-tr v-for="(member, index) in list.signInfo.dutyDoctorList" :index="index" :key="index">
						<uni-td v-if="member.teamLeader">
							团队长
						</uni-td>
						<uni-td v-else>
							{{member.teamMemberType=='0'?'全科医生':''}}
							{{member.teamMemberType=='1'?'专科医生':''}}
							{{member.teamMemberType=='2'?'社区护士':''}}
							{{member.teamMemberType=='3'?'公共卫生人员':''}}
						</uni-td>
						<uni-td>{{member.realname?member.realname:''}}</uni-td>
						<uni-td>
							{{member.profTitle=='0'?'初级':''}}
							{{member.profTitle=='1'?'中级':''}}
							{{member.profTitle=='2'?'高级':''}}
							{{member.profTitle=='99'?'其他':''}}
						</uni-td>
						<uni-td>{{member.landline?member.landline:''}}</uni-td>
						<uni-td>{{member.mobilePhone?member.mobilePhone:''}}</uni-td>
					</uni-tr>
				</uni-table>
				<u-parse style="margin-top: 30rpx;" :html="list.protocolContent.content"></u-parse>
				<h4 style='padding-top: 30rpx;font-weight: 600;'>三、服务收费</h4>
				<p style='padding-top: 30rpx;line-height: 46rpx;'>1. 根据自愿选择的原则，乙方选择<text
						class="box-line">{{list.basePackagesName?list.basePackagesName:''}}{{list.specialPackagesName?'，'+list.specialPackagesName:''}}</text>由甲方提供相应服务，服务费为<text
						class="box-line">{{list.packSignCost}}</text>元/年</p>
				<p style='padding-top: 30rpx;line-height: 46rpx;'>2.服务过程中，根据医生判断及患者临时需求增加的服务内容，按照国家相关规定和当地物价部门规定收费。
				</p>
				<p style='padding-top: 30rpx;line-height: 46rpx;'>3.乙方应于<text
						class="box-line">{{list.signInfo.signTime}}</text>
					前将签约服务费缴纳至甲方机构指定科室，不得由签约团队成员代收。
				</p>
				<h4 style='padding-top: 30rpx;font-weight: 600;'>四、其他约定服务：<text class="box-line">{{' '}}</text></h4>
				<h4 style='padding-top: 30rpx;font-weight: 600;'>
					五、保密条款：签约居民授权其所签约的家庭医生及其团队成员可调阅其电子健康档案和在其他医疗机构的诊疗记录信息。甲方有义务对签约居民的电子健康档案和在其他医疗机构的诊
					疗记录信息予以保密。除法律法规规定外，未经签约居民允许，不得泄露给第三方。
				</h4>
				<h4 style='padding-top:30rpx;font-weight: 600;'>六、本协议未尽事宜，经双方协商一致，签订补充协议，补充协议具有同等效力。</h4>
				<h4 style='padding-top: 30rpx;font-weight: 600;'>
					七、本协议解释权归甲方。协议一式两份，甲、乙双方各执一份，自双方签字之日起生效，
					<text
						class="box-line">{{list.signInfo.signTime}}{{' —— '}}{{list.signInfo.signDeadline}}</text>有效期<text
						class="box-line">{{list.signYears}}</text>年
				</h4>
			</view>
		</view>
		<view class="agreement-execute_container-img">
			<view class="parta-execute_box">
				<view class="textparta">甲方(团队长)签字</br><text style="padding-left: 15rpx;">或(单位盖章)</text></view>
				<image :src="list.doctorBase64" mode="aspectFill" style="width: 280rpx; height: 200rpx;"></image>
			</view>
			<view class="parta-execute_box">
				<view class="textparta">乙方(居民)签字</br><text style="padding-left: 8rpx;">或拍照</text></view>
				<image :src="list.residentBase64" mode="widthFix" style="width: 180rpx; height: 180rpx;"></image>
			</view>
			<view class="parta-execute_box">
				<view class="textparta">机构公章</view>
				<image :src="list.orgBase64" mode="widthFix" style="width: 180rpx; height: 180rpx;"></image>
			</view>
		</view>
		<u-mask :show="signatureshow" @click="signatureshow = false">
			<view style="position:absolute;bottom:0;height:900rpx;width:100%;background-color: #fff;"
				v-if='signatureshow'>
				<signature @userSignaturePictureUrl='userSignaturePicture' @click.native.stop
					style='background-color: #F4F5F7;width: 100%;height: 900rpx;'></signature>
			</view>
		</u-mask>
		<uni-fab ref="fab" horizontal="left" vertical="bottom" :content="fabContent" @trigger="fabTrigger" />
	</view>
</template>

<script>
	import baseurl from '@/api/baseurl.js'
	import signature from '@/components/signature/signature.vue'
	import {
		getSignProtocol
	} from '@/api/pagesC/contractsigningprotocol/index.js'
	export default {
		components: {
			signature
		},
		data() {
			return {
				signatureshow: false,
				list: null,
				fabContent: [{
					iconPath: '/static/pageC/signature-unselected.png',
					selectedIconPath: '/static/pageC/signature-selected.png',
					text: '居民签字',
					active: true
				}, {
					iconPath: '/static/pageC/camera-unselected.png',
					selectedIconPath: '/static/pageC/camera.png',
					text: '居民拍照',
					active: true
				}],
			};
		},
		methods: {
			fabTrigger(e) {
				if (e.index === 0) {
					this.signatureshow = true
				} else if (e.index === 1) {
					this.openCamera()
				}
			},
			openCamera() {
				let that = this
				setTimeout(function() {
						uni.chooseImage({
							sizeType: ['compressed'],
							sourceType: ['camera'],
							success: function(res) {
								let tempFilePath = res.tempFilePaths[0]
								uni.saveImageToPhotosAlbum({
									filePath: tempFilePath,
									success: (resp) => {
										uni.uploadFile({
											url: baseurl +
												'/applet/sign/apply/residentSignatureUpload',
											filePath: tempFilePath,
											name: 'file',
											header: {
												region: '1'
											},
											timeout: 10000,
											success(respp) {
												// residentAutographPath
												console.log(respp)
											}
										})
									}
								})
							}
						})
					},
					150)
			},
			// //签名
			userSignaturePicture(data) {
				this.signatureshow = false
			},
			info() {
				getSignProtocol(this.cardNo, '1').then(res => {
					this.list = res.data
				})
			},
		},
		onLoad(options) {
			this.cardNo = options.cardNo
			this.cardNo = '372424194703207523'
			this.info();
		},
	}
</script>

<style lang="scss">
	.app {
		width: 98%;
		margin: 10rpx auto;
		background-color: #fff;
	}

	.agreement-title-box {
		padding-top: 20rpx;
		margin: 0 0 30rpx;
		font-size: 40rpx;
		font-weight: 600;
		text-align: center;
	}

	.agreement-content-container {
		margin: 10rpx 10rpx;
		font-size: 16px;
		color: #333333;
		padding-bottom: 100rpx;
	}

	.agreement-content_parta-box {
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: flex-start;
		margin-bottom: 20rpx;
	}

	.box-line {
		display: inline-block;
		padding: 0 20rpx;
		text-align: center;
		border-bottom: 1px #808080 solid;
	}

	.agreement-execute_container-img {
		display: flex;
		flex-wrap: wrap;
		padding-bottom: 200rpx;

		.parta-execute_box {
			width: 50%;

			.textparta {
				display: inline-block;
				width: 100%;
				text-align: center;
			}

			image {
				display: block;
				margin: 30rpx auto;
			}
		}
	}
</style>
