riku
2022-08-11 5656daeb79c6d4d3f9fc78f981c7faf96582d2f1
pages/module_consult/consultdetail/consultdetail.js
@@ -18,14 +18,14 @@
   */
  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()
  },
  /**
@@ -75,5 +75,39 @@
    } 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);
          }
        })
      }
    })
  }
})