闫增涛
2024-11-05 50ca1ad0d141d7dc0ddf29b2d3051b85ceff8f56
packageDomain/pages/resourceDetails/document/index.js
@@ -41,6 +41,7 @@
    distance: 0, //记录手指移动距离
    scale: 1, //定义初始化的页面缩放大小
    newScale: 1, //记录新的页面缩放大小
    pdfSrc: ''
  },
  /**
   * 生命周期函数--监听页面加载
@@ -79,7 +80,6 @@
    } else {
      this.resourceDetailsData()
    }
  },
  /**
@@ -152,21 +152,21 @@
  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {
  },
  onReachBottom() {},
  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {
  },
  onShareAppMessage() {},
  onShareTimeline() {},
  goBack() {
    wx.navigateBack()
  },
  resourceDetailsData() {
    wx.showLoading({
      title: '正在加载...',
    });
    let query = {
      path: '*',
      queryType: '*',
@@ -284,39 +284,55 @@
  //刚进来的时候调用
  handleTeachData(item) {
    //图片
    console.log(item, 'item11111');
    if (item.selectType == 'picture') {
      this.setData({
        showData: item.file ? app.config.requestCtx + '/file/api/ApiDownload?md5=' + item.file : app.config.requestCtx + '/file/api/ApiDownload?md5=' + item.freeFile,
      })
      console.log(this.data.showData, 'showData');
      wx.hideLoading();
    }
    // 下载文件zip
    if (item.selectType == 'zip') {
      this.setData({
        zipData: item
      })
      wx.hideLoading();
    }
    //网页
    if (item.selectType == 'webpage') {
      this.setData({
        webpageSrc: item.jsek_link
      })
      wx.hideLoading();
    }
    // if (item.selectType == 'pdf') {
    //   console.log('pdf', item);
    //   wx.hideLoading()
    //   let md5 = item.file ? item.file : item.freeFile
    //   let pdfSrc = app.config.pdfUrl + "?MD5=" + md5 + "&url=" + app.config.requestCtx + '&currentPage=' + "1" + "&isPreview=" + false + "&warterMark=" + "北京师范大学出版社" + "&previewPages=" + 30 + "&token=" + wx.getStorageSync(app.config.tokenKey)
    //   this.setData({
    //     pdfSrc: pdfSrc
    //   })
    // }
    //文档等
    if (item.selectType == 'pdf' || item.selectType == 'document') {
    if (item.selectType == 'document' || item.selectType == 'pdf') {
      let md5 = item.file ? item.file : item.freeFile
      app.MG.file.getPdfInfo({
        md5: item.file
        md5: md5
      }).then((res) => {
        let naturalResources = []
        if (res && res.totalPages) {
          for (let i = 0; i < res.totalPages; i++) {
            const src = app.config.requestCtx + '/file/GetPdfPageImage?md5=' + item.file + '&index=' + (i + 1) + '&dpi=300'
            this.data.naturalResources.push(src)
            // console.log(this.data.naturalResources, ' this.data.naturalResources');
            const src = app.config.requestCtx + '/file/GetPdfPageImage?md5=' + md5 + '&index=' + (i + 1) + '&dpi=300'
            naturalResources.push(src)
          }
        }
        this.setData({
          naturalResources
        })
        wx.hideLoading();
      })
    }
  },
  handleTap: function () {