Răsfoiți Sursa

feat(文档预览): 优化文档预览页面布局并添加webview缩放功能

yusheng 6 luni în urmă
părinte
comite
cf982d7620
2 a modificat fișierele cu 78 adăugiri și 58 ștergeri
  1. 1 1
      manifest.json
  2. 77 57
      pages/doc/browse.vue

+ 1 - 1
manifest.json

@@ -2,7 +2,7 @@
     "name" : "智慧工厂",
     "appid" : "__UNI__45B3907",
     "description" : "",
-    "versionName" : "V1.0.3.31",
+    "versionName" : "V1.0.3.32",
     "versionCode" : "100",
     "transformPx" : false,
     "h5" : {

+ 77 - 57
pages/doc/browse.vue

@@ -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>