From c99f9976a5ef9d8974105feb8fc0580a10adf98c Mon Sep 17 00:00:00 2001
From: QYF-GitLab1 <1940665526@qq.com>
Date: 星期一, 23 十二月 2024 14:58:49 +0800
Subject: [PATCH] 111

---
 packageBookService/pages/components/webView/index.js |   57 +++++++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 41 insertions(+), 16 deletions(-)

diff --git a/packageBookService/pages/components/webView/index.js b/packageBookService/pages/components/webView/index.js
index 4ee82de..2a1ac76 100644
--- a/packageBookService/pages/components/webView/index.js
+++ b/packageBookService/pages/components/webView/index.js
@@ -1,5 +1,8 @@
 // packageBookService/pages/components/webView/index.js
 const app = getApp()
+import {
+  loginInfo
+} from '../../../../assets/js/login';
 Page({
 
   /**
@@ -20,6 +23,8 @@
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇
    */
   onLoad(options) {
+    console.log(options)
+
     if (options && options.link) {
       this.setData({
         src: decodeURIComponent(options.link),
@@ -31,13 +36,23 @@
         src: ''
       })
       if (options) {
-        console.log(options)
         wx.setNavigationBarTitle({
           title: options.fileName,
           skeletonLoding: true
         })
-        this.getProgress(options)
       }
+    }
+    const token = wx.getStorageSync(app.config.tokenKey)
+    if (!token) {
+      loginInfo(app, (data) => {
+        if (data) {
+          this.getProgress(options)
+        } else {
+          this.getProgress(options)
+        }
+      })
+    } else {
+      this.getProgress(options)
     }
   },
 
@@ -53,7 +68,7 @@
     let that = this;
     var url = "";
     if (data.fileType == 'epub') {
-      if (data.bookBuy) {
+      if (data.bookBuy == "true") {
         url = app.config.epubUrl +
           "?md5=" +
           data.md5 +
@@ -74,39 +89,36 @@
           "&token=" +
           wx.getStorageSync(app.config.tokenKey) +
           "&recordLocation=" +
-          this.data.currentPage + "&freeEpubPage=" + data.freePage
+          that.data.currentPage + "&isPreview=true&freeEpubPage=" + data.freePage
       }
-      this.setData({
+      that.setData({
         src: url,
         skeletonLoding: false,
       })
     } else {
-      this.setData({
+      that.setData({
         navigationBarTitleText: data.fileName
       })
       app.MG.file.getPdfInfo({
         md5: data.md5
       }).then((res) => {
-        let pageCount = data.bookBuy ? res.totalPages : Number(data.freePage)
+        let pageCount = data.bookBuy == "true" ? res.totalPages : Number(data.freePage)
+        console.log(pageCount, "connt")
         if (pageCount) {
           let list = [];
-
           for (let i = 0; i < pageCount; i++) {
             const src = app.config.requestCtx + '/file/GetPdfPageImage?md5=' + data.md5 + '&index=' + (i + 1) + '&dpi=300'
             list.push(src)
           }
-          console.log(list)
-          this.setData({
+          that.setData({
             pdfList: list,
             skeletonLoding: false,
           })
-
         }
       })
     }
 
   },
-
 
   // 鑾峰彇UserKey
   getProgress: function (dataObj) {
@@ -192,7 +204,7 @@
     this.setData({
       pauseTime: Date.now()
     })
-    if (wx.getStorageSync(app.config.tokenKey) && epubObj.bookBuy) {
+    if (wx.getStorageSync(app.config.tokenKey) && this.data.epubObj.bookBuy) {
       let duration = this.data.pauseTime - this.data.startTime
       this.count(duration)
     }
@@ -205,7 +217,7 @@
     this.setData({
       pauseTime: Date.now()
     })
-    if (wx.getStorageSync(app.config.tokenKey) && epubObj.bookBuy) {
+    if (wx.getStorageSync(app.config.tokenKey) && this.data.epubObj.bookBuy == 'true') {
       let duration = this.data.pauseTime - this.data.startTime
       this.count(duration)
     }
@@ -220,14 +232,22 @@
       sysType: 'App'
     }
     //闃呰鍟嗗搧鐨刬d
-    if (epubObj.bookId) {
-      data.productId = epubObj.bookId
+    if (this.data.epubObj.bookId) {
+      data.productId = this.data.epubObj.bookId
     }
     //闃呰璧勬簮鐨刬d
     // if (product.cmsItemId) {
     //   data.cmsItemId = product.cmsItemId
     // }
     app.MG.job.newJobWithApiNewEvent(data).then((res) => {})
+  },
+
+  //棰勮鍥剧墖锛屾斁澶ч瑙�
+  preview(event) {
+    let urls = [event.currentTarget.dataset.src]
+    wx.previewImage({
+      urls: urls // 闇�瑕侀瑙堢殑鍥剧墖http閾炬帴鍒楄〃
+    })
   },
 
   /**
@@ -243,4 +263,9 @@
   onReachBottom() {
 
   },
+  /**
+   * 鐢ㄦ埛鐐瑰嚮鍙充笂瑙掑垎浜�
+   */
+  onShareAppMessage() {},
+  onShareTimeline() {},
 })
\ No newline at end of file

--
Gitblit v1.9.1