From 3f1ea0a8e4bb02bf7544df8660b15cfa69d6b84a Mon Sep 17 00:00:00 2001
From: litian <C21AF165>
Date: 星期五, 15 三月 2024 18:54:04 +0800
Subject: [PATCH] Merge refs/remotes/origin/master into refs/heads/master

---
 pages/resourceDetails/document/index.js |  205 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 203 insertions(+), 2 deletions(-)

diff --git a/pages/resourceDetails/document/index.js b/pages/resourceDetails/document/index.js
index 6c099d4..3db416d 100644
--- a/pages/resourceDetails/document/index.js
+++ b/pages/resourceDetails/document/index.js
@@ -1,18 +1,50 @@
 // pages/resourceDetails/document/index.js
+const app = getApp()
 Page({
 
   /**
    * 椤甸潰鐨勫垵濮嬫暟鎹�
    */
   data: {
-
+    webpageSrc: '',
+    navBarHeight: '',
+    barHeight: '',
+    activeId: '',
+    bookId: '',
+    bookName: '',
+    cmsId: '',
+    parentName: '',
+    parentProductLinkPath: '',
+    productLinkPath: '',
+    showData: '',
+    titleName: '',
+    selectType: '',
+    zipData: '',
+    naturalResources: [],
+    titleName: '',
+    pdfDatA: [],
   },
-
   /**
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇
    */
   onLoad(options) {
+    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,
+      activeId: options.activeId,
+      bookId: options.bookId,
+      bookName: options.bookName,
+      cmsId: options.cmsId,
+      parentName: options.parentName,
+      parentProductLinkPath: options.parentProductLinkPath,
+      productLinkPath: options.productLinkPath
+    })
+    this.resourceDetailsData()
   },
 
   /**
@@ -62,5 +94,174 @@
    */
   onShareAppMessage() {
 
+  },
+  goBack() {
+    wx.navigateBack()
+  },
+
+  resourceDetailsData() {
+    let query = {
+      path: '*',
+      queryType: '*',
+      productId: this.data.bookId,
+      cmsPath: this.data.parentProductLinkPath,
+      itemFields: {
+        SysType: 'CmsFolder',
+        // 璧勬簮绫诲瀷锛岃瘯璇绘枃浠讹紝鏄惁鍏佽涓嬭浇绛夊弬鏁�
+        selectType: [],
+        freeFile: [],
+        file: [],
+        protectedFile: [],
+        resourcesClassification: [],
+        isDownload: [],
+        jsek_resourceBrief: [],
+        jsek_link: [],
+        jsek_questionBank: [],
+        learnSelectType: []
+      },
+      pading: {
+        start: 0,
+        size: 999
+      }
+    }
+    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({
+            titleName: item.name,
+            selectType: item.selectType
+          })
+        }
+
+
+      })
+    })
+  },
+  //zpi鏂囦欢涓嬭浇
+  onDownloadButton() {
+    const item = this.data.zipData;
+    if (!item || !item.file) {
+      wx.showToast({
+        title: '鏂囦欢淇℃伅缂哄け',
+        icon: 'none'
+      });
+      return;
+    }
+
+    const downloadUrl = app.config.requestCtx + '/file/api/ApiDownload?md5=' + item.file;
+    wx.showLoading({
+      title: '姝e湪涓嬭浇...',
+    });
+
+    wx.downloadFile({
+      url: downloadUrl,
+      success(res) {
+        if (res.statusCode === 200) {
+          // 涓嬭浇鎴愬姛锛屽彲浠ュ湪杩欓噷杩涜涓�浜涙搷浣滐紝渚嬪棰勮銆佷繚瀛樼瓑
+          // 杩欓噷浠ヤ繚瀛樻枃浠跺埌绯荤粺涓轰緥
+          wx.saveFile({
+            tempFilePath: res.tempFilePath,
+            success(saveRes) {
+              wx.hideLoading();
+              wx.showToast({
+                title: '淇濆瓨鎴愬姛',
+              });
+              // 鑾峰彇淇濆瓨鍚庣殑鏂囦欢璺緞
+              const savedFilePath = saveRes.savedFilePath;
+              // 鍙互鍦ㄨ繖閲岃繘琛屽悗缁搷浣滐紝渚嬪鎵撳紑鏂囦欢
+              wx.openDocument({
+                filePath: savedFilePath,
+                success: function () {
+                  console.log('鎵撳紑鏂囨。鎴愬姛')
+                },
+                fail: function (error) {
+                  console.error('鎵撳紑鏂囨。澶辫触', error);
+                }
+              });
+            },
+            fail() {
+              wx.hideLoading();
+              wx.showToast({
+                title: '淇濆瓨澶辫触',
+                icon: 'none'
+              });
+            }
+          });
+        } else {
+          wx.hideLoading();
+          wx.showToast({
+            title: '涓嬭浇澶辫触',
+            icon: 'none'
+          });
+        }
+      },
+      fail() {
+        wx.hideLoading();
+        wx.showToast({
+          title: '涓嬭浇澶辫触',
+          icon: 'none'
+        });
+      }
+    });
+  },
+  //鍒氳繘鏉ョ殑鏃跺�欒皟鐢�
+  handleTeachData(item) {
+    //鍥剧墖
+    if (item.selectType == 'picture') {
+      this.setData({
+        showData: app.config.requestCtx + '/file/api/ApiDownload?md5=' + item.file,
+
+      })
+    }
+    // 涓嬭浇鏂囦欢zip
+    if (item.selectType == 'zip') {
+      this.setData({
+        zipData: item
+      })
+    }
+    //缃戦〉
+    if (item.selectType == 'webpage') {
+      this.setData({
+        webpageSrc: item.jsek_link
+      })
+    }
+
+    //鏂囨。绛�
+    if (item.selectType == 'pdf' || item.selectType == 'document') {
+      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'
+            this.data.naturalResources.push(src)
+            // console.log(this.data.naturalResources, ' this.data.naturalResources');
+          }
+        }
+      })
+
+
+
+
+    }
+  },
+
+
+
+  handleTap: function () {
+    const naturalResources = this.data.naturalResources;
+    naturalResources.forEach(function (item) {
+      // console.log(item);
+    });
   }
+
+
+
+
+
 })
\ No newline at end of file

--
Gitblit v1.9.1