Browse Source

2024-2-24 文件在线预览

dzl 9 months ago
parent
commit
8003efc61b

+ 2 - 2
manifest.json

@@ -2,8 +2,8 @@
     "name" : "协同办公",
     "appid" : "__UNI__EEB5AF5",
     "description" : "",
-    "versionName" : "1.7.3",
-    "versionCode" : 173,
+    "versionName" : "1.7.5",
+    "versionCode" : 175,
     "transformPx" : false,
     "app-plus" : {
         /* 5+App特有相关 */

+ 17 - 0
package-lock.json

@@ -0,0 +1,17 @@
+{
+  "name": "wjw-app",
+  "lockfileVersion": 3,
+  "requires": true,
+  "packages": {
+    "": {
+      "dependencies": {
+        "base-64": "^1.0.0"
+      }
+    },
+    "node_modules/base-64": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmmirror.com/base-64/-/base-64-1.0.0.tgz",
+      "integrity": "sha512-kwDPIFCGx0NZHog36dj+tHiwP4QMzsZ3AgMViUBKI0+V5n4U0ufTCUMhnQ04diaRI8EX/QcPfql7zlhZ7j4zgg=="
+    }
+  }
+}

+ 5 - 0
package.json

@@ -0,0 +1,5 @@
+{
+  "dependencies": {
+    "base-64": "^1.0.0"
+  }
+}

+ 8 - 0
pages.json

@@ -182,6 +182,14 @@
 			"navigationBarTitleText" : "",
 			"enablePullDownRefresh" : false
 		}
+	},
+	{
+		"path" : "pages/office/office",
+		"style" : 
+		{
+			"navigationBarTitleText" : "",
+			"enablePullDownRefresh" : false
+		}
 	}],
 	"globalStyle": {
 		"navigationBarTextStyle": "white",

+ 41 - 38
pages/emailInfo/emailInfo.vue

@@ -64,45 +64,48 @@
 			//下载附件
 			downLoad(v){
 				let that = this
-				uni.showLoading({
-					title:"打开中...",
+				uni.navigateTo({
+					url:"/pages/office/office?url="+getApp().globalData.saveUrl+v
 				})
-				if(that.list1.indexOf(v) == -1){
-					uni.downloadFile({
-					  url:getApp().globalData.saveUrl+ v,
-					  success: function(res) {
-					    if (res.statusCode === 200) {
-							that.list1.push(v)
-							that.list2.push(res.tempFilePath)
-					      uni.openDocument({
-					        filePath: res.tempFilePath,
-							success: function (res) {
-								uni.hideLoading();
-							}
-					      });
-					    }else{
-							uni.hideLoading()
-							uni.showToast({
-								title:"下载失败",
-								icon:'none'
-							})
-						}
-					  },fail:function(){
-						  uni.hideLoading()
-						  uni.showToast({
-						  	title:"下载失败",
-							icon:'none'
-						  })
-					  }
-					});
-				}else{
-					uni.openDocument({
-					  filePath: that.list2[that.list1.indexOf(v)],
-					  success: function (res) {
-					  	uni.hideLoading();
-					  }
-					});
-				}
+				// uni.showLoading({
+				// 	title:"打开中...",
+				// })
+				// if(that.list1.indexOf(v) == -1){
+				// 	uni.downloadFile({
+				// 	  url:getApp().globalData.saveUrl+ v,
+				// 	  success: function(res) {
+				// 	    if (res.statusCode === 200) {
+				// 			that.list1.push(v)
+				// 			that.list2.push(res.tempFilePath)
+				// 	      uni.openDocument({
+				// 	        filePath: res.tempFilePath,
+				// 			success: function (res) {
+				// 				uni.hideLoading();
+				// 			}
+				// 	      });
+				// 	    }else{
+				// 			uni.hideLoading()
+				// 			uni.showToast({
+				// 				title:"下载失败",
+				// 				icon:'none'
+				// 			})
+				// 		}
+				// 	  },fail:function(){
+				// 		  uni.hideLoading()
+				// 		  uni.showToast({
+				// 		  	title:"下载失败",
+				// 			icon:'none'
+				// 		  })
+				// 	  }
+				// 	});
+				// }else{
+				// 	uni.openDocument({
+				// 	  filePath: that.list2[that.list1.indexOf(v)],
+				// 	  success: function (res) {
+				// 	  	uni.hideLoading();
+				// 	  }
+				// 	});
+				// }
 				
 			}
 		}

+ 41 - 38
pages/fwMessage/fwMessage.vue

@@ -658,45 +658,48 @@
 			//下载附件
 			downLoad(v){
 				let that = this
-				uni.showLoading({
-					title:"打开中...",
+				uni.navigateTo({
+					url:"/pages/office/office?url="+getApp().globalData.saveUrl+v
 				})
-				if(that.list3.indexOf(v) == -1){
-					uni.downloadFile({
-					  url:getApp().globalData.saveUrl+v,
-					  success: function(res) {
-					    if (res.statusCode === 200) {
-							that.list3.push(v)
-							that.list2.push(res.tempFilePath)
-					      uni.openDocument({
-					        filePath: res.tempFilePath,
-							success: function (res) {
-								uni.hideLoading();
-							}
-					      });
-					    }else{
-							uni.hideLoading()
-							uni.showToast({
-								title:"下载失败",
-								icon:'none'
-							})
-						}
-					  },fail:function(){
-						  uni.hideLoading()
-						  uni.showToast({
-						  	title:"下载失败",
-							icon:'none'
-						  })
-					  }
-					});
-				}else{
-					uni.openDocument({
-					  filePath: that.list2[that.list3.indexOf(v)],
-					  success: function (res) {
-					  	uni.hideLoading();
-					  }
-					});
-				}
+				// uni.showLoading({
+				// 	title:"打开中...",
+				// })
+				// if(that.list3.indexOf(v) == -1){
+				// 	uni.downloadFile({
+				// 	  url:getApp().globalData.saveUrl+v,
+				// 	  success: function(res) {
+				// 	    if (res.statusCode === 200) {
+				// 			that.list3.push(v)
+				// 			that.list2.push(res.tempFilePath)
+				// 	      uni.openDocument({
+				// 	        filePath: res.tempFilePath,
+				// 			success: function (res) {
+				// 				uni.hideLoading();
+				// 			}
+				// 	      });
+				// 	    }else{
+				// 			uni.hideLoading()
+				// 			uni.showToast({
+				// 				title:"下载失败",
+				// 				icon:'none'
+				// 			})
+				// 		}
+				// 	  },fail:function(){
+				// 		  uni.hideLoading()
+				// 		  uni.showToast({
+				// 		  	title:"下载失败",
+				// 			icon:'none'
+				// 		  })
+				// 	  }
+				// 	});
+				// }else{
+				// 	uni.openDocument({
+				// 	  filePath: that.list2[that.list3.indexOf(v)],
+				// 	  success: function (res) {
+				// 	  	uni.hideLoading();
+				// 	  }
+				// 	});
+				// }
 				
 			},
 			//保存修改收文信息

+ 81 - 75
pages/newsContent/newsContent.vue

@@ -55,84 +55,90 @@
 			//下载附件
 			downLoad(v){
 				let that = this
-				uni.showLoading({
-					title:"打开中...",
-				})
+				// uni.showLoading({
+				// 	title:"打开中...",
+				// })
 				if(v.path == null){
 					let qaz = v.url.slice(10).replace(/[\\]/g,'/')
-					if(that.list1.indexOf(v.url.slice(10)) == -1){
-						uni.downloadFile({
-						  url:getApp().globalData.updateUrl+qaz,
-						  success: function(res) {
-						    if (res.statusCode === 200) {
-								that.list1.push(v.url.slice(10))
-								that.list2.push(res.tempFilePath)
-						      uni.openDocument({
-						        filePath: res.tempFilePath,
-								success: function (qwe) {
-									uni.hideLoading();
-								}
-						      });
-						    }else{
-								uni.hideLoading()
-								uni.showToast({
-									title:"下载失败",
-									icon:'none'
-								})
-							}
-						  },fail:function(){
-							  uni.hideLoading()
-							  uni.showToast({
-							  	title:"下载失败",
-								icon:'none'
-							  })
-						  }
-						});
-					}else{
-						uni.openDocument({
-						  filePath: that.list2[that.list1.indexOf(v.url.slice(10))],
-						  success: function (res) {
-						  	uni.hideLoading();
-						  }
-						});
-					}
+					uni.navigateTo({
+						url:"/pages/office/office?url="+getApp().globalData.updateUrl+qaz
+					})
+					// if(that.list1.indexOf(v.url.slice(10)) == -1){
+					// 	uni.downloadFile({
+					// 	  url:getApp().globalData.updateUrl+qaz,
+					// 	  success: function(res) {
+					// 	    if (res.statusCode === 200) {
+					// 			that.list1.push(v.url.slice(10))
+					// 			that.list2.push(res.tempFilePath)
+					// 	      uni.openDocument({
+					// 	        filePath: res.tempFilePath,
+					// 			success: function (qwe) {
+					// 				uni.hideLoading();
+					// 			}
+					// 	      });
+					// 	    }else{
+					// 			uni.hideLoading()
+					// 			uni.showToast({
+					// 				title:"下载失败",
+					// 				icon:'none'
+					// 			})
+					// 		}
+					// 	  },fail:function(){
+					// 		  uni.hideLoading()
+					// 		  uni.showToast({
+					// 		  	title:"下载失败",
+					// 			icon:'none'
+					// 		  })
+					// 	  }
+					// 	});
+					// }else{
+					// 	uni.openDocument({
+					// 	  filePath: that.list2[that.list1.indexOf(v.url.slice(10))],
+					// 	  success: function (res) {
+					// 	  	uni.hideLoading();
+					// 	  }
+					// 	});
+					// }
 				}else{
-					if(that.list1.indexOf(v.path) == -1){
-						uni.downloadFile({
-						  url:getApp().globalData.saveUrl+v.path,
-						  success: function(res) {
-						    if (res.statusCode === 200) {
-								that.list1.push(v.path)
-								that.list2.push(res.tempFilePath)
-						      uni.openDocument({
-						        filePath: res.tempFilePath,
-								success: function (qwe) {
-									uni.hideLoading();
-								}
-						      });
-						    }else{
-								uni.hideLoading()
-								uni.showToast({
-									title:"下载失败",
-									icon:'none'
-								})
-							}
-						  },fail:function(){
-							  uni.hideLoading()
-							  uni.showToast({
-							  	title:"下载失败",
-								icon:'none'
-							  })
-						  }
-						});
-					}else{
-						uni.openDocument({
-						  filePath: that.list2[that.list1.indexOf(v.path)],
-						  success: function (res) {
-						  	uni.hideLoading();
-						  }
-						});
-					}
+					uni.navigateTo({
+						url:"/pages/office/office?url="+getApp().globalData.saveUrl+v.path
+					})
+					// if(that.list1.indexOf(v.path) == -1){
+					// 	uni.downloadFile({
+					// 	  url:getApp().globalData.saveUrl+v.path,
+					// 	  success: function(res) {
+					// 	    if (res.statusCode === 200) {
+					// 			that.list1.push(v.path)
+					// 			that.list2.push(res.tempFilePath)
+					// 	      uni.openDocument({
+					// 	        filePath: res.tempFilePath,
+					// 			success: function (qwe) {
+					// 				uni.hideLoading();
+					// 			}
+					// 	      });
+					// 	    }else{
+					// 			uni.hideLoading()
+					// 			uni.showToast({
+					// 				title:"下载失败",
+					// 				icon:'none'
+					// 			})
+					// 		}
+					// 	  },fail:function(){
+					// 		  uni.hideLoading()
+					// 		  uni.showToast({
+					// 		  	title:"下载失败",
+					// 			icon:'none'
+					// 		  })
+					// 	  }
+					// 	});
+					// }else{
+					// 	uni.openDocument({
+					// 	  filePath: that.list2[that.list1.indexOf(v.path)],
+					// 	  success: function (res) {
+					// 	  	uni.hideLoading();
+					// 	  }
+					// 	});
+					// }
 				}
 				
 				

+ 56 - 0
pages/office/office.vue

@@ -0,0 +1,56 @@
+<template>
+	<div class="wrap">
+		 <web-view :src="filePath"></web-view>
+	</div>
+</template>
+
+<script>
+	import Base64 from 'base-64'
+	//引入相关样式
+	export default {
+		data() {
+			return {
+				filePath: "", // 预览地址
+				fileType: "", // 文件类型
+			};
+		},
+		onLoad(options) {
+			console.log(options)
+			this.filePath =`http://121.28.24.104:13898/app/kkfile/onlinePreview?url=${encodeURIComponent(Base64.encode(options.url))}` 
+			// this.fileType = options.type
+			// encodeURIComponent(Base64.encode(options.url))
+		},
+		methods: {
+			 
+		},
+	};
+</script>
+
+<style scoped lang="scss">
+
+	.wrap {
+		width: 100vw;
+		height: 100vh;
+		padding: 40px 0 0 0;
+
+
+		.content {
+			white-space: pre;
+			width: 100%;
+			height: 100%;
+			padding: 20px 10px;
+			background: #fff;
+			overflow-x: auto;
+		}
+
+		.van-loading {
+			background-color: #fff;
+			position: absolute;
+			width: 100vw;
+			height: 100vh;
+			display: flex;
+			align-items: center;
+			justify-content: center;
+		}
+	}
+</style>

+ 42 - 38
pages/swMessage/swMessage.vue

@@ -362,6 +362,7 @@
 			getContent(id) {
 				uni.$u.http.get('/offcial/receive/sel/' + id).then(res => {
 					this.content = res.data
+					console.log(res.data)
 					this.content.workid = id
 					if (this.gdType == true) {
 						this.content.typeId = null //归档分类
@@ -651,45 +652,48 @@
 			//下载附件
 			downLoad(v){
 				let that = this
-				uni.showLoading({
-					title:"打开中...",
+				uni.navigateTo({
+					url:"/pages/office/office?url="+getApp().globalData.saveUrl+v
 				})
-				if(that.list3.indexOf(v) == -1){
-					uni.downloadFile({
-					  url:getApp().globalData.saveUrl+v,
-					  success: function(res) {
-					    if (res.statusCode === 200) {
-							that.list3.push(v)
-							that.list2.push(res.tempFilePath)
-					      uni.openDocument({
-					        filePath: res.tempFilePath,
-							success: function (res) {
-								uni.hideLoading();
-							}
-					      });
-					    }else{
-							uni.hideLoading()
-							uni.showToast({
-								title:"下载失败",
-								icon:'none'
-							})
-						}
-					  },fail:function(){
-						  uni.hideLoading()
-						  uni.showToast({
-						  	title:"下载失败",
-							icon:'none'
-						  })
-					  }
-					});
-				}else{
-					uni.openDocument({
-					  filePath: that.list2[that.list3.indexOf(v)],
-					  success: function (res) {
-					  	uni.hideLoading();
-					  }
-					});
-				}
+				// uni.showLoading({
+				// 	title:"打开中...",
+				// })
+				// if(that.list3.indexOf(v) == -1){
+				// 	uni.downloadFile({
+				// 	  url:getApp().globalData.saveUrl+v,
+				// 	  success: function(res) {
+				// 	    if (res.statusCode === 200) {
+				// 			that.list3.push(v)
+				// 			that.list2.push(res.tempFilePath)
+				// 	      uni.openDocument({
+				// 	        filePath: res.tempFilePath,
+				// 			success: function (res) {
+				// 				uni.hideLoading();
+				// 			}
+				// 	      });
+				// 	    }else{
+				// 			uni.hideLoading()
+				// 			uni.showToast({
+				// 				title:"下载失败",
+				// 				icon:'none'
+				// 			})
+				// 		}
+				// 	  },fail:function(){
+				// 		  uni.hideLoading()
+				// 		  uni.showToast({
+				// 		  	title:"下载失败",
+				// 			icon:'none'
+				// 		  })
+				// 	  }
+				// 	});
+				// }else{
+				// 	uni.openDocument({
+				// 	  filePath: that.list2[that.list3.indexOf(v)],
+				// 	  success: function (res) {
+				// 	  	uni.hideLoading();
+				// 	  }
+				// 	});
+				// }
 			},
 			//查询是否能退回
 			getBackNo(id){