yiming
2024-04-29 9cc35aa83764cb91436750db66e9868c99c1de90
packageBookService/pages/bookServices/detail/components/tree/index.js
@@ -135,6 +135,8 @@
      if (token) {
        const item = e.currentTarget.dataset.item;
        const parent = e.currentTarget.dataset.parent;
        const parentProductLinkPath = parent ? parent.productLinkPath : wx.getStorageSync('teachResourcesPath')
        const parentName = parent ? parent.name : '教学资源'
        let url;
        if (this.properties.isShowCheck && this.resourceIsBuy(item)) {
          return false;
@@ -159,18 +161,48 @@
              "请先购买该资源" : "请先点击领取查看按钮",
          });
        }
        if (item.saleMethod.length == 0 && item.sysType == 'CmsItem' && this.properties.tab == "jsek_cloudLearning") {
          return wx.showToast({
            icon: 'error',
            title: '暂未开始销售,请联系管理员',
          })
        }
        if (this.properties.tab == "jsek_teachingResources" && item.fileMap) {
          if (item.file && item.fileMap[item.file].protectType !== "Public") {
            return wx.showToast({
              icon: 'error',
              title: '资源不可用,请联系管理员',
            })
          } else if (item.freeFile && item.fileMap[item.freeFile].protectType !== "Public") {
            return wx.showToast({
              icon: 'error',
              title: '资源不可用,请联系管理员',
            })
          }
        }
        wx.navigateTo({
          url: `${url}?productLinkPath=${item.productLinkPath}&parentProductLinkPath=${parent.productLinkPath}&parentName=${parent.name}&activeId=${item.id}&bookId=${this.properties.bookInfo.id}&bookName=${this.properties.bookInfo.name}&cmsId=${this.properties.bookInfo.rootCmsItemId}&formPath=${this.properties.tab}`,
          url: `${url}?productLinkPath=${item.productLinkPath}&parentProductLinkPath=${parentProductLinkPath}&parentName=${parentName}&activeId=${item.id}&bookId=${this.properties.bookInfo.id}&bookName=${this.properties.bookInfo.name}&cmsId=${this.properties.bookInfo.rootCmsItemId}&formPath=${this.properties.tab}`,
        });
        console.log(item, '7899');
        if (item.selectType == "document" || item.selectType == "pdf") {
          const fileLink =
            app.config.requestCtx + "/file/api/ApiDownload?md5=" + item.file;
          // freeFile
          if (item.selectType == "document") {
            item.selectType = "pptx"
          }
          console.log(item);
          const fileLink = item.file ?
            app.config.requestCtx + "/file/api/ApiDownload?md5=" + item.file : app.config.requestCtx + "/file/api/ApiDownload?md5=" + item.freeFile
          console.log(fileLink, "fileLink");
          //提示加载中
          util.showLoading();
          // 单次下载允许的最大文件为 200MB
          wx.downloadFile({
            url: fileLink, // 地址已打码,自己换个其他的地址("https://www.xxxxx.com/file/测试通知.pdf")
            url: fileLink,
            // filePath: wx.env.USER_DATA_PATH + `/${item.name}.${item.selectType}`,
            filePath: wx.env.USER_DATA_PATH + `/${item.name}.${item.selectType}`,
            success: function (res) {
              console.log(res, "wx.downloadFile success res");
              if (res.statusCode != 200) {
@@ -178,8 +210,9 @@
                return false;
              }
              var Path = res.tempFilePath; //返回的文件临时地址,用于后面打开本地预览所用
              let data = res.filePath;
              wx.openDocument({
                filePath: Path,
                filePath: data,
                showMenu: true,
                success: function (res) {
                  console.log("打开成功");
@@ -193,6 +226,10 @@
            },
          });
        }
        if (item.selectType == "webpage") {
          this.setData({
            webpageSrc: item.jsek_link,
@@ -201,6 +238,7 @@
        }
      }
    },
    // 拿到所有项
    getAllChildren(id) {
      let result = [];
@@ -514,9 +552,8 @@
            title: "添加成功",
          });
          item.isShopCar = false
          this.triggerEvent("updateCloudLearning")
        }
      }
    },
    sadd() {