<template>
	<view v-if="params.url">
		<u-navbar :title="params.title || ''" :autoBack="true" :placeholder="true"></u-navbar>
		<image v-if="params.type == 'JPG' || params.type == 'PNG'" :src="params.url"></image>
		<video v-else-if="params.type == 'MP4' || params.type == 'AVI'" :src="params.url" controls autoplay style="width: 100%;"></video>
		<web-view v-else :webview-styles="webviewStyles" :src="params.url"  style="margin-top: 44px;"></web-view>
		<!-- <web-view :src="params.url" style="margin-top: 44px;"></web-view> -->
	</view>
</template>

<script>
	export default {
		data() {
			return {
				params: {
					// url:'http://baiji-case-collection-system-dev.oss-cn-shanghai.aliyuncs.com/case/2024/02/23/9b20fa05c421420e90d528e8d1091731.xlsx?Expires=1709262212&OSSAccessKeyId=LTAI5t6WgwRWjPdxFfrR3PFn&Signature=F7KwghNYCkdkQUF%2BjLnckAqbY6Y%3D&x-oss-process=imm%2Fpreviewdoc%2Ccopy_1'
				},
				webviewStyles: {
					progress: {
						color: "#FF3333"
					}
				}
			}
		},
		onLoad(event) {
			this.params = event
			if(this.params.type == 'PDF'){
				let temp = this.params.url
				//预览参数
				let ops = {
				  "pdf": true,
				  "mtime":new Date().getTime()
				};
				//传入预览参数
				for (var a in ops) {
				　　temp += "&" + a + "=" + encodeURIComponent(ops[a]);
				}
				this.params.url = temp
			}else if(this.params.type == 'OSS'){
				this.params.url = uni.getStorageSync('FileUrl') || ''
				console.log('==url==', this.params.url);
			}
		}
	}
</script>
