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: [],
@@ -70,12 +76,15 @@
          },
        });
      }
      if (!this.data.isBuyBank) return wx.showToast({
        icon: 'error',
        title: '请先购买题库',
      })
      wx.showLoading({
        title: "加载中",
      });
      // 获取章节下是否有题目
      let idPathList = [];
      if (this.properties.storeInfo || this.properties.jslx) {
        idPathList.push({
          id: this.properties.bookInfo.id,
@@ -115,15 +124,38 @@
        }
      }
      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}&jslx=${this.properties.jslx}`,
      });
      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;
@@ -197,5 +229,14 @@
        loading: type,
      });
    },
    // 题库购买
    buyBank() {
      var myEventDetail = {} // detail对象,提供给事件监听函数
      var myEventOption = {
        bubbles: true,
        composed: true
      } // 触发事件的选项
      this.triggerEvent('buyBank', myEventDetail, myEventOption)
    }
  },
});