闫增涛
2024-11-06 12e72812d28c95394a17ec495985d44aff1c77f7
packageDomain/pages/resourceDetails/document/index.js
@@ -41,6 +41,7 @@
    distance: 0, //记录手指移动距离
    scale: 1, //定义初始化的页面缩放大小
    newScale: 1, //记录新的页面缩放大小
    pdfSrc: ''
  },
  /**
   * 生命周期函数--监听页面加载
@@ -49,7 +50,6 @@
    wx.setNavigationBarTitle({
      title: '资源详情'
    });
    console.log(options);
    const systInfo = wx.getSystemInfoSync();
    const menu = wx.getMenuButtonBoundingClientRect(); // 胶囊信息
    const navBarHeight = (menu.top - systInfo.statusBarHeight) * 2 + menu.height; // 导航栏高度
@@ -79,7 +79,6 @@
    } else {
      this.resourceDetailsData()
    }
  },
  /**
@@ -105,7 +104,7 @@
    this.setData({
      pauseTime: Date.now()
    })
    if (wx.getStorageSync(app.config.tokenKey) && epubObj && epubObj.bookBuy) {
    if (wx.getStorageSync(app.config.tokenKey)) {
      let duration = this.data.pauseTime - this.data.startTime
      this.count(duration)
    }
@@ -118,7 +117,7 @@
    this.setData({
      pauseTime: Date.now()
    })
    if (wx.getStorageSync(app.config.tokenKey) && epubObj && epubObj.bookBuy) {
    if (wx.getStorageSync(app.config.tokenKey)) {
      let duration = this.data.pauseTime - this.data.startTime
      this.count(duration)
    }
@@ -152,9 +151,7 @@
  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {
  },
  onReachBottom() {},
  /**
   * 用户点击右上角分享
@@ -197,7 +194,6 @@
      query.storeInfo = this.data.storeInfo
    }
    app.MG.store.getProductDetail(query).then((res) => {
      console.log(res);
      res.datas.cmsDatas[0].datas.forEach((item) => {
        if (this.data.productLinkPath == item.productLinkPath) {
          this.handleTeachData(item)
@@ -286,7 +282,6 @@
  //刚进来的时候调用
  handleTeachData(item) {
    //图片
    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,
@@ -307,15 +302,25 @@
      })
      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'
            const src = app.config.requestCtx + '/file/GetPdfPageImage?md5=' + md5 + '&index=' + (i + 1) + '&dpi=300'
            naturalResources.push(src)
          }
        }
@@ -331,7 +336,6 @@
  handleTap: function () {
    const naturalResources = this.data.naturalResources;
    naturalResources.forEach(function (item) {
      // console.log(item);
    });
  },
@@ -368,7 +372,6 @@
    const {
      trigger
    } = e.detail;
    console.log(trigger);
    this.setData({
      visible: false,
    });