浏览代码

update 直接在线看文档

linweizeng 3 年之前
父节点
当前提交
45bde7e9d5
共有 3 个文件被更改,包括 36 次插入25 次删除
  1. 5 5
      common/router/index.js
  2. 2 1
      manifest.json
  3. 29 19
      pages/fileView/fileView.vue

+ 5 - 5
common/router/index.js

@@ -9,20 +9,20 @@ import {
 Vue.use(Router)
 //初始化
 const router = new Router({
-	encodeURI: true,
+	encodeURI: false,
 	routes: [...modules] //路由表
 });
 
-const whiteList = ['/pages/login/login']
+const whiteList = ['/pages/login/login', '/pages/fileView/fileView']
 //全局路由前置守卫
 router.beforeEach((to, from, next) => {
-
 	let token = uni.getStorageSync(ACCESS_TOKEN);
-
 	if (token) {
 		next()
 	} else {
-		if (to.name == 'login') {
+		if (whiteList.indexOf(to.path) !== -1) {
+			next()
+		} else if (to.name == 'login') {
 			next()
 		} else if (to.name == 'zhuce') {
 			next()

+ 2 - 1
manifest.json

@@ -92,7 +92,8 @@
             }
         },
         "router" : {
-            "base" : "/h5/"
+            "base" : "/h5/",
+            "mode" : "hash"
         },
         "devServer" : {
             "https" : false

+ 29 - 19
pages/fileView/fileView.vue

@@ -7,6 +7,8 @@
 		</cu-custom> -->
 
 		<web-view :src="pdfUrl"></web-view>
+
+		<!-- <view style="position: fixed;top: 15rpx;right: 50rpx;z-index: 999;color: #ffffff;">55555</view> -->
 	</view>
 </template>
 
@@ -21,29 +23,37 @@
 				type: '1'
 			}
 		},
+		created() {
+			let url = window.location.href
+			let urlOne = url.split('#')[1]
+			let urlTwo = urlOne.split('?')[1]
+			let urlThree = urlTwo.split('=')
+			if (urlThree[0] == 'url') {
+				this.pdfUrl = '/hybrid/html/web/viewer.html?file=' + decodeURIComponent(urlThree[1])
+				// this.pdfUrl = '/hybrid/html/web/viewer.html?file=' + encodeURIComponent(decodeURIComponent(urlThree[1]))
+			}
 
+		},
+		mounted() {
+			window.addEventListener('mousedown', this.handleonmousedown)
+		},
 		onLoad(option) {
-
-			if (option.type) {
-				this.type = option.type
-			}
-			if (this.type == 1) {
-				this.getDe(option.id)
-			} else {
-				this.getDe2(option.id)
+			if (!option.url) {
+				if (option.type) {
+					this.type = option.type
+				}
+				if (this.type == 1) {
+					this.getDe(option.id)
+				} else {
+					this.getDe2(option.id)
+				}
 			}
-			/**
-			 * 浏览情景
-			 */
-
-			// 浏览情景1:浏览本地的pdf文件
-			//this.pdfUrl = '/hybrid/html/web/viewer.html?file=./compressed.tracemonkey-pldi-09.pdf'
 
-			// 浏览情景2:浏览在线的pdf文件
-			// this.pdfUrl = '/hybrid/html/web/viewer.html?file=' + encodeURIComponent(
-			// 	"https://www.mingjianlims.com/group1/M00/00/0C/rBKdLGHuElCAVpUEAAY6VxViWJE056.pdf")
 		},
 		methods: {
+			handleonmousedown(e) {
+				console.log(e)
+			},
 			/**
 			 * 根据报告的id查询没有盖章文档路径
 			 */
@@ -63,8 +73,8 @@
 							let dataItem = data[0]
 							let url =
 								http.apiHosp + dataItem.FILE_PATH_
-							console.log(url)
-							this.pdfUrl = '/hybrid/html/web/viewer.html?file=' + encodeURIComponent(url)
+							// this.pdfUrl = '/hybrid/html/web/viewer.html?file=' + encodeURIComponent(url)
+							this.pdfUrl = '/hybrid/html/web/viewer.html?file=' + url
 						}
 
 					}