yiming
2024-06-17 bbd3feaa30f2d980eb55c17f8cb492eae4372b5b
packageBookService/pages/bookServices/detail/index.js
@@ -37,6 +37,8 @@
    openTeachids: [],
    openLearnids: [],
    openTestids: [],
    isGoBuyResource: true,
    learnPath: '',
    applyResourceState: false, // 申请教学资源按钮防抖
    resourceClassList: [], // 资源所属分类
    applyState: "", // 教学资源申请状态
@@ -150,7 +152,8 @@
      },
    ],
    showIndex: '',
    successOrderNumber: ''
    successOrderNumber: '',
    applicationState: '' // 电子样书申请状态
  },
  resetTree: function (e) {
@@ -637,6 +640,8 @@
      this.setData({
        showIndex: '1'
      })
    console.log(this.data.bookDetail.icon, '0111111');
    console.log(this.data.bookDetail.name, '45688');
  },
  // 跳转网店
  goShop(e) {
@@ -745,7 +750,7 @@
    return num
  },
  // 给·目录添加子项数量
  // 给目录添加子项数量
  changeResourceChildren(list) {
    const changeList = (list) => {
      for (let index = 0; index < list.length; index++) {
@@ -767,7 +772,8 @@
  // 扁平化数据转换tree
  getTreeList(rootList, pathLength, newArr, path) {
    for (const item of rootList) {
      if (item.productLinkPath.length == pathLength && item.productLinkPath.includes(path)) {
      // 此处原本 item.productLinkPath.length == pathLength 但 productLinkPath 长度个别书存在4、5位交错
      if ((pathLength - item.productLinkPath.length >= 0 && pathLength - item.productLinkPath.length <= 3) && item.productLinkPath.includes(path)) {
        if (item.sysType == 'CmsItem') {
          if (item.selectType == 'webpage') {
            item.disabled = true
@@ -855,6 +861,7 @@
        SysType: 'CmsFolder',
        // 资源类型,试读文件,是否允许下载等参数
        selectType: [],
        learnSelectType: [],
        freeFile: [],
        file: [],
        protectedFile: [],
@@ -897,7 +904,24 @@
            }
          }
        });
        this.getTreeList(res.datas.cmsDatas[0].datas, 17, list, '\\')
        if (type.refCode == "jsek_cloudLearning") {
          this.setData({
            learnPath: type.productLinkPath
          })
          const dataList = res.datas.cmsDatas[0].datas
          if (dataList.length) {
            const tag = dataList.findIndex(item => item.saleMethod.length && item.saleMethod[0].Price > 0)
            this.setData({
              isGoBuyResource: tag > -1 ? true : false
            })
          } else {
            this.setData({
              isGoBuyResource: false
            })
          }
        }
        const num = query.cmsPath.length + 6
        this.getTreeList(res.datas.cmsDatas[0].datas, num, list, '\\')
        list = this.ensureTreeConsistency(list)
        list = this.changeResourceChildren(list)
        console.log('修改后云', list);
@@ -1323,7 +1347,6 @@
  },
  // 申请教学资源
  applyResource() {
    // if (this.data.applyResourceState) {
    //   return wx.showToast({
    //     icon: "error",
@@ -1559,7 +1582,7 @@
      if (isSHow) {
        return false;
      } else {
        return data.saleMethod[0].price > 0 ? true : false;
        return data.saleMethod[0].Price > 0 ? true : false;
      }
      return !isSHow;
    } else {
@@ -1609,7 +1632,6 @@
  },
  updateShoppingCartHidden() {
    const isSHow = this.data.shoppingCartGetId.some(
      (item) => item == data.saleMethod[0].Id
    );
@@ -1684,19 +1706,19 @@
        };
        // 确认订单
        const confirmOrderRes = await app.MG.store.confirmOrder(parameter);
        console.log(confirmOrderRes.orderNumber, 'confirmOrderRes.orderNumber');
        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);
@@ -2022,6 +2044,7 @@
        this.data.bookBuy +
        "&bookId=" +
        this.data.bookDetail.id,
    });
  },
@@ -2086,6 +2109,20 @@
            list.push(item);
          }
        });
        const smBook = list.find(item => item.content[0].id == this.data.bookDetail.id)
        console.log('已申请', smBook);
        if (smBook && smBook.state == 'Normal') {
          const flag = new Date(smBook.feedBack.endDate + '23:59:59').getTime() > new Date().getTime()
          if (flag) {
            this.setData({
              applicationState: 'Normal'
            })
          } else {
            this.setData({
              applicationState: 'overdue'
            })
          }
        }
        this.setData({
          alreadyElectronicBookList: list,
        });
@@ -2174,15 +2211,27 @@
          return false;
        }
        let isApply = this.data.alreadyElectronicBookList.find(
          (eitem) => eitem.id == this.data.bookDetail.id
          (eitem) => eitem.content[0].id == this.data.bookDetail.id
        );
        if (isApply) {
          wx.showToast({
            title: "该书已申请!",
            icon: "none",
            duration: 1000,
          });
          return false;
          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({
@@ -2250,7 +2299,7 @@
          return false;
        }
        let isApply = this.data.alreadyPaperBookList.find(
          (pitem) => pitem.id == this.data.bookDetail.id
          (pitem) => pitem.content[0].id == this.data.bookDetail.id
        );
        if (isApply) {
          wx.showToast({