litian
2024-04-01 6a7e1f5b8a08728860140652d442209f810d58e1
packageBookService/pages/components/webView/index.js
@@ -10,6 +10,8 @@
    link: false,
    epubObj: null,
    currentPage: '',
    pdfList: [],
    skeletonLoding: true,
  },
  /**
@@ -27,8 +29,10 @@
        src: ''
      })
      if (options) {
        console.log(options)
        wx.setNavigationBarTitle({
          title: options.fileName,
          skeletonLoding: true
        })
        this.getProgress(options)
      }
@@ -44,6 +48,7 @@
  },
  setWebViewSrc: function (data) {
    let that = this;
    var url = "";
    if (data.fileType == 'epub') {
      if (data.bookBuy) {
@@ -69,21 +74,36 @@
          "&recordLocation=" +
          this.data.currentPage + "&freeEpubPage=" + data.freePage
      }
      this.setData({
        src: url,
        skeletonLoding: false,
      })
    } else {
      url = app.config.pdfUrl +
        "?md5=" +
        data.md5 +
        "&bookName=" +
        data.fileName +
        "&url=" + app.config.requestCtx +
        "&token=" +
        wx.getStorageSync(app.config.tokenKey) +
        "&recordLocation=" +
        this.data.currentPage;
      this.setData({
        navigationBarTitleText: data.fileName
      })
      app.MG.file.getPdfInfo({
        md5: data.md5
      }).then((res) => {
        let pageCount = data.bookBuy ? res.totalPages : Number(data.freePage)
        if (pageCount) {
          let list = [];
          for (let i = 0; i < pageCount; i++) {
            const src = app.config.requestCtx + '/file/GetPdfPageImage?md5=' + data.md5 + '&index=' + (i + 1) + '&dpi=300'
            list.push(src)
          }
          console.log(list)
          this.setData({
            pdfList: list,
            skeletonLoding: false,
          })
        }
      })
    }
    this.setData({
      src: url
    })
  },