浏览代码

文件预览

xujunjie 1 年之前
父节点
当前提交
bd48c257b3
共有 4 个文件被更改,包括 68 次插入25 次删除
  1. 26 23
      components/preview-file/preview-file.vue
  2. 10 1
      pages.json
  3. 1 1
      pages/audit/list.vue
  4. 31 0
      pages/preview/preview.vue

+ 26 - 23
components/preview-file/preview-file.vue

@@ -25,28 +25,31 @@
 			},
 			previewFile() {
 				console.log(this.src);
-				uni.showLoading({
-					title: "下载中...",
-					mask: true,
-				});
-				uni.downloadFile({
-					url: this.src,
-					success: (res) => {
-						if (res.statusCode === 200) {
-							uni.openDocument({
-								filePath: res.tempFilePath,
-								// filePath: escape(res.tempFilePath),
-								// 如果文件名包含中文,建议使用escape(res.tempFilePath)转码,防止ios和安卓客户端导致的差异
-								success: function(res) {
-									console.log("打开文档成功");
-								},
-							});
-						}
-					},
-					complete: () => {
-						uni.hideLoading();
-					},
-				});
+				uni.navigateTo({
+					url: '/pages/preview/preview?fileSrc=' + this.src
+				})
+				// uni.showLoading({
+				// 	title: "下载中...",
+				// 	mask: true,
+				// });
+				// uni.downloadFile({
+				// 	url: this.src,
+				// 	success: (res) => {
+				// 		if (res.statusCode === 200) {
+				// 			uni.openDocument({
+				// 				filePath: res.tempFilePath,
+				// 				// filePath: escape(res.tempFilePath),
+				// 				// 如果文件名包含中文,建议使用escape(res.tempFilePath)转码,防止ios和安卓客户端导致的差异
+				// 				success: function(res) {
+				// 					console.log("打开文档成功");
+				// 				},
+				// 			});
+				// 		}
+				// 	},
+				// 	complete: () => {
+				// 		uni.hideLoading();
+				// 	},
+				// });
 			},
 		},
 	};
@@ -63,4 +66,4 @@
 		color: #2f42ca;
 		text-decoration: underline;
 	}
-</style>
+</style>

+ 10 - 1
pages.json

@@ -24,7 +24,16 @@
 			}
 
 		}
-	],
+	    ,{
+            "path" : "pages/preview/preview",
+            "style" :                                                                                    
+            {
+                "navigationBarTitleText": "",
+                "enablePullDownRefresh": false
+            }
+            
+        }
+    ],
 	"globalStyle": {
 		"app-plus": {
 			"titleNView": false

+ 1 - 1
pages/audit/list.vue

@@ -20,7 +20,7 @@
 					</view>
 					<view class="item">
 						<view class="label">提交人</view>
-						<view class="value">{{item.AuthorInfo.CName}}</view>
+						<view class="value">{{item.AuthorInfo && item.AuthorInfo.CName}}</view>
 					</view>
 				</view>
 			</uni-card>

+ 31 - 0
pages/preview/preview.vue

@@ -0,0 +1,31 @@
+<template>
+	<web-view style="width: 100%;height: 100vh;" :src="src"></web-view>
+</template>
+
+<script>
+	export default {
+		data() {
+			return {
+				fileSrc: ""
+			}
+		},
+		onLoad(options) {
+			this.fileSrc = options.fileSrc
+		},
+		computed: {
+			src() {
+				if (this.fileSrc) {
+					return `http://vw.usdoc.cn/?src=${this.fileSrc}`
+				}
+				return ""
+			}
+		},
+		methods: {
+
+		}
+	}
+</script>
+
+<style>
+
+</style>