闫增涛
2024-05-07 4a9955330070cf8abd78d95aaa2067d9a06a88c3
packageDomain/pages/resourceDetails/document/index.js
@@ -33,6 +33,10 @@
    pauseTime: 0, //暂停时间
    applyState: '',
    deadline: '',
    lzoomFlag: false, //定义 缩放事件 节流阀,防止一次缩放触发两次缩放事件
    distance: 0, //记录手指移动距离
    scale: 1, //定义初始化的页面缩放大小
    newScale: 1, //记录新的页面缩放大小
  },
  /**
   * 生命周期函数--监听页面加载
@@ -342,12 +346,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
  //     })
  //   }
  // },
})