<template>
	<view class="container">
		<web-view :src="pdfUrl"></web-view>
	</view>
</template>

<script>
	import http from "@/common/service/http.js"
	import md5 from "@/common/util/md5.js"
	export default {
		data() {
			return {
				pdfUrl: '',
				from: 'app',
				type: '1'
			}
		},
		created() {
			let url = window.location.href
			let urlOne = url.split('#')[1]
			let urlTwo = urlOne.split('?')[1]
			let urlThree = urlTwo.split('=')
			if (urlThree[0] == 'url') {
				this.pdfUrl = '/hybrid/html/web/viewer.html?file=' + decodeURIComponent(urlThree[1])
				// this.pdfUrl = '/hybrid/html/web/viewer.html?file=' + encodeURIComponent(decodeURIComponent(urlThree[1]))
			}

		},
		mounted() {
			// window.addEventListener('mousedown', this.handleonmousedown)
		},
		onLoad(option) {
			if (!option.url) {
				this.getDe(option.fileId)
			}

		},
		methods: {
			/**
			 * 根据报告的id查询没有盖章文档路径
			 */
			getDe(id) {
				let access_token = uni.getStorageSync('Access-Token')
				console.log(access_token)

				let sql =
					`select FILE_PATH_  from ibps_file_attachment where ID_ = '${id}'`
				let requestData = this.$sig(sql)
				this.$http.post("/ibps/business/v3/sys/universal/inputSqlSelectData", requestData).then(res => {
					if (res.data.state == 200) {
						const data = res.data.variables.data
						if (data.length > 0) {
							let dataItem = data[0]
							let url =
								http.apiHosp + dataItem.FILE_PATH_
							// this.pdfUrl = '/hybrid/html/web/viewer.html?file=' + encodeURIComponent(url)
							this.pdfUrl = '/hybrid/html/web/viewer.html?file=' + url
						}

					}
				})
			}
		}
	}
</script>

<style>

</style>