From 79ea9dfd43f0e000abcba7ac2168cee76b8cd765 Mon Sep 17 00:00:00 2001
From: zhouwenxuan <1175765986@qq.com>
Date: 星期二, 20 六月 2023 16:34:00 +0800
Subject: [PATCH] 文件预览
---
pages/tabBar/notice/detail.vue | 88 +++++++++++++++++++++----------------------
1 files changed, 43 insertions(+), 45 deletions(-)
diff --git a/pages/tabBar/notice/detail.vue b/pages/tabBar/notice/detail.vue
index 36f4794..08871d0 100644
--- a/pages/tabBar/notice/detail.vue
+++ b/pages/tabBar/notice/detail.vue
@@ -145,51 +145,49 @@
}
})
},
- openFile(item) {
- let fileUrl = '';
- console.log("iiii",item)
- if(item.role == 'leader'){
- fileUrl = VUE_APP_BASE_URL + item.attachment;
- console.log("url",fileUrl)
- }else {
- fileUrl = VUE_APP_BASE_URL + item.attachement;
- console.log("url",VUE_APP_BASE_URL + item.attachement)
- }
-
- uni.downloadFile({
- url: encodeURI('http://192.168.0.38:8086/uploadtest/2023/naturalDisaster/Warninginfo/0620/abc051b6ee66402d98e7b27216662d17.pdf'),
- header: {
- 'Content-type': 'application/json',
- 'tk':uni.getStorageSync('tk'),
- 'uid': uni.getStorageSync('uid')
- },
- success:function(res){
- console.log("下载res",res);
- var filePath = res.tempFilePath;
- const sidx = filePath.lastIndexOf('(');
- const eidx = filePath.lastIndexOf(')');
- // 用于处理文档打开问题(ps:第一次打开 第二次无法打开问题)
- if (sidx > -1 && eidx > -1) {
- const restr = filePath.substr(sidx, eidx - sidx + 1);
- filePath = filePath.replace(restr, '');
- }
- // plus.runtime.openFile(filePath)
- uni.openDocument({
- filePath: escape(filePath),
- success:function(){
- console.log('成功')
- },
- fail:function(){
- uni.showToast({
- icon: 'none',
- title: '暂不支持此类型',
- duration: 2000
- })
- }
- })
- }
- })
- }
+ openFile(item) {
+ let fileUrl = '';
+ console.log("iiii",item)
+ if(this.detailData.role == 'leader'){
+ fileUrl = VUE_APP_BASE_URL + item.attachment;
+ }else {
+ fileUrl = VUE_APP_BASE_URL + item.attachement;
+ }
+ console.log("urlllllllllllll",fileUrl)
+ uni.downloadFile({
+ url: fileUrl,
+ header: {
+
+ // 'tk':uni.getStorageSync('tk'),
+ // 'uid': uni.getStorageSync('uid'),
+ },
+ success:function(res){
+ console.log("下载res",res);
+ var filePath = res.tempFilePath;
+ const sidx = filePath.lastIndexOf('(');
+ const eidx = filePath.lastIndexOf(')');
+ // 用于处理文档打开问题(ps:第一次打开 第二次无法打开问题)
+ if (sidx > -1 && eidx > -1) {
+ const restr = filePath.substr(sidx, eidx - sidx + 1);
+ filePath = filePath.replace(restr, '');
+ }
+ // plus.runtime.openFile(filePath)
+ uni.openDocument({
+ filePath: filePath,
+ success:function(){
+ console.log('成功')
+ },
+ fail:function(){
+ uni.showToast({
+ icon: 'none',
+ title: '暂不支持此类型',
+ duration: 2000
+ })
+ }
+ })
+ }
+ })
+ }
}
}
</script>
--
Gitblit v1.9.2