|
|
@@ -1,66 +1,86 @@
|
|
|
<template>
|
|
|
+ <view class="">
|
|
|
+ <uni-nav-bar
|
|
|
+ fixed="true"
|
|
|
+ statusBar="true"
|
|
|
+ left-icon="back"
|
|
|
+ title="预览"
|
|
|
+ @clickLeft="back"
|
|
|
+ >
|
|
|
+ </uni-nav-bar>
|
|
|
|
|
|
- <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>
|
|
|
-
|
|
|
+ <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
|
|
|
- }) {
|
|
|
+// import { getFileType } from './util.js';
|
|
|
|
|
|
- uni.getSystemInfo({
|
|
|
- success: (res) => {
|
|
|
- this.webviewStyles.height = res.screenHeight - res.statusBarHeight - res.safeAreaInsets
|
|
|
- ?.bottom - 100 + 'px';
|
|
|
- this.webviewStyles.bottom = res.safeAreaInsets?.bottom + 56 + 'px';
|
|
|
- }
|
|
|
+export default {
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ fileUrl: "",
|
|
|
+ showEditFlag: false,
|
|
|
+ webviewStyles: {
|
|
|
+ width: "100%",
|
|
|
+ height: "100%",
|
|
|
+ bottom: "56px",
|
|
|
+ },
|
|
|
+ };
|
|
|
+ },
|
|
|
+ onReady() {
|
|
|
+ // #ifdef APP-PLUS
|
|
|
+ var currentWebview = this.$scope.$getAppWebview(); //获取当前页面的webview对象
|
|
|
+ setTimeout(function () {
|
|
|
+ let wv = currentWebview.children()[0];
|
|
|
+ console.log(currentWebview.children()[0],'currentWebview')
|
|
|
+ console.log(wv,'wv')
|
|
|
+ wv.setStyle({ scalable: true });
|
|
|
+ }, 1000); //如果是页面初始化调用时,需要延时一下
|
|
|
+ // #endif
|
|
|
+ },
|
|
|
+ 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);
|
|
|
+ },
|
|
|
|
|
|
- })
|
|
|
-
|
|
|
- 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);
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- };
|
|
|
+ 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>
|
|
|
+<style scoped lang="scss"></style>
|