| | |
| | | } |
| | | } |
| | | }, |
| | | |
| | | checkFileExtensions(str) { |
| | | const extensions = ['pdf', 'doc', 'docx', 'xls', 'xlsx']; |
| | | return extensions.some(extension => str.includes(extension)); |
| | | }, |
| | | previewWechat(urlPdf) { |
| | | uni.showLoading({ |
| | | title: '正在加载中..' |
| | | }) |
| | | uni.downloadFile({ |
| | | url: urlPdf, |
| | | success: function(res) { |
| | | var filePath = res.tempFilePath; |
| | | const index = urlPdf.lastIndexOf("."); |
| | | const suffix = urlPdf.substring(index + 1); |
| | | uni.openDocument({ |
| | | fileType: suffix, |
| | | filePath: filePath, |
| | | showMenu: true, |
| | | success: function(res) { |
| | | console.log('打开文档成功'); |
| | | uni.hideLoading() |
| | | }, |
| | | }); |
| | | }, |
| | | complete: function(r) { |
| | | uni.hideLoading() |
| | | } |
| | | }); |
| | | }, |
| | | } |