litian
2024-06-28 75a9abca4f4cf0ebe579705abc369489cfe20e7c
packageBookService/pages/bookServices/detail/index.js
@@ -992,31 +992,45 @@
    app.MG.store
      .getProductDetail(query)
      .then(async (res) => {
        if (!res.datas.cmsDatas[0].datas.length) {
          return this.setData({
            noResources: true,
            loading: false,
          });
        }
        // 云测试,递归请求里层数据
        if (type.refCode == "questionBank") {
          const data = res.datas.cmsDatas[0].datas.filter((item) => item.type == 'questionBankFolder' && item.childrenFolderCount > 0);
          if (data.length > 0) {
            let list = []
            console.log(query.cmsPath, query.cmsPath.length)
            // 测试 6位// 正式 5位//  测试调用传20,内部7  正式调用传17 内部传6
            const addNum = query.cmsPath.length > 12 ? 7 : query.cmsPath.length > 14 ? 8 : 6
            const num = query.cmsPath.length + addNum
            this.getTreeList(data, num, list, '\\', addNum)
            list = this.ensureTreeConsistency(list)
            let result = [];
            this.findChildIds(list[0].children, result);
            this.setData({
              test: list[0].children,
              loading: false,
              openTeachids: result,
            });
            console.log(this.data.test, "test")
          let data = []
          let result = [];
          if (this.data.options.storeInfo == 'jsek_jslx') {
            data = res.datas.cmsDatas[0].datas.filter((item) => item.type == 'questionBankFolder');
            if (data.length > 0) {
              this.setData({
                test: data,
                loading: false,
                openTeachids: result,
              });
            } else {
              this.setData({
                noResources: true,
                loading: false,
              });
            }
          } else {
            data = res.datas.cmsDatas[0].datas.filter((item) => item.type == 'questionBankFolder' && item.childrenFolderCount > 0);
            if (data.length > 0) {
              let list = []
              // 测试 6位// 正式 5位//  测试调用传20,内部7  正式调用传17 内部传6
              const addNum = query.cmsPath.length > 12 ? 7 : query.cmsPath.length > 14 ? 8 : 6
              const num = query.cmsPath.length + addNum
              this.getTreeList(data, num, list, '\\', addNum)
              list = this.ensureTreeConsistency(list)
              this.findChildIds(list[0].children, result);
              this.setData({
                test: list[0].children,
                loading: false,
                openTeachids: result,
              });
            } else {
              this.setData({
                noResources: true,
                loading: false,
              });
            }
          }
        }
      })
@@ -1112,30 +1126,33 @@
  // 获取展开项
  findChildIds(data, result) {
    let index = 0
    for (let i = 0; i < data.length; i++) {
      if (index < 3) {
        const item = data[i]
        if (item.childrenFolderCount > 0) {
          result.push(item.id)
          for (let j = 0; j < item.children.length; j++) {
            if (index < 3) {
              const childrenItme = item.children[j]
              if (item.childrenCount > 0) {
                result.push(childrenItme.id)
                index += 1
    if (data)
      for (let i = 0; i < data.length; i++) {
        if (index < 3) {
          const item = data[i]
          if (item.childrenFolderCount > 0) {
            result.push(item.id)
            if (item.children) {
              for (let j = 0; j < item.children.length; j++) {
                if (index < 3) {
                  const childrenItme = item.children[j]
                  if (item.childrenCount > 0) {
                    result.push(childrenItme.id)
                    index += 1
                  }
                } else {
                  break
                }
              }
            } else {
              break
            }
          } else if (item.childrenCount > 0) {
            result.push(item.id)
            index += 1
          }
        } else if (item.childrenCount > 0) {
          result.push(item.id)
          index += 1
        } else {
          break
        }
      } else {
        break
      }
    }
  },
  // 图书添加购物车