| | |
| | | } |
| | | }) |
| | | }, |
| | | 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> |