From 04c7b0163caeae4ab1c5da62e301fa993101cfad Mon Sep 17 00:00:00 2001
From: 闫增涛 <1829501689@qq.com>
Date: 星期一, 31 三月 2025 10:40:45 +0800
Subject: [PATCH] bug修改

---
 packageBookService/pages/bookServices/detail/index.js | 1128 +++++++++++++++++++++++++++++++++++------------------------
 1 files changed, 670 insertions(+), 458 deletions(-)

diff --git a/packageBookService/pages/bookServices/detail/index.js b/packageBookService/pages/bookServices/detail/index.js
index b4f2294..4a1ea38 100644
--- a/packageBookService/pages/bookServices/detail/index.js
+++ b/packageBookService/pages/bookServices/detail/index.js
@@ -7,14 +7,12 @@
 } from "../../../../assets/js/login";
 import FormData from '../../../../utils/formdata/index.js';
 const app = getApp();
+var pastData = require('../../psychologyAnswer/testdata/index')
 Page({
   /**
    * 椤甸潰鐨勫垵濮嬫暟鎹�
    */
   data: {
-    // 杩涢〉闈㈤粯璁ゅ垏鎹�  灞曞紑鐨刬d
-    // defaultactiveTeachid  鏁欏璧勬簮  
-    // defaultactiveLearnid  浜戝涔�
     bookId: "",
     barHeight: "",
     navBarHeight: "",
@@ -48,7 +46,7 @@
     learnPath: '',
     applyResourceState: false, // 鐢宠鏁欏璧勬簮鎸夐挳闃叉姈
     resourceClassList: [], // 璧勬簮鎵�灞炲垎绫�
-    applyState: "", // 鏁欏璧勬簮鐢宠鐘舵��
+    applyState: "1", // 鏁欏璧勬簮鐢宠鐘舵��
     deadline: "", // 鏁欏璧勬簮鐢宠鏈夋晥鏃ユ湡,
     isShowBuyCloundBtn: false,
     isshowDrawBtn: true, // 浜戝涔犻鍙栨煡鐪嬫寜閽槸鍚︽樉绀�
@@ -74,6 +72,9 @@
       residue: 0, // 缁勫嵎鍓╀綑娆℃暟
       mockList: [], // 鐢ㄦ埛缁勫嵎鎻愪氦淇℃伅
     },
+    isBuyBank: false, // 棰樺簱鏄惁璐拱
+    isShoppingBank: false, // 棰樺簱鏄惁鍔犲叆璐墿杞�
+    bankSaleData: null,
     relatedBookLoading: false,
     noRelatedBookData: false,
     relatedBookPath: "", // 鐩稿叧鍥句功path
@@ -208,7 +209,10 @@
     fileList: [],
     isShowUp: true,
     protocolShow: false,
-    protocolTxt: ''
+    protocolTxt: '',
+    learnMenu: null,
+    md5List: [],
+    editDialog: false
   },
 
   resetTree: function (e) {
@@ -216,6 +220,26 @@
       currentCheck: e.detail.checkedItem,
       list: e.detail.changeList,
     });
+  },
+
+  logInFun(callback) {
+    loginInfo(app, (data) => {
+      if (data) {
+        this.getShoppingCartProductGet();
+        this.getApplyInfo(this.data.options.id);
+        this.getAlreadyPBookList();
+        this.getAlreadyEBookList();
+        if (wx.getStorageSync(app.config.userInfoKey)) {
+          this.setData({
+            userInfo: JSON.parse(wx.getStorageSync(app.config.userInfoKey)),
+          });
+          // 鑾峰彇鐢宠娆℃暟
+          this.getSelectPaperBookCount();
+          this.getSelectBookCount();
+        }
+        callback()
+      }
+    })
   },
   /**
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇
@@ -238,42 +262,33 @@
     wx.setNavigationBarTitle({
       title: decodeURI(options.name),
     })
-    let token = wx.getStorageSync(app.config.tokenKey)
-    if (!token) {
-      loginInfo(app, (data) => {
-        if (data) {} else {}
-      })
-    }
     this.getBookInfo(options.id);
-    // this.getResourceClass(); // 鑾峰彇璧勬簮鎵�灞炲垎绫�
-    token = wx.getStorageSync(app.config.tokenKey)
-    if (token) {
-      this.getShoppingCartProductGet();
-      this.getApplyInfo(options.id);
-      this.getAlreadyPBookList();
-      this.getAlreadyEBookList();
-    }
-    if (wx.getStorageSync(app.config.userInfoKey)) {
-      this.setData({
-        userInfo: JSON.parse(wx.getStorageSync(app.config.userInfoKey)),
-      });
-      // 鑾峰彇鐢宠娆℃暟
-      this.getSelectPaperBookCount();
-      this.getSelectBookCount();
-    }
     if (options.tabValue) {
       this.setData({
         tabValue: options.tabValue,
       });
-
-
+    }
+    const token = wx.getStorageSync(app.config.tokenKey);
+    if (token) {
+      this.getShoppingCartProductGet();
+      this.getApplyInfo(this.data.options.id);
+      this.getAlreadyPBookList();
+      this.getAlreadyEBookList();
+      if (wx.getStorageSync(app.config.userInfoKey)) {
+        this.setData({
+          userInfo: JSON.parse(wx.getStorageSync(app.config.userInfoKey)),
+        });
+        // 鑾峰彇鐢宠娆℃暟
+        this.getSelectPaperBookCount();
+        this.getSelectBookCount();
+      }
     }
   },
 
   /**
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鏄剧ず
    */
-  onShow() {
+  onShow(options) {
     if (wx.getStorageSync("paperBookList")) {
       this.setData({
         paperBookList: JSON.parse(wx.getStorageSync("paperBookList")),
@@ -286,7 +301,11 @@
     }
     this.setData({
       num: Number(this.data.paperBookList.length) + Number(this.data.electronicBookList.length),
+      editDialog: false
     });
+    if (this.data.bookDetail.id) {
+      this.getBookInfo(this.data.bookDetail.id)
+    }
   },
 
   /**
@@ -424,10 +443,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,
@@ -461,6 +484,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(
@@ -499,13 +532,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
         ),
-
       });
     });
   },
@@ -524,9 +556,29 @@
       }
     }
     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')
       })
     })
   },
@@ -683,51 +735,64 @@
   setCollect() {
     const token = wx.getStorageSync(app.config.tokenKey);
     if (!token) {
-      // 妫�鏌ョ櫥褰曠姸鎬�
-      loginInfo(app, (data) => {
-        // 濡傛灉涓嶆槸绗竴娆$櫥褰曪紝浼氭墽琛屽洖璋�
-        if (data) {
-          // 鐧诲綍鎴愬姛锛岃嚜鍔ㄨ褰晅oken鍜岀敤鎴蜂俊鎭紝骞惰繑鍥瀟rue
-          this.getBookInfo(this.data.bookId);
-        } else {
-          // 鍑虹幇閿欒锛岃繑鍥瀎alse
-        }
-      });
+      this.logInFun(() => {
+        this.getBookInfo(this.data.bookId);
+      })
     } else {
-      if (this.data.bookDetail.isFavourite) {
-        app.MG.store
-          .delProductLink({
-            productIds: [this.data.bookDetail.id],
-            linkType: "FavoriteBookCity",
-          })
-          .then(() => {
-            this.setData({
-              "bookDetail.isFavourite": false,
-            });
-          });
-      } else {
-        const params = {
+      this.collectFun()
+    }
+  },
+  collectFun() {
+    if (this.data.bookDetail.isFavourite) {
+      app.MG.store
+        .delProductLink({
           productIds: [this.data.bookDetail.id],
           linkType: "FavoriteBookCity",
-        };
-        app.MG.store.addProductLink(params).then((res) => {
+        })
+        .then(() => {
           this.setData({
-            "bookDetail.isFavourite": true,
+            "bookDetail.isFavourite": false,
           });
         });
-      }
+    } else {
+      const params = {
+        productIds: [this.data.bookDetail.id],
+        linkType: "FavoriteBookCity",
+      };
+      app.MG.store.addProductLink(params).then((res) => {
+        this.setData({
+          "bookDetail.isFavourite": true,
+        });
+      });
     }
+  },
+  // 鑱旂郴
+  editPhone() {
+    this.setData({
+      editDialog: true
+    })
+  },
+  closeEditDialog() {
+    this.setData({
+      editDialog: false
+    })
   },
   // 鎴戣寤鸿
   suggestBtn() {
     // 妫�鏌ョ櫥褰曠姸鎬�
     const token = wx.getStorageSync(app.config.tokenKey);
-    const child = this.selectComponent("#suggest-component");
-    if (token)
-      // child.showDialog();
+    if (token) {
       this.setData({
         showIndex: '1'
       })
+    } else {
+      this.logInFun(() => {
+        this.setData({
+          showIndex: '1'
+        })
+      })
+    }
+
   },
   // 璺宠浆缃戝簵
   goShop(e) {
@@ -761,17 +826,6 @@
             "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)
-        // ) {
-        //   if (e.detail.value == "jsek_teachingResources") {
-        //     wx.setStorageSync('teachResourcesPath', checkData.productLinkPath)
-        //   }
-        //   this.getResourceData(checkData);
-        // }
         if ((e.detail.value == "jsek_teachingResources" && !this.data.teach.length) || (e.detail.value == "jsek_cloudLearning" && !this.data.learn.length)) {
           wx.setStorageSync('teachResourcesPath', checkData.productLinkPath)
           this.getResourceDataList(checkData)
@@ -871,7 +925,7 @@
         }
         // newArr.push(item)
         // 鍦ㄦ彃鍏ヨ繃绋嬩腑瀵规暟鎹繘琛屾帓搴�
-        newArr = this.insertAndSortObjectsByProductLinkPath(newArr, item)
+        newArr = this.insertAndSortObjectsById(newArr, item)
         // 鎻掕繘鏁扮粍鍚� 浠庡師鏁版嵁涓垹闄�
         rootList = rootList.filter(nitem => nitem.id != item.id)
       }
@@ -903,8 +957,8 @@
     return tree
   },
 
-  // 鎺掑簭鏁扮粍 鎸夌収productLinkPath
-  insertAndSortObjectsByProductLinkPath(array, newObj) {
+  // 鎺掑簭鏁扮粍 鎸夌収id
+  insertAndSortObjectsById(array, newObj) {
     // 鏌ユ壘鏂板璞″簲璇ユ彃鍏ョ殑浣嶇疆  
     let insertIndex = array.findIndex(obj => newObj.id < obj.id);
     // 濡傛灉娌℃湁鎵惧埌鍚堥�傜殑浣嶇疆锛屽垯鏀惧湪鏁扮粍鏈熬  
@@ -973,7 +1027,7 @@
       },
     }
     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,
@@ -990,9 +1044,19 @@
         cloundSaleMethod &&
         new Date().getTime() <= new Date(cloundSaleMethod.EndDate).getTime() &&
         new Date().getTime() >= new Date(cloundSaleMethod.BeginDate).getTime()
+      let md5s = []
       res.datas.cmsDatas[0].datas.forEach((item) => {
         // 浜戝涔犱笂鏈夐攢鍞柟寮忥紝鍘绘帀浜戝涔犱笅鎵�鏈夐攢鍞柟寮�
-        if (flags) item.saleMethod = []
+        if (this.data.tabValue == "jsek_teachingResources") {
+          if (item.file || item.freeFile) {
+            let md5 = item.file ? item.file : item.freeFile
+            md5s.push(md5)
+          }
+          this.setData({
+            md5List: md5s,
+          });
+        }
+        if (flags && cloundSaleMethod.Price > 0) item.saleMethod = []
         item.checked = false;
         if (item.sysType == 'CmsItem') {
           // 鏁欏璧勬簮 绫诲瀷鍚嶇О璧嬪��
@@ -1040,9 +1104,9 @@
           new Date(item.saleMethod.find((citem) => citem.SaleType == 'Normal').BeginDate).getTime() <= new Date().getTime()
         ) || (flags && cloundSaleMethod.Price == 0)
         // 鍒ゆ柇浜戝涔犲叏閮ㄨ喘涔版寜閽槸鍚︽樉绀�
-        let isShowBuyCloundMenu = flags && cloundSaleMethod.Price >= 0
+        let isShowBuyCloundMenu = flags && cloundSaleMethod.Price > 0 && !this.data.buyIdList.includes(cloundSaleMethod.Id)
         // 鍒ゆ柇璧勬簮璐拱鎸夐挳鏄惁鏄剧ず
-        let isShowBuyCloundBtn = res.datas.cmsDatas[0].datas.some(citem => citem.saleMethod.length != 0) || type.saleMethod.length
+        let isShowBuyCloundBtn = !flags && res.datas.cmsDatas[0].datas.some(citem => citem.saleMethod.length != 0)
         // 鍒ゆ柇璐墿杞︽寜閽拰閿佹寜閽槸鍚︽樉绀�
         this.handleTreeData(list).forEach(item => {
           item.isbuy = this.resourceIsBuy(item);
@@ -1053,13 +1117,14 @@
           isshowDrawBtn,
           isShowBuyCloundMenu,
           isShowBuyCloundBtn,
-          isCloundHaveSaleMethod: flags,
+          isCloundHaveSaleMethod: flags && cloundSaleMethod.Price > 0,
           learn: list,
           loading: false,
           openLearnids: result,
           learnPath: type.productLinkPath
         });
       }
+      console.log('1', this.data.teach);
     })
   },
   //  鑾峰彇 浜戞祴璇�
@@ -1125,17 +1190,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)
@@ -1145,6 +1215,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,
@@ -1192,48 +1276,57 @@
   },
 
   // 鍥句功娣诲姞璐墿杞�
-  async addBookShopcCar() {
-    if (!this.data.expire) {
-      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);
-      });
-      const determine = shoppingCartGetId.some(
-        (item) => item == this.data.selectedIds
-      );
-      if (!determine) {
+  addBookShopcCar() {
+    const addFun = async () => {
+      if (!this.data.expire) {
+        const shoppingCartGetId = [];
         let query = {
-          requests: [{
-            saleMethodId: this.data.selectedIds,
-            storeEventId: null,
-            agentCode: "鐢靛瓙涔�",
-          }, ],
+          start: 0,
+          size: 9999,
+          filterList: [],
+          searchList: [],
         };
-        const addRes = app.MG.store.addShoppingCart(query);
-        this.showSuccessToast();
+        const res = await app.MG.store.getShoppingCartProductList(query);
+        res.datas.forEach((item) => {
+          shoppingCartGetId.push(item.saleMethod.id);
+        });
+        const determine = shoppingCartGetId.some(
+          (item) => item == this.data.selectedIds
+        );
+        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: "warning",
+            direction: "column",
+          });
+        }
       } else {
-        Toast({
-          context: this,
-          selector: "#t-toast",
-          message: "璇ヤ功宸插湪璐墿杞︼紝璇峰嬁閲嶅娣诲姞",
-          theme: "warning",
-          direction: "column",
+        wx.showToast({
+          title: "鍟嗗搧涓嶅湪鏈夋晥鏈�",
+          icon: "none",
+          duration: 1000,
         });
       }
-    } else {
-      wx.showToast({
-        title: "鍟嗗搧涓嶅湪鏈夋晥鏈�",
-        icon: "none",
-        duration: 1000,
-      });
     }
+    const token = wx.getStorageSync(app.config.tokenKey);
+    if (token) {
+      addFun()
+    } else {
+      this.logInFun(() => {})
+    }
+
   },
 
   showSuccessToast() {
@@ -1593,7 +1686,7 @@
         (item) => item == saleData.Id
       );
       // 宸茬粡璐拱
-      if (isShow) return false
+      if (isShow || saleData.Price == 0) return false
       // 鏈喘涔帮紝鏌ョ湅閿�鍞柟寮忔槸鍚﹁繃鏈�
       if (!isShow) {
         const flag = new Date(saleData.EndDate).getTime() >= new Date().getTime() &&
@@ -1708,85 +1801,83 @@
     return flattenedArray;
   },
   // 浜戝涔犱竴閿鍙�
-  async getFreeResource() {
+  getFreeResource() {
+    const getFreeFun = async () => {
+      // 棰嗗彇鏌ョ湅 锛屽厛鐪嬩簯瀛︿範涓婄殑  鍐嶇湅璧勬簮涓婄殑
+      const cloundMenu = this.data.resourceCodeList.find((item) => item.refCode == 'jsek_cloudLearning')
+      const cloundMenuSaleMethod =
+        cloundMenu.saleMethod && cloundMenu.saleMethod.length ?
+        cloundMenu.saleMethod.find((ditem) => ditem.SaleType == 'Normal') :
+        undefined
+      let query = {}
+      if (this.data.isCloundHaveSaleMethod && !cloundMenuSaleMethod.Price) {
+        // 浜戝涔犱笂鏈夐攢鍞柟寮忥紝涓斾负0鍏冿紝鐩存帴棰嗗彇浜戝涔�
+        query = {
+          remarks: '浜戝涔�',
+          requests: [{
+            saleMethodId: cloundMenuSaleMethod.Id,
+            count: 1
+          }]
+        }
+      } else {
+        // 棰嗗彇璧勬簮
+        let arr = this.handleTreeData(this.data.learn).filter(item => this.resourceIsBuy(item))
+        let freeIds = arr.filter((item) => {
+          return item.saleMethod.find((citem) => citem.SaleType == 'Normal').Price == 0
+        })
+        if (!freeIds.length)
+          return wx.showToast({
+            icon: "error",
+            title: "鏆傛棤鍏嶈垂璧勬簮",
+          });
+        let requests = [];
+        freeIds.forEach((item, index) => {
+          if (this.resourceIsBuy(item)) {
+            requests.push({
+              saleMethodId: item.saleMethod[0].Id,
+              count: 1,
+            });
+          }
+        });
+        query = {
+          remarks: "浜戝涔�",
+          requests,
+        };
+      }
+      child.changeReceive(true);
+      try {
+        const initOrderRes = await app.MG.store.initOrder(query);
+        let parameter = {
+          orderNum: initOrderRes.orderNumber,
+        };
+        // 纭璁㈠崟
+        const confirmOrderRes = await app.MG.store.confirmOrder(parameter);
+        if (confirmOrderRes.orderNumber) {
+          child.changeReceive(false);
+          wx.showToast({
+            title: "棰嗗彇鎴愬姛",
+          });
+          this.getBookInfo(this.data.bookId);
+          this.getResourceDataList({
+            refCode: 'jsek_cloudLearning',
+            productLinkPath: this.data.learnPath
+          })
+          this.setData({
+            successOrderNumber: confirmOrderRes.orderNumber
+          })
+        }
+      } catch (error) {
+        console.log(error);
+      }
+    }
     const child = this.selectComponent("#learn-resource");
     const token = wx.getStorageSync(app.config.tokenKey);
     if (!token) {
-      loginInfo(app, (data) => {
-        // 濡傛灉涓嶆槸绗竴娆$櫥褰曪紝浼氭墽琛屽洖璋�
-        if (data) {
-          // 鐧诲綍鎴愬姛锛岃嚜鍔ㄨ褰晅oken鍜岀敤鎴蜂俊鎭紝骞惰繑鍥瀟rue
-        } else {
-          // 鍑虹幇閿欒锛岃繑鍥瀎alse
-        }
-      });
-    }
-    // 棰嗗彇鏌ョ湅 锛屽厛鐪嬩簯瀛︿範涓婄殑  鍐嶇湅璧勬簮涓婄殑
-    const cloundMenu = this.data.resourceCodeList.find((item) => item.refCode == 'jsek_cloudLearning')
-    const cloundMenuSaleMethod =
-      cloundMenu.saleMethod && cloundMenu.saleMethod.length ?
-      cloundMenu.saleMethod.find((ditem) => ditem.SaleType == 'Normal') :
-      undefined
-    let query = {}
-    if (this.data.isCloundHaveSaleMethod && !cloundMenuSaleMethod.Price) {
-      // 浜戝涔犱笂鏈夐攢鍞柟寮忥紝涓斾负0鍏冿紝鐩存帴棰嗗彇浜戝涔�
-      query = {
-        remarks: '浜戝涔�',
-        requests: [{
-          saleMethodId: cloundMenuSaleMethod.Id,
-          count: 1
-        }]
-      }
+      this.logInFun(() => {});
     } else {
-      // 棰嗗彇璧勬簮
-      let arr = this.handleTreeData(this.data.learn).filter(item => this.resourceIsBuy(item))
-      let freeIds = arr.filter((item) => {
-        return item.saleMethod.find((citem) => citem.SaleType == 'Normal').Price == 0
-      })
-      if (!freeIds.length)
-        return wx.showToast({
-          icon: "error",
-          title: "鏆傛棤鍏嶈垂璧勬簮",
-        });
-      let requests = [];
-      freeIds.forEach((item, index) => {
-        if (this.resourceIsBuy(item)) {
-          requests.push({
-            saleMethodId: item.saleMethod[0].Id,
-            count: 1,
-          });
-        }
-      });
-      query = {
-        remarks: "浜戝涔�",
-        requests,
-      };
+      getFreeFun()
     }
-    child.changeReceive(true);
-    try {
-      const initOrderRes = await app.MG.store.initOrder(query);
-      let parameter = {
-        orderNum: initOrderRes.orderNumber,
-      };
-      // 纭璁㈠崟
-      const confirmOrderRes = await app.MG.store.confirmOrder(parameter);
-      if (confirmOrderRes.orderNumber) {
-        child.changeReceive(false);
-        wx.showToast({
-          title: "棰嗗彇鎴愬姛",
-        });
-        this.getBookInfo(this.data.bookId);
-        this.getResourceDataList({
-          refCode: 'jsek_cloudLearning',
-          productLinkPath: this.data.learnPath
-        })
-        this.setData({
-          successOrderNumber: confirmOrderRes.orderNumber
-        })
-      }
-    } catch (error) {
-      console.log(error);
-    }
+
   },
   // 浜戝涔犱竴閿喘涔�
   async allAddShoppiingCar() {
@@ -1839,34 +1930,37 @@
     }
   },
   // 浜戝涔犲叏閮ㄨ喘涔�
-  async buyCloudLearnClass() {
-    const cloundMenu = this.data.resourceCodeList.find((item) => item.refCode == 'jsek_cloudLearning')
-    debugger
-    let query = {
-      remarks: '浜戝涔�',
-      requests: [{
-        saleMethodId: cloundMenu.saleMethod.find((eitem) => eitem.SaleType == 'Normal').Id,
-        count: 1
-      }]
+  buyCloudLearnClass() {
+    const buyClass = async () => {
+      const cloundMenu = this.data.resourceCodeList.find((item) => item.refCode == 'jsek_cloudLearning')
+      let query = {
+        remarks: '浜戝涔�',
+        requests: [{
+          saleMethodId: cloundMenu.saleMethod.find((eitem) => eitem.SaleType == 'Normal').Id,
+          count: 1
+        }]
+      }
+      const initOrderRes = await app.MG.store.initOrder(query)
+      // 妫�鏌ヨ鍗曞彿鏄惁瀛樺湪
+      if (initOrderRes.orderNumber) {
+        // bookService: orderNumber.value,  灏戜紶杩欎釜 锛屾殏鏃朵笉鐭ラ亾鏈変粈涔堢敤
+        wx.navigateTo({
+          url: `/pages/cart/paymentPage/index?&bookId=${this.data.bookDetail.id}&bookName=${this.data.bookDetail.name}&orderNumber=${initOrderRes.orderNumber}`,
+        });
+      } else {
+        // 璁㈠崟鍙蜂笉瀛樺湪锛屾樉绀鸿鍛婃秷鎭�
+        wx.showToast({
+          icon: "error",
+          title: "璇烽噸璇�",
+        });
+      }
     }
-    const initOrderRes = await app.MG.store.initOrder(query)
-    // 妫�鏌ヨ鍗曞彿鏄惁瀛樺湪
-    if (initOrderRes.orderNumber) {
-      // bookService: orderNumber.value,  灏戜紶杩欎釜 锛屾殏鏃朵笉鐭ラ亾鏈変粈涔堢敤
-      wx.navigateTo({
-        url: `/pages/cart/paymentPage/index?&bookId=${this.data.bookDetail.id}&bookName=${this.data.bookDetail.name}&orderNumber=${initOrderRes.orderNumber}`,
-      });
+    const token = wx.getStorageSync(app.config.tokenKey);
+    if (token) {
+      buyClass()
     } else {
-      // 璁㈠崟鍙蜂笉瀛樺湪锛屾樉绀鸿鍛婃秷鎭�
-      wx.showToast({
-        icon: "error",
-        title: "璇烽噸璇�",
-      });
+      this.logInFun(() => {})
     }
-  },
-  // 浜戝涔犲瓧娈佃喘涔�
-  async buyCloundMenu() {
-    const cloundData = this.data.resourceCodeList.find(item => item.refCode == 'jsek_cloudLearning')
 
   },
   // 鍙樹负鎵�鏈塩heck   true
@@ -1887,8 +1981,58 @@
     }
     return tree; // 杩斿洖淇敼鍚庣殑瀹屾暣鏁扮粍
   },
-  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) {
@@ -1959,53 +2103,62 @@
       });
   },
   // 璐拱缁勫嵎
-  async buyMock() {
-    let res;
-    if (!this.data.mockData.id)
-      return wx.showToast({
-        icon: "error",
-        title: "鏆傛棤缁勫嵎",
-        mask: true,
-      });
-    // 鏋勫缓璁㈠崟鏌ヨ瀵硅薄
-    try {
-      let query = {
-        remarks: "缁勫嵎",
-        requests: [{
-          saleMethodId: this.data.mockData.id,
-          count: 1,
-        }, ],
-      };
-      if (this.data.flag) {
-        this.setData({
-          flag: false,
+  buyMock() {
+    const buyMockFun = async () => {
+      let res;
+      if (!this.data.mockData.id)
+        return wx.showToast({
+          icon: "error",
+          title: "鏆傛棤缁勫嵎",
+          mask: true,
         });
-        res = await app.MG.store.initOrder(query);
-      }
-      if (res.orderNumber && this.data.mockData.price) {
-        wx.navigateTo({
-          url: `/pages/cart/paymentPage/index?orderNumber=${res.orderNumber}`,
-        });
-      } else {
-        // 0鍏冪洿鎺ラ鍙�
-        // 纭璁㈠崟
-        const confirmOrderRes = await app.MG.store.confirmOrder({
-          orderNum: res.orderNumber,
-        });
-        if (confirmOrderRes) {
-          wx.showToast({
-            icon: "success",
-            title: "棰嗗彇鎴愬姛",
-          });
+      // 鏋勫缓璁㈠崟鏌ヨ瀵硅薄
+      try {
+        let query = {
+          remarks: "缁勫嵎",
+          requests: [{
+            saleMethodId: this.data.mockData.id,
+            count: 1,
+          }, ],
+        };
+        if (this.data.flag) {
           this.setData({
-            flag: true,
+            flag: false,
           });
-          await this.recordBuyMock(); // 璁板綍璐拱鏃堕棿
+          res = await app.MG.store.initOrder(query);
         }
+        if (res.orderNumber && this.data.mockData.price) {
+          wx.navigateTo({
+            url: `/pages/cart/paymentPage/index?orderNumber=${res.orderNumber}`,
+          });
+        } else {
+          // 0鍏冪洿鎺ラ鍙�
+          // 纭璁㈠崟
+          const confirmOrderRes = await app.MG.store.confirmOrder({
+            orderNum: res.orderNumber,
+          });
+          if (confirmOrderRes) {
+            wx.showToast({
+              icon: "success",
+              title: "棰嗗彇鎴愬姛",
+            });
+            this.setData({
+              flag: true,
+            });
+            await this.recordBuyMock(); // 璁板綍璐拱鏃堕棿
+          }
+        }
+      } catch (error) {
+        console.log(error);
       }
-    } catch (error) {
-      console.log(error);
     }
+    const token = wx.getStorageSync(app.config.tokenKey);
+    if (token) {
+      buyMockFun()
+    } else {
+      this.logInFun(() => {})
+    }
+
   },
   // 璁板綍璐拱缁勫嵎鏃堕棿
   recordBuyMock() {
@@ -2107,40 +2260,65 @@
   },
   // 搴曢儴璐拱鎸夐挳
   buyBtn() {
-    if (this.data.tabValue == "brief" && !this.data.bookBuy) {
-      this.buyBook();
-    } else if (this.data.tabValue == "jsek_cloudLearning") {
-      const tree = this.selectComponent("#tree");
-      tree.onCloudShoppingCart();
-    } else {
-      console.log(this.data.tabValue);
+    const buyFun = () => {
+      if (this.data.tabValue == "brief" && !this.data.bookBuy) {
+        this.buyBook();
+      } else if (this.data.tabValue == "jsek_cloudLearning") {
+        const tree = this.selectComponent("#tree");
+        tree.onCloudShoppingCart();
+      } else {
+        console.log(this.data.tabValue);
+      }
     }
+    const token = wx.getStorageSync(app.config.tokenKey);
+    if (token) {
+      buyFun()
+    } else {
+      this.logInFun(() => {})
+    }
+
   },
 
-  goRead() {
-    if (!this.data.noFile) {
-      wx.showToast({
-        title: "鏆傛棤闃呰鏂囦欢",
-        icon: "none",
-        duration: 2000,
+  goRead(e) {
+    const readFun = (bookBuy) => {
+      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 +
+          "&bookBuy=" +
+          bookBuy +
+          "&bookId=" +
+          this.data.bookDetail.id,
       });
-      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 +
-        "&bookBuy=" +
-        this.data.bookBuy +
-        "&bookId=" +
-        this.data.bookDetail.id,
+    const {
+      type
+    } = e.currentTarget.dataset
+    if (type == 'freeFile') return readFun(this.data.bookBuy)
+    if (this.data.bookDetail.price == '0.00')
+      return readFun(true)
+    const token = wx.getStorageSync(app.config.tokenKey);
+    if (token) {
+      readFun(this.data.bookBuy)
+    } else {
+      this.logInFun(() => {
+        readFun(this.data.bookBuy)
+      })
+    }
 
-    });
   },
 
   //鏍蜂功鐢宠
@@ -2253,179 +2431,127 @@
 
   //鐢宠鐢靛瓙鏍蜂功
   appplyElectronicBook() {
-    // 鍏堝垽鏂笅鏁欏笀璁よ瘉锛屾湭瀵瑰師鏈夐�昏緫淇敼
-    let role = this.data.userInfo != null ? this.data.userInfo.role : null;
-    if (role && role == "Teacher") {} else {
-      return wx.showModal({
-        title: "灏婃暚鐨勭敤鎴凤紝鎮ㄥソ锛�", //鎻愮ず鐨勬爣棰�
-        content: "璇峰厛杩涜鏁欏笀璁よ瘉锛�", //鎻愮ず鐨勫唴瀹�
-        confirmColor: "#ff6c00",
-        cancelColor: "#949494",
-        success: function (res) {
-          if (res.confirm) {
-            wx.navigateTo({
-              url: "/packageDomain/pages/teacherCertification/index",
-            });
-          } else if (res.cancel) {}
-        },
-      });
-    }
-    if (
-      this.data.bookDetail.isApplyBook == 2 ||
-      this.data.bookDetail.isApplyBook == 4
-    ) {
+    const applyFun = () => {
+      // 鍏堝垽鏂笅鏁欏笀璁よ瘉锛屾湭瀵瑰師鏈夐�昏緫淇敼
       let role = this.data.userInfo != null ? this.data.userInfo.role : null;
-      if (role && role == "Teacher") {
-        if (!this.data.noFile) {
-          wx.showToast({
-            title: "鏆傛棤鐢靛瓙涔︽枃浠�,璇疯仈绯荤鐞嗗憳!",
-            icon: "none",
-            duration: 1000,
-          });
-          return;
-        }
-        if (this.data.ebookCount == 0) {
-          wx.showToast({
-            title: "鎮ㄧ殑鐢靛瓙鏍蜂功鐢宠娆℃暟宸茬敤灏斤紝鑻ヨ缁х画锛岃鑱旂郴绠$悊鍛橈紒",
-            icon: "none",
-            duration: 1000,
-          });
-          return false;
-        }
-
-        let isHas = this.data.electronicBookList.find(
-          (eitem) => eitem.id == this.data.bookDetail.id
-        );
-        if (isHas) {
-          wx.showToast({
-            title: "璇ヤ功宸插湪娓呭崟鍒楄〃涓�",
-            icon: "none",
-            duration: 1000,
-          });
-          return false;
-        }
-        let isApply = this.data.alreadyElectronicBookList.find(
-          (eitem) => eitem.content[0].id == this.data.bookDetail.id
-        );
-        if (isApply) {
-          if (isApply.state == 'WaitAudit') {
+      if (role && role == "Teacher") {} else {
+        return wx.showModal({
+          title: "灏婃暚鐨勭敤鎴凤紝鎮ㄥソ锛�", //鎻愮ず鐨勬爣棰�
+          content: "璇峰厛杩涜鏁欏笀璁よ瘉锛�", //鎻愮ず鐨勫唴瀹�
+          confirmColor: "#ff6c00",
+          cancelColor: "#949494",
+          success: function (res) {
+            if (res.confirm) {
+              wx.navigateTo({
+                url: "/packageDomain/pages/teacherCertification/index",
+              });
+            } else if (res.cancel) {}
+          },
+        });
+      }
+      if (
+        this.data.bookDetail.isApplyBook == 2 ||
+        this.data.bookDetail.isApplyBook == 4
+      ) {
+        let role = this.data.userInfo != null ? this.data.userInfo.role : null;
+        if (role && role == "Teacher") {
+          if (!this.data.noFile) {
             wx.showToast({
-              title: "璇ヤ功宸茬敵璇凤紒",
+              title: "鏆傛棤鐢靛瓙涔︽枃浠�,璇疯仈绯荤鐞嗗憳!",
+              icon: "none",
+              duration: 1000,
+            });
+            return;
+          }
+          if (this.data.ebookCount == 0) {
+            wx.showToast({
+              title: "鎮ㄧ殑鐢靛瓙鏍蜂功鐢宠娆℃暟宸茬敤灏斤紝鑻ヨ缁х画锛岃鑱旂郴绠$悊鍛橈紒",
               icon: "none",
               duration: 1000,
             });
             return false;
-          } else if (isApply.state == 'Normal') {
-            const flag = new Date(isApply.feedBack.endDate + ' 23:59:59').getTime() > new Date().getTime()
-            if (flag) {
+          }
+
+          let isHas = this.data.electronicBookList.find(
+            (eitem) => eitem.id == this.data.bookDetail.id
+          );
+          if (isHas) {
+            wx.showToast({
+              title: "璇ヤ功宸插湪娓呭崟鍒楄〃涓�",
+              icon: "none",
+              duration: 1000,
+            });
+            return false;
+          }
+          let isApply = this.data.alreadyElectronicBookList.find(
+            (eitem) => eitem.content[0].id == this.data.bookDetail.id
+          );
+          if (isApply) {
+            if (isApply.state == 'WaitAudit') {
               wx.showToast({
                 title: "璇ヤ功宸茬敵璇凤紒",
                 icon: "none",
                 duration: 1000,
               });
               return false;
+            } else if (isApply.state == 'Normal') {
+              const flag = new Date(isApply.feedBack.endDate + ' 23:59:59').getTime() > new Date().getTime()
+              if (flag) {
+                wx.showToast({
+                  title: "璇ヤ功宸茬敵璇凤紒",
+                  icon: "none",
+                  duration: 1000,
+                });
+                return false;
+              }
             }
           }
-        }
-        if (this.data.electronicBookList.length >= 2) {
-          wx.showToast({
-            title: "姣忔鏈�澶氬彧鍙敵璇�2鏈牱涔�",
-            icon: "none",
-            duration: 1000,
+          if (this.data.electronicBookList.length >= 2) {
+            wx.showToast({
+              title: "姣忔鏈�澶氬彧鍙敵璇�2鏈牱涔�",
+              icon: "none",
+              duration: 1000,
+            });
+            return false;
+          }
+          this.addBookFun(this.data.bookDetail, "eBook");
+        } else {
+          wx.showModal({
+            title: "灏婃暚鐨勭敤鎴凤紝鎮ㄥソ锛�", //鎻愮ず鐨勬爣棰�
+            content: "璇峰厛杩涜鏁欏笀璁よ瘉锛�", //鎻愮ず鐨勫唴瀹�
+            confirmColor: "#ff6c00",
+            cancelColor: "#949494",
+            success: function (res) {
+              if (res.confirm) {
+                wx.navigateTo({
+                  url: "/packageDomain/pages/teacherCertification/index",
+                });
+              } else if (res.cancel) {}
+            },
           });
-          return false;
         }
-        this.addBookFun(this.data.bookDetail, "eBook");
       } else {
-        wx.showModal({
-          title: "灏婃暚鐨勭敤鎴凤紝鎮ㄥソ锛�", //鎻愮ず鐨勬爣棰�
-          content: "璇峰厛杩涜鏁欏笀璁よ瘉锛�", //鎻愮ず鐨勫唴瀹�
-          confirmColor: "#ff6c00",
-          cancelColor: "#949494",
-          success: function (res) {
-            if (res.confirm) {
-              wx.navigateTo({
-                url: "/packageDomain/pages/teacherCertification/index",
-              });
-            } else if (res.cancel) {}
-          },
+        wx.showToast({
+          title: "璇ヤ功涓嶈兘鐢宠鐢靛瓙鏍蜂功",
+          icon: "none",
+          duration: 1000,
         });
       }
-    } else {
-      wx.showToast({
-        title: "璇ヤ功涓嶈兘鐢宠鐢靛瓙鏍蜂功",
-        icon: "none",
-        duration: 1000,
-      });
     }
+    const token = wx.getStorageSync(app.config.tokenKey);
+    if (token) {
+      applyFun()
+    } else {
+      this.logInFun(() => {})
+    }
+
   },
   //鐢宠绾歌川鏍蜂功
   appplyPaperBook() {
-    let role = this.data.userInfo != null ? this.data.userInfo.role : null;
-    if (role && role == "Teacher") {} else {
-      return wx.showModal({
-        title: "灏婃暚鐨勭敤鎴凤紝鎮ㄥソ锛�", //鎻愮ず鐨勬爣棰�
-        content: "璇峰厛杩涜鏁欏笀璁よ瘉锛�", //鎻愮ず鐨勫唴瀹�
-        confirmColor: "#ff6c00",
-        cancelColor: "#949494",
-        success: function (res) {
-          if (res.confirm) {
-            wx.navigateTo({
-              url: "/packageDomain/pages/teacherCertification/index",
-            });
-          } else if (res.cancel) {}
-        },
-      });
-    }
-    if (
-      this.data.bookDetail.isApplyBook == 3 ||
-      this.data.bookDetail.isApplyBook == 4
-    ) {
+    const applyFun = () => {
       let role = this.data.userInfo != null ? this.data.userInfo.role : null;
-      if (role && role == "Teacher") {
-        // 鐐瑰嚮閫変腑
-        if (this.data.paperBookCount == 0) {
-          wx.showToast({
-            title: "鎮ㄧ殑绾歌川鏍蜂功鐢宠娆℃暟宸茬敤灏斤紝鑻ヨ缁х画锛岃鑱旂郴绠$悊鍛橈紒",
-            icon: "none",
-            duration: 1000,
-          });
-          return false;
-        }
-        let isApply = this.data.alreadyPaperBookList.find(
-          (pitem) => pitem.content[0].id == this.data.bookDetail.id
-        );
-        if (isApply) {
-          wx.showToast({
-            title: "璇ヤ功宸茬敵璇凤紒",
-            icon: "none",
-            duration: 1000,
-          });
-          return false;
-        }
-
-        let isHas = this.data.paperBookList.find(
-          (pitem) => pitem.id == this.data.bookDetail.id
-        );
-        if (isHas) {
-          wx.showToast({
-            title: "璇ヤ功宸插湪娓呭崟鍒楄〃涓�",
-            icon: "none",
-            duration: 1000,
-          });
-          return false;
-        }
-        if (this.data.paperBookList.length >= 2) {
-          wx.showToast({
-            title: "姣忔鏈�澶氬彧鍙敵璇�2鏈牱涔�",
-            icon: "none",
-            duration: 1000,
-          });
-          return false;
-        }
-        this.addBookFun(this.data.bookDetail, "pBook");
-      } else {
-        wx.showModal({
+      if (role && role == "Teacher") {} else {
+        return wx.showModal({
           title: "灏婃暚鐨勭敤鎴凤紝鎮ㄥソ锛�", //鎻愮ず鐨勬爣棰�
           content: "璇峰厛杩涜鏁欏笀璁よ瘉锛�", //鎻愮ず鐨勫唴瀹�
           confirmColor: "#ff6c00",
@@ -2439,13 +2565,83 @@
           },
         });
       }
-    } else {
-      wx.showToast({
-        title: "璇ヤ功涓嶈兘鐢宠绾歌川鏍蜂功",
-        icon: "none",
-        duration: 1000,
-      });
+      if (
+        this.data.bookDetail.isApplyBook == 3 ||
+        this.data.bookDetail.isApplyBook == 4
+      ) {
+        let role = this.data.userInfo != null ? this.data.userInfo.role : null;
+        if (role && role == "Teacher") {
+          // 鐐瑰嚮閫変腑
+          if (this.data.paperBookCount == 0) {
+            wx.showToast({
+              title: "鎮ㄧ殑绾歌川鏍蜂功鐢宠娆℃暟宸茬敤灏斤紝鑻ヨ缁х画锛岃鑱旂郴绠$悊鍛橈紒",
+              icon: "none",
+              duration: 1000,
+            });
+            return false;
+          }
+          let isApply = this.data.alreadyPaperBookList.find(
+            (pitem) => pitem.content[0].id == this.data.bookDetail.id
+          );
+          if (isApply) {
+            wx.showToast({
+              title: "璇ヤ功宸茬敵璇凤紒",
+              icon: "none",
+              duration: 1000,
+            });
+            return false;
+          }
+
+          let isHas = this.data.paperBookList.find(
+            (pitem) => pitem.id == this.data.bookDetail.id
+          );
+          if (isHas) {
+            wx.showToast({
+              title: "璇ヤ功宸插湪娓呭崟鍒楄〃涓�",
+              icon: "none",
+              duration: 1000,
+            });
+            return false;
+          }
+          if (this.data.paperBookList.length >= 2) {
+            wx.showToast({
+              title: "姣忔鏈�澶氬彧鍙敵璇�2鏈牱涔�",
+              icon: "none",
+              duration: 1000,
+            });
+            return false;
+          }
+          this.addBookFun(this.data.bookDetail, "pBook");
+        } else {
+          wx.showModal({
+            title: "灏婃暚鐨勭敤鎴凤紝鎮ㄥソ锛�", //鎻愮ず鐨勬爣棰�
+            content: "璇峰厛杩涜鏁欏笀璁よ瘉锛�", //鎻愮ず鐨勫唴瀹�
+            confirmColor: "#ff6c00",
+            cancelColor: "#949494",
+            success: function (res) {
+              if (res.confirm) {
+                wx.navigateTo({
+                  url: "/packageDomain/pages/teacherCertification/index",
+                });
+              } else if (res.cancel) {}
+            },
+          });
+        }
+      } else {
+        wx.showToast({
+          title: "璇ヤ功涓嶈兘鐢宠绾歌川鏍蜂功",
+          icon: "none",
+          duration: 1000,
+        });
+      }
     }
+    const token = wx.getStorageSync(app.config.tokenKey);
+    if (token) {
+      applyFun()
+    } else {
+      this.logInFun(() => {})
+    }
+
   },
   //  娣诲姞鏍蜂功
   addBookFun(item, type) {
@@ -2489,9 +2685,14 @@
 
   //鍘绘牱涔︾敵璇峰崟
   goApply() {
-    wx.navigateTo({
-      url: "/packageDomain/pages/sampleBookList/applicationForm/index",
-    });
+    const token = wx.getStorageSync(app.config.tokenKey);
+    if (token) {
+      wx.navigateTo({
+        url: "/packageDomain/pages/sampleBookList/applicationForm/index",
+      });
+    } else {
+      this.logInFun(() => {})
+    }
   },
   handleTree() {
     // const child = this.selectComponent('#teach-tree')
@@ -2572,15 +2773,26 @@
     return childrenList
   },
   uploadFile(e) {
-    const userInfo = JSON.parse(wx.getStorageSync(app.config.userInfoKey))
-    if (userInfo.role != 'Teacher') return wx.showToast({
-      icon: 'error',
-      title: '璇峰厛杩涜鏁欏笀璁よ瘉',
-    })
-    this.setData({
-      dialogBox: true,
-      isShowUp: true
-    });
+    const uploadFun = () => {
+      const userInfo = JSON.parse(wx.getStorageSync(app.config.userInfoKey))
+      if (userInfo.role != 'Teacher') return wx.showToast({
+        icon: 'error',
+        title: '璇峰厛杩涜鏁欏笀璁よ瘉',
+      })
+      this.setData({
+        dialogBox: true,
+        isShowUp: true
+      });
+    }
+    const token = wx.getStorageSync(app.config.tokenKey);
+    if (token) {
+      uploadFun()
+    } else {
+      this.logInFun(() => {
+        uploadFun()
+      })
+    }
+
   },
   closeDialog() {
     this.setData({
@@ -2806,7 +3018,7 @@
     app.MG.ugc.newTopicMessage(query).then((res) => {
       wx.showToast({
         icon: "success",
-        title: "璇蜂笂浼犺祫婧愭枃浠�",
+        title: "涓婁紶鎴愬姛",
       });
       this.closeDialog()
     })

--
Gitblit v1.9.1