<template>
	<view class="app">
		<view class="content">
			<view class="item">
				筛查项目：
				<span>{{screeningResultData.projectName}}</span>
			</view>
			<view class="item">
				筛查时间：
				<span>{{ screeningResultData.screeningDate ? screeningResultData.screeningDate : '无' }}</span>
			</view>
			<view class="item">
				筛查机构：
				<span v-if="screeningResultData.hospitalName">{{screeningResultData.hospitalName}}</span>
			</view>
			<view class="item">
				筛查医生：
				<span v-if="screeningResultData.doctorName">{{screeningResultData.doctorName}}</span>
			</view>
			<view class="itemend">
				筛查结果:
			</view>
			<view class="image">
				<view style="text-align: center;">
					<view class="" v-if="screeningResultData.fileType=='docx'||screeningResultData.fileType=='doc'">
						<view class="btn" style="color: #346CF2;" @click="lookpath"
							v-if="screeningResultData.attachment">
							查看报告
						</view>
					</view>
					<view class="" v-else>
						<view v-if="screeningResultData.attachment && screeningResultData.attachment != '找不到指定文件!'">
							<view style="display: flex;justify-content: space-around;">
								<view style="width: 49%;" @click="xxbClick(screeningResultData.attachment)">
									<image style="width: 100%;height: 100px;"
										:src="'data:image/jpeg;base64' + screeningResultData.attachment"></image>
								</view>
								<view style="width: 49%;" @click="picClick1(screeningResultData.attachmentTwo)">
									<image style="width: 100%;height: 100px;"
										:src="'data:image/jpeg;base64' + screeningResultData.attachmentTwo"></image>
								</view>
							</view>
						</view>
					</view>
					<view v-else style="margin: 10px auto; ">
						<u-empty text="暂无照片" mode="data"></u-empty>
					</view>
				</view>
			</view>
			<!-- <view class="imageitem">
					<image   :src="require('@/pagesC/images/Behave.png')" mode=""></image>
				</view>
				<view class="imageitem">
					<image   :src="require('@/pagesC/images/Behave.png')" mode=""></image>
				</view>
				<view class="imageitem">
					<image   :src="require('@/pagesC/images/Behave.png')" mode=""></image>
				</view> -->
			<view class="item">
				诊断结果：
				<span v-if="screeningResultData.diagnosticResult">{{screeningResultData.diagnosticResult}}</span>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		lastScreeningResult,
		screeningResultDetail
	} from '@/api/pagesB/screeningResult/screeningResult.js'
	import baseurl from '@/api/baseurl.js'
	export default {
		data() {
			return {
				screeningResultData: {},
				projectId: '',
				identity: '',
				userinfo: {},
				baseurl: '',
			};
		},
		onLoad(e) {
			this.userinfo = uni.getStorageSync('userinfo');
			this.identity = this.userinfo.cardNo;
			this.projectId = e.projectId
			this.getLastScreeningResult()
			console.log(e)
		},
		onShow() {
			this.baseurl = baseurl
		},
		methods: {
			// 获取最新的筛查结果
			getLastScreeningResult() {
				lastScreeningResult(this.identity, this.projectId).then(res => {
					this.screeningResultData = res.data
				})
			},
			// 查看报告
			lookpath() {
				var that = this
				var url = that.baseurl +
					`/nurseApplet/screening/record/fileview?filePath=${that.screeningResultData.attachment}`
				// console.log(url, '1')
				uni.downloadFile({
					url: url,
					responseType: 'blob',
					success: function(resp) {
						var filePath = resp.tempFilePath;
						uni.openDocument({
							filePath: filePath,
							fileType: that.screeningResultData.fileType.toLowerCase(),
							showMenu: true,
							success: function(respp) {
								console.log(respp)
							},
							fail(err) {
								console.log(err)
							}
						});
					}
				})
			},
			goapponint() {
				uni.navigateTo({
					url: '/pagesC/Screeningdetails/Screeningdetails'
				});
			},
		},
	}
</script>

<style lang="scss">
	.app {
		height: 100vh;
		background-color: #F7F5F5;
		padding: 30rpx 0 0 0;
		overflow: scroll;

		.content {
			background-color: #fff;
			position: relative;
			width: 95%;
			height: 100%;
			box-shadow: 0rpx 9rpx 31rpx 9rpx rgba(0, 0, 0, 0.03);
			border-radius: 5rpx;
			margin: 15rpx auto;

			.word {
				width: 90%;
				margin: 10rpx auto;
				font-size: 30rpx;
				font-family: Source Han Sans CN;
				font-weight: 400;
				color: #868585;
				line-height: 38rpx;
				text-indent: 35rpx;
				overflow: hidden;
				text-overflow: ellipsis;
				display: -webkit-box;
				-webkit-line-clamp: 5;
				line-clamp: 5;
				-webkit-box-orient: vertical;
				text-align: justify;
			}

			.itemend {
				font-size: 30rpx;
				font-family: Source Han Sans CN;
				font-weight: 400;
				color: #333333;
				line-height: 38rpx;
				padding: 50rpx 30rpx 0 30rpx;


			}

			.image {
				// display: flex;
				// justify-content: space-around;
				padding-top: 20rpx;
			}

			.imageitem {
				image {
					width: 195rpx;
					height: 276rpx;
				}
			}

			.item {
				padding: 30rpx 30rpx 0 30rpx;
				font-size: 30rpx;
				font-family: Source Han Sans CN;
				font-weight: 400;
				color: #333333;
				line-height: 38rpx;

				span {
					color: #868585;
				}
			}
		}
	}
</style>