From 4a9955330070cf8abd78d95aaa2067d9a06a88c3 Mon Sep 17 00:00:00 2001
From: 闫增涛 <1829501689@qq.com>
Date: 星期二, 07 五月 2024 10:05:59 +0800
Subject: [PATCH] 各页面bug修改

---
 packageDomain/pages/resourceDetails/document/index.js |  189 +++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 164 insertions(+), 25 deletions(-)

diff --git a/packageDomain/pages/resourceDetails/document/index.js b/packageDomain/pages/resourceDetails/document/index.js
index 3db416d..0ca3e50 100644
--- a/packageDomain/pages/resourceDetails/document/index.js
+++ b/packageDomain/pages/resourceDetails/document/index.js
@@ -1,4 +1,5 @@
 // pages/resourceDetails/document/index.js
+import Toast from 'tdesign-miniprogram/toast/index';
 const app = getApp()
 Page({
 
@@ -6,6 +7,11 @@
    * 椤甸潰鐨勫垵濮嬫暟鎹�
    */
   data: {
+    visible: false,
+    showIndex: false,
+    closeBtn: false,
+    deleteBtn: false,
+    images: [],
     webpageSrc: '',
     navBarHeight: '',
     barHeight: '',
@@ -23,16 +29,26 @@
     naturalResources: [],
     titleName: '',
     pdfDatA: [],
+    startTime: "", //杩涘叆椤甸潰褰撳墠鏃堕棿
+    pauseTime: 0, //鏆傚仠鏃堕棿
+    applyState: '',
+    deadline: '',
+    lzoomFlag: false, //瀹氫箟 缂╂斁浜嬩欢 鑺傛祦闃�,闃叉涓�娆$缉鏀捐Е鍙戜袱娆$缉鏀句簨浠�
+    distance: 0, //璁板綍鎵嬫寚绉诲姩璺濈
+    scale: 1, //瀹氫箟鍒濆鍖栫殑椤甸潰缂╂斁澶у皬
+    newScale: 1, //璁板綍鏂扮殑椤甸潰缂╂斁澶у皬
   },
   /**
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇
    */
   onLoad(options) {
+    wx.setNavigationBarTitle({
+      title: '璧勬簮璇︽儏'
+    });
     console.log(options);
     const systInfo = wx.getSystemInfoSync();
     const menu = wx.getMenuButtonBoundingClientRect(); // 鑳跺泭淇℃伅
     const navBarHeight = (menu.top - systInfo.statusBarHeight) * 2 + menu.height; // 瀵艰埅鏍忛珮搴�
-
     this.setData({
       navBarHeight: navBarHeight,
       barHeight: systInfo.statusBarHeight,
@@ -42,7 +58,9 @@
       cmsId: options.cmsId,
       parentName: options.parentName,
       parentProductLinkPath: options.parentProductLinkPath,
-      productLinkPath: options.productLinkPath
+      productLinkPath: options.productLinkPath,
+      applyState: options.applyState,
+      deadline: options.deadline
     })
     this.resourceDetailsData()
   },
@@ -58,23 +76,55 @@
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鏄剧ず
    */
   onShow() {
-
+    this.setData({
+      startTime: Date.now()
+    })
   },
 
   /**
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰闅愯棌
    */
   onHide() {
-
+    this.setData({
+      pauseTime: Date.now()
+    })
+    if (wx.getStorageSync(app.config.tokenKey) && epubObj && epubObj.bookBuy) {
+      let duration = this.data.pauseTime - this.data.startTime
+      this.count(duration)
+    }
   },
 
   /**
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍗歌浇
    */
   onUnload() {
-
+    this.setData({
+      pauseTime: Date.now()
+    })
+    if (wx.getStorageSync(app.config.tokenKey) && epubObj && epubObj.bookBuy) {
+      let duration = this.data.pauseTime - this.data.startTime
+      this.count(duration)
+    }
   },
 
+  count(timeStr) {
+    const data = {
+      appRefCode: app.config.appRefCode,
+      type: 'LearningTime', //缁熻绫诲瀷--闃呰鏃堕暱
+      data: timeStr + '', //缁熻鍐呭--鏃堕暱姣
+      event: 'LearningTime',
+      sysType: 'App'
+    }
+    //闃呰鍟嗗搧鐨刬d
+    if (this.data.bookId) {
+      data.productId = this.data.bookId
+    }
+    //闃呰璧勬簮鐨刬d
+    if (this.data.cmsId) {
+      data.cmsItemId = this.data.cmsId
+    }
+    app.MG.job.newJobWithApiNewEvent(data).then((res) => {})
+  },
   /**
    * 椤甸潰鐩稿叧浜嬩欢澶勭悊鍑芥暟--鐩戝惉鐢ㄦ埛涓嬫媺鍔ㄤ綔
    */
@@ -127,11 +177,6 @@
     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)
           this.setData({
@@ -139,14 +184,21 @@
             selectType: item.selectType
           })
         }
-
-
       })
     })
   },
   //zpi鏂囦欢涓嬭浇
   onDownloadButton() {
     const item = this.data.zipData;
+    if (this.data.applyState !== 'Normal') {
+      if (!this.data.deadline == '姘镐箙') {
+        const flag = new Date(this.data.deadline) > new Date()
+        return wx.showToast({
+          icon: 'none',
+          title: '璇峰厛鐢宠涓嬭浇',
+        })
+      }
+    }
     if (!item || !item.file) {
       wx.showToast({
         title: '鏂囦欢淇℃伅缂哄け',
@@ -154,12 +206,10 @@
       });
       return;
     }
-
     const downloadUrl = app.config.requestCtx + '/file/api/ApiDownload?md5=' + item.file;
     wx.showLoading({
       title: '姝e湪涓嬭浇...',
     });
-
     wx.downloadFile({
       url: downloadUrl,
       success(res) {
@@ -214,11 +264,12 @@
   //鍒氳繘鏉ョ殑鏃跺�欒皟鐢�
   handleTeachData(item) {
     //鍥剧墖
+    console.log(item, 'item11111');
     if (item.selectType == 'picture') {
       this.setData({
-        showData: app.config.requestCtx + '/file/api/ApiDownload?md5=' + item.file,
-
+        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');
     }
     // 涓嬭浇鏂囦欢zip
     if (item.selectType == 'zip') {
@@ -232,10 +283,11 @@
         webpageSrc: item.jsek_link
       })
     }
-
     //鏂囨。绛�
     if (item.selectType == 'pdf' || item.selectType == 'document') {
-      app.MG.file.getPdfInfo({ md5: item.file }).then((res) => {
+      app.MG.file.getPdfInfo({
+        md5: item.file
+      }).then((res) => {
         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'
@@ -244,24 +296,111 @@
           }
         }
       })
-
-
-
-
     }
   },
-
-
 
   handleTap: function () {
     const naturalResources = this.data.naturalResources;
     naturalResources.forEach(function (item) {
       // console.log(item);
     });
-  }
+  },
 
+  onClick() {
+    this.setData({
+      images: [
+        this.data.showData,
+        // 'https://tdesign.gtimg.com/mobile/demos/swiper2.png',
+      ],
+      showIndex: true,
+      visible: true,
+    });
+  },
+  onChange(e) {
+    const {
+      index
+    } = e.detail;
+    console.log('change', index);
+  },
 
+  onDelete(e) {
+    const {
+      index
+    } = e.detail;
 
+    Toast({
+      context: this,
+      selector: '#t-toast',
+      message: `鍒犻櫎绗�${index + 1}涓猔,
+    });
+  },
 
+  onClose(e) {
+    const {
+      trigger
+    } = e.detail;
+    console.log(trigger);
+    this.setData({
+      visible: false,
+    });
+  },
+  //棰勮鍥剧墖锛屾斁澶ч瑙�
+  preview(event) {
+    let urls = [event.currentTarget.dataset.src]
+    wx.previewImage({
+      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绉诲姩鍚庣殑鍧愭爣鍜寉绉诲姩鍚庣殑鍧愭爣
+  //     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
+  //     })
+  //   }
+  // },
 })
\ No newline at end of file

--
Gitblit v1.9.1