| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- <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",
- },
- };
- },
- 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);
- },
- 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>
|