From 2ee8ddb1ecac7df4198e54e08ec7f22daf4b07c0 Mon Sep 17 00:00:00 2001
From: QYF-GitLab1 <1940665526@qq.com>
Date: 星期五, 03 一月 2025 16:57:38 +0800
Subject: [PATCH] 111

---
 packageBookService/pages/bookServices/detail/index.js |  142 +++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 129 insertions(+), 13 deletions(-)

diff --git a/packageBookService/pages/bookServices/detail/index.js b/packageBookService/pages/bookServices/detail/index.js
index 68ed718..6eae7bd 100644
--- a/packageBookService/pages/bookServices/detail/index.js
+++ b/packageBookService/pages/bookServices/detail/index.js
@@ -7,6 +7,7 @@
 } from "../../../../assets/js/login";
 import FormData from '../../../../utils/formdata/index.js';
 const app = getApp();
+var pastData = require('../../psychologyAnswer/testdata/index')
 Page({
   /**
    * 椤甸潰鐨勫垵濮嬫暟鎹�
@@ -74,6 +75,9 @@
       residue: 0, // 缁勫嵎鍓╀綑娆℃暟
       mockList: [], // 鐢ㄦ埛缁勫嵎鎻愪氦淇℃伅
     },
+    isBuyBank: false, // 棰樺簱鏄惁璐拱
+    isShoppingBank: false, // 棰樺簱鏄惁鍔犲叆璐墿杞�
+    bankSaleData: null,
     relatedBookLoading: false,
     noRelatedBookData: false,
     relatedBookPath: "", // 鐩稿叧鍥句功path
@@ -210,7 +214,8 @@
     protocolShow: false,
     protocolTxt: '',
     learnMenu: null,
-    md5List: []
+    md5List: [],
+    editDialog: false
   },
 
   resetTree: function (e) {
@@ -267,15 +272,13 @@
       this.setData({
         tabValue: options.tabValue,
       });
-
-
     }
   },
 
   /**
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鏄剧ず
    */
-  onShow() {
+  onShow(options) {
     if (wx.getStorageSync("paperBookList")) {
       this.setData({
         paperBookList: JSON.parse(wx.getStorageSync("paperBookList")),
@@ -289,6 +292,9 @@
     this.setData({
       num: Number(this.data.paperBookList.length) + Number(this.data.electronicBookList.length),
     });
+    if (this.data.bookDetail.id) {
+      this.getBookInfo(this.data.bookDetail.id)
+    }
   },
 
   /**
@@ -426,10 +432,14 @@
         protectedEpub: [],
         probationPage: [], //pdf璇曡椤垫暟
         freeEpubPage: [], //epub璇曡鐧惧垎姣�
+        bookEditor: [], //鍥句功缂栬緫
+        contactInformation: [], //鑱旂郴鏂瑰紡
       },
     };
     app.MG.store.getProductDetail(query).then(async (res) => {
       this.getResourceCode(id, res.datas.rootCmsItemId)
+      res.datas.bookEditor = res.datas.bookEditor ? res.datas.bookEditor : '-'
+      res.datas.contactInformation = res.datas.contactInformation ? res.datas.contactInformation : '-'
       this.setData({
         bookDetail: res.datas,
         buyIdList: res.datas.purchasedSaleMethodIdList,
@@ -463,6 +473,16 @@
           }
           await this.getBookClass(classData);
         }
+      }
+      // 鎵爜浠庨搴撹烦杞洖鍥句功璇︽儏
+      const localData = wx.getStorageSync('tabValue')
+      if (localData) {
+        this.setData({
+          tabValue: localData
+        })
+        wx.removeStorage({
+          key: 'tabValue',
+        })
       }
       if (this.data.tabValue == 'questionBank' || this.data.tabValue == 'jsek_cloudLearning' || this.data.tabValue == 'jsek_teachingResources') {
         const checkData = this.data.cmsDatas.find(
@@ -501,13 +521,12 @@
         }
       }
       this.setData({
-        "bookDetail.publicationDate": moment(this.data.bookDetail.publicationDate).format("YYYY骞碝M鏈�"),
+        "bookDetail.publicationDate": this.data.bookDetail.publicationDate ? moment(this.data.bookDetail.publicationDate).format("YYYY骞碝M鏈�") : '',
         "bookDetail.price": this.numFormat(this.data.bookDetail.price),
         "bookDetail.oldPrice": this.numFormat(this.data.bookDetail.oldPrice),
         "bookDetail.paperPrice": this.numFormat(
           this.data.bookDetail.paperPrice
         ),
-
       });
     });
   },
@@ -526,9 +545,26 @@
       }
     }
     app.MG.store.getProductDetail(query).then((res) => {
+      let isBuyBank = true
+      let isShoppingBank = true
+      let bankSaleData = null
+      // 鍒ゆ柇棰樺簱鏄惁鏁翠綋璐拱
+      const bank = res.datas.cmsDatas[0].datas.find((item) => item.refCode == 'questionBank')
+      if (bank) {
+        if (bank.saleMethod.length) {
+          bankSaleData = bank.saleMethod.find((item) => item.SaleType == 'Normal')
+          if (bankSaleData) {
+            isBuyBank = this.data.buyIdList.includes(bankSaleData.Id)
+            isShoppingBank = this.data.buyIdList.includes(bankSaleData.Id) ? true : this.data.shoppingCartGetId.includes(bankSaleData.Id)
+          }
+        }
+      }
       this.setData({
         resourceCodeList: res.datas.cmsDatas[0].datas,
-        learnTaskData: res.datas.cmsDatas[0].datas.filter((item) => item.refCode == 'jsek_learningTasks')[0]
+        learnTaskData: res.datas.cmsDatas[0].datas.filter((item) => item.refCode == 'jsek_learningTasks')[0],
+        isBuyBank,
+        isShoppingBank,
+        bankSaleData
       })
       if (res.datas.cmsDatas[0].datas.length) this.setData({
         learnMenu: res.datas.cmsDatas[0].datas.find(item => item.refCode == 'jsek_cloudLearning')
@@ -723,6 +759,14 @@
       }
     }
   },
+
+  // 鑱旂郴
+  editPhone() {
+    this.setData({
+      editDialog: true
+    })
+  },
+
   // 鎴戣寤鸿
   suggestBtn() {
     // 妫�鏌ョ櫥褰曠姸鎬�
@@ -876,7 +920,7 @@
         }
         // newArr.push(item)
         // 鍦ㄦ彃鍏ヨ繃绋嬩腑瀵规暟鎹繘琛屾帓搴�
-        newArr = this.insertAndSortObjectsByProductLinkPath(newArr, item)
+        newArr = this.insertAndSortObjectsById(newArr, item)
         // 鎻掕繘鏁扮粍鍚� 浠庡師鏁版嵁涓垹闄�
         rootList = rootList.filter(nitem => nitem.id != item.id)
       }
@@ -908,8 +952,8 @@
     return tree
   },
 
-  // 鎺掑簭鏁扮粍 鎸夌収productLinkPath
-  insertAndSortObjectsByProductLinkPath(array, newObj) {
+  // 鎺掑簭鏁扮粍 鎸夌収id
+  insertAndSortObjectsById(array, newObj) {
     // 鏌ユ壘鏂板璞″簲璇ユ彃鍏ョ殑浣嶇疆  
     let insertIndex = array.findIndex(obj => newObj.id < obj.id);
     // 濡傛灉娌℃湁鎵惧埌鍚堥�傜殑浣嶇疆锛屽垯鏀惧湪鏁扮粍鏈熬  
@@ -978,12 +1022,13 @@
       },
     }
     app.MG.store.getProductDetailNoChildren(query).then((res) => {
-      if (!res.datas.cmsDatas[0].datas.length) {
+      if (!res.datas.cmsDatas[0].datas.length || res.datas.cmsDatas[0].datas.length == 0) {
         return this.setData({
           noResources: true,
           loading: false,
         });
       }
+
       let list = []
       // 鍒ゆ柇浜戝涔犳湁鏃犻攢鍞柟寮忓拰鏈夋晥鏈�
       const cloundSaleMethod =
@@ -1141,17 +1186,22 @@
             }
           } else {
             if (isTSFW.length > 0) {
-              data = res.datas.cmsDatas[0].datas.filter((item) => item.type == 'questionBankFolder' && item.childrenFolderCount > 0)
+              data = res.datas.cmsDatas[0].datas.filter((item) => item.type == 'questionBankFolder' && item.refCode != 'jsek_interaction' && (item.childrenFolderCount > 0 || item.childrenCount > 0) && (item.name !== '濉┖棰�' &&
+                item.name !== '鍒ゆ柇棰�' &&
+                item.name !== '澶氶�夐' &&
+                item.name !== '绠�绛旈') && item.name !== '鍗曢�夐')
               that.setData({
                 jslx: false,
               });
             } else {
               data = res.datas.cmsDatas[0].datas.filter((item) => item.type == 'questionBankFolder')
+              // && item.refCode != 'jsek_interaction'
               that.setData({
                 jslx: true,
               });
             }
             if (data.length > 0) {
+              console.log('data', data);
               let list = []
               that.getTreeList(data, list, query.cmsPath)
               list = that.ensureTreeConsistency(list)
@@ -1161,6 +1211,20 @@
                 loading: false,
                 openTeachids: result,
               });
+              //Json璧嬪��
+              // const bookId = that.data.bookId
+              // if (bookId == 6619) {
+              //   const jsonData = {}
+              //   jsonData.name = "蹇冪悊娴嬭瘎"
+              //   jsonData.children = [...pastData.postData.list]
+              //   var test = that.data.test;
+              //   test.push(jsonData);
+              //   that.setData({
+              //     test: test,
+              //   });
+              //   console.log(that.data.test, "鏁欏浜掑姩");
+              // }
+
             } else {
               that.setData({
                 noResources: true,
@@ -1857,7 +1921,6 @@
   // 浜戝涔犲叏閮ㄨ喘涔�
   async buyCloudLearnClass() {
     const cloundMenu = this.data.resourceCodeList.find((item) => item.refCode == 'jsek_cloudLearning')
-    debugger
     let query = {
       remarks: '浜戝涔�',
       requests: [{
@@ -1906,6 +1969,59 @@
   handleTrue() {
     // findAndUpdateItemsByIds(this.date.)
   },
+
+  // 棰樺簱璐拱
+  async buyBank() {
+    let query = {
+      remarks: '浜戞祴璇�',
+      requests: [{
+        saleMethodId: this.data.bankSaleData.Id,
+        count: 1
+      }]
+    }
+    const initOrderRes = await app.MG.store.initOrder(query)
+    if (this.data.bankSaleData.Price) {
+      // 璐拱
+      const url = "/pages/cart/paymentPage/index?orderNumber=" + initOrderRes.orderNumber + '&onNorderSaleMethod=' + initOrderRes.saleMethodLinks[0].orderSaleMethod.id;
+      wx.navigateTo({
+        url,
+      });
+    } else {
+      // 鍏嶈垂棰嗗彇
+      app.MG.store
+        .confirmOrder({
+          orderNum: initOrderRes.orderNumber,
+        })
+        .then((res) => {
+          if (res) {
+            wx.showToast({
+              title: "棰嗗彇鎴愬姛",
+              icon: "none",
+              duration: 1000,
+            });
+            this.getBookInfo(this.data.bookDetail.id);
+          }
+        });
+    }
+  },
+  // 棰樺簱鍔犲叆璐墿杞�
+  handleShoppingBank() {
+    let query = {
+      requests: [{
+        saleMethodId: this.data.bankSaleData.Id,
+        storeEventId: null,
+        agentCode: "浜戞祴璇�",
+      }, ],
+    };
+    app.MG.store.addShoppingCart(query).then(res => {
+      wx.showToast({
+        icon: 'success',
+        title: '鍔犲叆鎴愬姛',
+      })
+      this.getShoppingCartProductGet();
+      this.getBookInfo(this.data.bookDetail.id)
+    })
+  },
   // 缁勫嵎鏍煎紡鍖栨棩鏈熸樉绀�
   DateFormat(date, fmt) {
     if (date && fmt) {

--
Gitblit v1.9.1