闫增涛
2024-09-19 1674ff52a2874cfdf59bc876290c0d102265ad32
packageDomain/pages/resourceDetails/document/index.js
@@ -1,6 +1,9 @@
// pages/resourceDetails/document/index.js
import Toast from 'tdesign-miniprogram/toast/index';
const app = getApp()
import {
  loginInfo
} from '../../../../assets/js/login';
Page({
  /**
@@ -16,6 +19,7 @@
    navBarHeight: '',
    barHeight: '',
    activeId: '',
    storeInfo: '',
    bookId: '',
    bookName: '',
    cmsId: '',
@@ -33,6 +37,10 @@
    pauseTime: 0, //暂停时间
    applyState: '',
    deadline: '',
    lzoomFlag: false, //定义 缩放事件 节流阀,防止一次缩放触发两次缩放事件
    distance: 0, //记录手指移动距离
    scale: 1, //定义初始化的页面缩放大小
    newScale: 1, //记录新的页面缩放大小
  },
  /**
   * 生命周期函数--监听页面加载
@@ -51,6 +59,7 @@
      activeId: options.activeId,
      bookId: options.bookId,
      bookName: options.bookName,
      storeInfo: options.storeInfo,
      cmsId: options.cmsId,
      parentName: options.parentName,
      parentProductLinkPath: options.parentProductLinkPath,
@@ -58,7 +67,19 @@
      applyState: options.applyState,
      deadline: options.deadline
    })
    this.resourceDetailsData()
    const token = wx.getStorageSync(app.config.tokenKey)
    if (!token) {
      loginInfo(app, (data) => {
        if (data) {
          this.resourceDetailsData()
        } else {
          this.resourceDetailsData()
        }
      })
    } else {
      this.resourceDetailsData()
    }
  },
  /**
@@ -138,9 +159,8 @@
  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {
  },
  onShareAppMessage() {},
  onShareTimeline() {},
  goBack() {
    wx.navigateBack()
  },
@@ -169,6 +189,9 @@
        start: 0,
        size: 999
      }
    }
    if (this.data.storeInfo) {
      query.storeInfo = this.data.storeInfo
    }
    app.MG.store.getProductDetail(query).then((res) => {
      console.log(res);
@@ -260,7 +283,6 @@
  //刚进来的时候调用
  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,
@@ -284,13 +306,17 @@
      app.MG.file.getPdfInfo({
        md5: item.file
      }).then((res) => {
        if (res && res.totalPages) {
          for (let i = 0; i < res.totalPages; i++) {
        let naturalResources = []
        if (res && JSON.parse(res).totalPages) {
          for (let i = 0; i < JSON.parse(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');
            naturalResources.push(src)
          }
        }
        this.setData({
          naturalResources
        })
        console.log('ppt', this.data.naturalResources);
      })
    }
  },
@@ -342,12 +368,61 @@
  },
  //预览图片,放大预览
  preview(event) {
    console.log(event.currentTarget.dataset.src)
    let currentUrl = event.currentTarget.dataset.src
    let urls = [event.currentTarget.dataset.src]
    wx.previewImage({
      current: currentUrl, // 当前显示图片的http链接
      // urls: this.data.showData // 需要预览的图片http链接列表
      urls: urls // 需要预览的图片http链接列表
    })
  },
  // myTouchStart(e) {
  //   //---------------------记录缩放事件信息---------------------
  //   // 当两根手指放上去的时候,将距离(distance)初始化。
  //   let xMove = e.touches[1].clientX - e.touches[0].clientX;
  //   let yMove = e.touches[1].clientY - e.touches[0].clientY;
  //   //计算开始触发两个手指坐标的距离
  //   const distance = Math.sqrt(xMove * xMove + yMove * yMove);
  //   this.setData({
  //     distance: distance
  //   })
  //   //---------------------记录缩放事件信息end---------------------
  // },
  // myTouchMove(e) {
  //   // ----------------监听手势缩小放大事件----------------
  //   // 单手指缩放不做任何操作
  //   if (e.touches.length != 1) {
  //     //双手指运动 x移动后的坐标和y移动后的坐标
  //     let xMove = e.touches[1].clientX - e.touches[0].clientX;
  //     let yMove = e.touches[1].clientY - e.touches[0].clientY;
  //     //双手指运动新的 ditance
  //     let newDistance = Math.sqrt(xMove * xMove + yMove * yMove);
  //     //计算移动的过程中实际移动了多少的距离
  //     let distanceDiff = newDistance - this.data.distance;
  //     // newScale = scale + 0.005 * distanceDiff
  //     console.log('移动距离', distanceDiff);
  //     this.setData({
  //       newScale: this.data.newScale + 0.005 * distanceDiff
  //     })
  //     // 打开缩放监听
  //     // zoomFlag = true
  //     this.setData({
  //       lzoomFlag: true
  //     })
  //     return
  //   }
  //   // ----------------监听手势缩小放大事件end----------------
  // },
  // myTouchEnd() {
  //   if (this.data.lzoomFlag) {
  //     if (this.data.newScale > 1.3) {
  //       console.log("放大了", this.data.newScale);
  //     } else if (this.data.newScale < 0.7, this.data.newScale) {
  //       console.log("缩小了");
  //     }
  //     // 关闭缩放监听
  //     // zoomFlag = false
  //     this.setData({
  //       lzoomFlag: false
  //     })
  //   }
  // },
})