From ecabd20b3dfbd956dad14ffb6ba3dc2efcfdd7c1 Mon Sep 17 00:00:00 2001
From: yiming <m13691596795@163.com>
Date: 星期一, 25 三月 2024 16:23:32 +0800
Subject: [PATCH] 微信支付

---
 packageBookService/pages/bookServices/detail/index.js |  169 +++++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 124 insertions(+), 45 deletions(-)

diff --git a/packageBookService/pages/bookServices/detail/index.js b/packageBookService/pages/bookServices/detail/index.js
index 500be20..bc9ec6c 100644
--- a/packageBookService/pages/bookServices/detail/index.js
+++ b/packageBookService/pages/bookServices/detail/index.js
@@ -67,6 +67,16 @@
     paperBookCount: 0, //绾歌川涔﹀墿浣欐鏁�
     ebookCount: 0, //鐢靛瓙涔﹀墿浣欐鏁�
     userInfo: {},
+    fileInfo: {
+      bookName: "",
+      fileType: "",
+      md5: "",
+      freePage: ""
+    },  //闃呰鍣ㄦ暟鎹�
+    buyResourceData: {
+      productLinkPath: '',
+      refCode: '',
+    }
   },
 
 
@@ -157,7 +167,7 @@
    * 椤甸潰涓婃媺瑙﹀簳浜嬩欢鐨勫鐞嗗嚱鏁�
    */
   onReachBottom() {
-    if (this.data.tabValue == 'jesk_note') {
+    if (this.data.tabValue == 'jsek_note') {
       const child = this.selectComponent('#note')
       child.onReachBottom()
     }
@@ -352,13 +362,44 @@
           this.setData({
             noFile: true
           });
+          if (res.datas[0].bookshelf_pdf) {
+            this.setData({
+              "fileInfo.bookName": this.data.bookDetail.name,
+              "fileInfo.fileType": 'pdf',
+              "fileInfo.md5": res.datas[0].bookshelf_pdf,
+              "fileInfo.freePage": res.datas[0].bookshelf_probationPage,
+            });
+          } else if (res.datas[0].bookshelf_protectedEpub) {
+            this.setData({
+              "fileInfo.bookName": this.data.bookDetail.name,
+              "fileInfo.fileType": 'epub',
+              "fileInfo.md5": res.datas[0].bookshelf_protectedEpub,
+              "fileInfo.freePage": res.datas[0].bookshelf_freeEpub,
+            });
+          }
         }
       } else {
         if (this.data.bookDetail.pdf || this.data.bookDetail.protectedEpub) {
           this.setData({
             noFile: true
           });
+          if (this.data.bookDetail.pdf) {
+            this.setData({
+              "fileInfo.bookName": this.data.bookDetail.name,
+              "fileInfo.fileType": 'pdf',
+              "fileInfo.md5": this.data.bookDetail.pdf,
+              "fileInfo.freePage": this.data.bookDetail.probationPage,
+            });
+          } else if (this.data.bookDetail.protectedEpub) {
+            this.setData({
+              "fileInfo.bookName": this.data.bookDetail.name,
+              "fileInfo.fileType": 'epub',
+              "fileInfo.md5": this.data.bookDetail.protectedEpub,
+              "fileInfo.freePage": this.data.bookDetail.freeEpubPage,
+            });
+          }
         }
+        console.log(this.data.fileInfo, 456)
         this.setData({
           selectedIds: this.data.bookDetail.defaultSaleMethodId,
           bookBuy: this.data.bookDetail.purchasedSaleMethodIdList.indexOf(this.data.bookDetail.defaultSaleMethodId) > -1
@@ -453,6 +494,12 @@
     if (e.detail.label == '鏁欏璧勬簮' || e.detail.label == '浜戝涔�' || e.detail.label == '浜戞祴璇�') {
       const checkData = this.data.cmsDatas.find(item => item.refCode == e.detail.value)
       if (checkData) {
+        if (e.detail.value == 'jsek_cloudLearning') {
+          this.setData({
+            'buyResourceData.productLinkPath': checkData.productLinkPath,
+            'buyResourceData.refCode': checkData.refCode
+          })
+        }
         if ((e.detail.value == 'jsek_teachingResources' && !this.data.teach.length)
           || (e.detail.value == 'jsek_cloudLearning' && !this.data.learn.length)
           || (e.detail.value == 'questionBank' && !this.data.test.length)) {
@@ -470,6 +517,12 @@
       if (token) {
         child.changeLoading()
         child.getNoteList()
+      }
+
+    } else if (e.detail.label == '鐢靛瓙涔�') {
+      const child = this.selectComponent('#eBook')
+      if (child) {
+        child.getProgress()
       }
 
     }
@@ -669,54 +722,65 @@
 
   // 鍥句功娣诲姞璐墿杞�
   async addBookShopcCar() {
-    const token = wx.getStorageSync('jsek-token')
-    if (!token) {
-      return wx.getUserProfile({
-        desc: '鐢ㄦ埛鐧诲綍',
-        success: (res) => {
-          console.log(res);
+
+    if (!this.data.expire) {
+
+      const token = wx.getStorageSync('jsek-token')
+      if (!token) {
+        return wx.getUserProfile({
+          desc: '鐢ㄦ埛鐧诲綍',
+          success: (res) => {
+            console.log(res);
+          }
+        })
+      }
+
+      const shoppingCartGetId = []
+
+      let query = {
+        start: 0,
+        size: 9999,
+        filterList: [],
+        searchList: []
+      }
+      const res = await app.MG.store.getShoppingCartProductList(query)
+      res.datas.forEach((item) => {
+        shoppingCartGetId.push(item.saleMethod.id)
+      })
+      console.log(shoppingCartGetId, 'shoppingCartGetId');
+      console.log(this.data.selectedIds, '閿�鍞柟寮廼d');
+      const determine = shoppingCartGetId.some((item) => item == this.data.selectedIds)
+      console.log(determine);
+      if (!determine) {
+        let query = {
+          requests: [
+            {
+              saleMethodId: this.data.selectedIds,
+              storeEventId: null,
+              agentCode: '鐢靛瓙涔�'
+            }
+          ]
         }
+        const addRes = app.MG.store.addShoppingCart(query)
+        this.showSuccessToast()
+
+      } else {
+        Toast({
+          context: this,
+          selector: '#t-toast',
+          message: '宸叉坊鍔�',
+          theme: 'success',
+          direction: 'column',
+        });
+      }
+    } else {
+      wx.showToast({
+        title: "鍟嗗搧涓嶅湪鏈夋晥鏈�",
+        icon: 'none',
+        duration: 1000,
       })
     }
 
-    const shoppingCartGetId = []
-
-    let query = {
-      start: 0,
-      size: 999,
-      filterList: [],
-      searchList: []
-    }
-    const res = await app.MG.store.getShoppingCartProductList(query)
-    res.datas.forEach((item) => {
-      shoppingCartGetId.push(item.saleMethod.id)
-    })
-    console.log(shoppingCartGetId, 'shoppingCartGetId');
-    console.log(this.data.selectedIds, '閿�鍞柟寮廼d');
-    const determine = shoppingCartGetId.some((item) => item == this.data.selectedIds)
-    console.log(determine);
-    if (!determine) {
-      let query = {
-        requests: [
-          {
-            saleMethodId: this.data.selectedIds,
-            storeEventId: null,
-            agentCode: '鐢靛瓙涔�'
-          }
-        ]
-      }
-      const addRes = app.MG.store.addShoppingCart(query)
-      this.showSuccessToast()
-
-    } else {
-      Toast({
-        context: this,
-        selector: '#t-toast',
-        message: '宸叉坊鍔�',
-        theme: 'success',
-        direction: 'column',
-      });
-    }
 
   },
 
@@ -1342,6 +1406,21 @@
     }
   },
 
+  goRead() {
+    if (!this.data.noFile) {
+      wx.showToast({
+        title: '鏆傛棤闃呰鏂囦欢',
+        icon: 'none',
+        duration: 2000
+      })
+      return false;
+    }
+    wx.navigateTo({
+      url: '/packageBookService/pages/components/webView/index?md5=' + this.data.fileInfo.md5 + '&fileName=' + this.data.fileInfo.bookName + '&fileType=' + this.data.fileInfo.fileType + '&freePage=' + this.data.fileInfo.freePage
+    })
+
+  },
+
   //鏍蜂功鐢宠
   //鐢宠鐢靛瓙鏍蜂功
   appplyElectronicBook() {

--
Gitblit v1.9.1