<template>

	<view class="">
		<uni-nav-bar fixed="true" statusBar="true" left-icon="back" title="预览" @clickLeft="back">
		</uni-nav-bar>

		<web-view :src="fileUrl" class="webview" allow :fullscreen="false" :webview-styles="webviewStyles"
			style="width: 100%;height: calc(100vh - 100px)" :frameborder="0"></web-view>

	</view>

</template>

<script>
	// import { getFileType } from './util.js';

	export default {
		data() {
			return {
				fileUrl: '',
				showEditFlag: false,
				webviewStyles: {
					width: '100%',
					height: '100%',
					bottom: '56px'
				}
			};
		},
		onLoad({
			url
		}) {

			uni.getSystemInfo({
				success: (res) => {
					this.webviewStyles.height = res.screenHeight - res.statusBarHeight - res.safeAreaInsets
						?.bottom - 100 + 'px';
					this.webviewStyles.bottom = res.safeAreaInsets?.bottom + 56 + 'px';
				}


			})

			this.fileUrl = url
			console.log(url);
		},

		methods: {
			// open(row) {
			// 	this.showEditFlag = true
			// 	this.setFileUrl(row)
			// },
			setFileUrl(row) {
				let file = row.storagePath[0];
				let fileNames = file.storePath.split('/')
				let url = window.location.origin + '/api/main/file/getFile?objectName=' + file.storePath +
					'&fullfilename=' + fileNames[fileNames.length - 1]
				this.fileUrl = '/kkfile/onlinePreview?url=' + btoa(url);

			
			}
		}
	};
</script>
<style scoped lang="scss">

</style>