zhongshujie
2024-12-05 b00acb907054a7119862de9c037e600b3818e266
packageBookService/pages/bookServices/detail/components/testResource/testResource.js
@@ -5,6 +5,12 @@
   * 组件的属性列表
   */
  properties: {
    isBuyBank: {
      type: Boolean
    },
    bankSaleData: {
      type: Object
    },
    list: {
      type: Array,
      value: [],
@@ -28,6 +34,9 @@
    storeInfo: {
      type: String,
      value: "",
    },
    jslx: {
      type: Boolean,
    },
  },
@@ -57,7 +66,6 @@
      })
    },
    async goTest(e) {
      console.log(e.detail.value.item, 666)
      const value = e.detail.value.item;
      const token = wx.getStorageSync("jsek-token");
      if (!token) {
@@ -68,12 +76,16 @@
          },
        });
      }
      if (!this.data.isBuyBank) return wx.showToast({
        icon: 'error',
        title: '请先购买题库',
      })
      wx.showLoading({
        title: "加载中",
      });
      // 获取章节下是否有题目
      let idPathList = [];
      if (this.properties.storeInfo) {
      if (this.properties.storeInfo || this.properties.jslx) {
        idPathList.push({
          id: this.properties.bookInfo.id,
          name: this.properties.bookInfo.name,
@@ -91,6 +103,7 @@
            size: 999,
          },
        };
        console.log(value.childrenFolderCount, 1234578)
        if (value.childrenFolderCount == 0) {
          wx.hideLoading();
          return wx.showToast({
@@ -107,18 +120,42 @@
              type: item.type,
            });
          });
          console.log(idPathList, 123413456578)
        }
      }
      wx.hideLoading();
      wx.navigateTo({
        url: `/packageBookService/pages/bookServices/examination/examination?bookId=${
          this.properties.bookInfo.id
        }&productLinkPath=${value.productLinkPath}&rootCmsItemId=${
          this.properties.bookInfo.rootCmsItemId
        }&idPathList=${JSON.stringify(idPathList)}&answerTitle=${
          value.name
        }&answerType=${"option"}&storeInfo=${this.properties.storeInfo}`,
      });
      if (value.fromType == "json") {
        const questuionList = this.properties.list
        var psychologyList = []
        var listIndex = 0
        for (let index = 0; index < questuionList.length; index++) {
          const item = questuionList[index];
          if (item.name == "心理测评") {
            psychologyList = [...item.children]
          }
        }
        for (let cindex = 0; cindex < psychologyList.length; cindex++) {
          const citem = psychologyList[cindex];
          if (value.name == citem.name) {
            listIndex = cindex
          }
        }
        wx.navigateTo({
          url: `/packageBookService/pages/psychologyAnswer/psychologyAnswer?listIndex=${
            listIndex
        }`
        })
      } else {
        wx.navigateTo({
          url: `/packageBookService/pages/bookServices/examination/examination?bookId=${
            this.properties.bookInfo.id
          }&productLinkPath=${value.productLinkPath}&rootCmsItemId=${
            this.properties.bookInfo.rootCmsItemId
          }&idPathList=${JSON.stringify(idPathList)}&answerTitle=${
            value.name
          }&answerType=${"option"}&storeInfo=${this.properties.storeInfo}&jslx=${this.properties.jslx}`,
        });
      }
    },
    goMycollect(e) {
      const answertype = e.currentTarget.dataset.answertype;
@@ -192,5 +229,14 @@
        loading: type,
      });
    },
    // 题库购买
    buyBank() {
      var myEventDetail = {} // detail对象,提供给事件监听函数
      var myEventOption = {
        bubbles: true,
        composed: true
      } // 触发事件的选项
      this.triggerEvent('buyBank', myEventDetail, myEventOption)
    }
  },
});