From 558845242a07b68f42fa1802c45ab2769395d8b8 Mon Sep 17 00:00:00 2001
From: 闫增涛 <1829501689@qq.com>
Date: 星期一, 29 四月 2024 14:31:30 +0800
Subject: [PATCH] 合并代码

---
 packageDomain/pages/resourceDetails/document/index.js |   80 ++++++++++++++++++++++++++++++++++++---
 1 files changed, 73 insertions(+), 7 deletions(-)

diff --git a/packageDomain/pages/resourceDetails/document/index.js b/packageDomain/pages/resourceDetails/document/index.js
index 3db416d..9cf27f2 100644
--- a/packageDomain/pages/resourceDetails/document/index.js
+++ b/packageDomain/pages/resourceDetails/document/index.js
@@ -23,11 +23,27 @@
     naturalResources: [],
     titleName: '',
     pdfDatA: [],
+    startTime: "", //杩涘叆椤甸潰褰撳墠鏃堕棿
+    pauseTime: 0, //鏆傚仠鏃堕棿
+    applyState: '',
+    deadline: '',
   },
   /**
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇
    */
   onLoad(options) {
+
+    wx.setNavigationBarTitle({
+      title: '璧勬簮璇︽儏'
+    });
+
+
+
+
+
+
+
+
     console.log(options);
     const systInfo = wx.getSystemInfoSync();
     const menu = wx.getMenuButtonBoundingClientRect(); // 鑳跺泭淇℃伅
@@ -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,56 @@
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鏄剧ず
    */
   onShow() {
-
+    this.setData({
+      startTime: Date.now()
+    })
   },
 
   /**
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰闅愯棌
    */
   onHide() {
-
+    this.setData({
+      pauseTime: Date.now()
+    })
+    if (wx.getStorageSync(app.config.tokenKey) && 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.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) => {})
+  },
   /**
    * 椤甸潰鐩稿叧浜嬩欢澶勭悊鍑芥暟--鐩戝惉鐢ㄦ埛涓嬫媺鍔ㄤ綔
    */
@@ -147,6 +198,18 @@
   //zpi鏂囦欢涓嬭浇
   onDownloadButton() {
     const item = this.data.zipData;
+    if (this.data.applyState !== 'Normal') {
+      return wx.showToast({
+        icon: 'none',
+        title: '璇峰厛鐢宠涓嬭浇',
+      })
+    } else {
+      const flag = new Date(this.data.deadline) > new Date()
+      if (!flag) return wx.showToast({
+        icon: 'none',
+        title: '璇峰厛鐢宠涓嬭浇',
+      })
+    }
     if (!item || !item.file) {
       wx.showToast({
         title: '鏂囦欢淇℃伅缂哄け',
@@ -154,7 +217,6 @@
       });
       return;
     }
-
     const downloadUrl = app.config.requestCtx + '/file/api/ApiDownload?md5=' + item.file;
     wx.showLoading({
       title: '姝e湪涓嬭浇...',
@@ -214,9 +276,11 @@
   //鍒氳繘鏉ョ殑鏃跺�欒皟鐢�
   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,
 
       })
     }
@@ -235,7 +299,9 @@
 
     //鏂囨。绛�
     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'

--
Gitblit v1.9.1