| | |
| | | */ |
| | | onLoad(options) { |
| | | var that = this |
| | | // this.getOpenerEventChannel().on('acceptDataFromOpenerPage', function (data) { |
| | | // that.setData({ |
| | | // fileId: data.fileId |
| | | // }) |
| | | this.getOpenerEventChannel().on('acceptDataFromOpenerPage', function (data) { |
| | | that.setData({ |
| | | fileId: data.fileId |
| | | }) |
| | | |
| | | // that.getFile() |
| | | // }) |
| | | that.getFile() |
| | | that.getFile() |
| | | }) |
| | | // that.getFile() |
| | | }, |
| | | |
| | | /** |
| | |
| | | } else { |
| | | return undefined |
| | | } |
| | | }, |
| | | |
| | | openFile () { |
| | | let content = this.data.content |
| | | if (content.mfFileUrl == undefined || content.mfFileUrl == null || content.mfFileUrl.length == 0) { |
| | | wx.showToast({ |
| | | title: '文件暂时无法访问', |
| | | duration: 1000, |
| | | icon: 'none', |
| | | mask: true, |
| | | }) |
| | | return |
| | | } |
| | | console.log(content.mfFileUrl); |
| | | wx.showLoading({ |
| | | title: ' 文件下载中', |
| | | mask: true, |
| | | }) |
| | | wx.downloadFile({ |
| | | url: content.mfFileUrl, |
| | | success: function (res) { |
| | | wx.hideLoading() |
| | | const filePath = res.tempFilePath |
| | | wx.openDocument({ |
| | | filePath: filePath, |
| | | success: function (res) { |
| | | console.log('打开文档成功') |
| | | }, |
| | | fail (error) { |
| | | console.log(error); |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | }) |