litian
2024-08-27 366de5b4636679392a1e3d2984fc23bd5eaa5ac3
packageBookService/pages/bookServices/detail/components/tree/index.js
@@ -96,6 +96,7 @@
    },
    // 节点展开
    handleChange(e) {
      console.log(e.detail.value);
      this.setData({
        openIds: e.detail.value,
      });
@@ -168,12 +169,13 @@
          item.learnSelectType == "audio"
        ) {
          url = "/packageDomain/pages/resourceDetails/myAudio/index";
        } else if (item.selectType == "picture" || item.selectType == "zip") {
        } else if (item.selectType == "picture") {
          url = "/packageDomain/pages/resourceDetails/document/index";
        }
        if (
          this.properties.tab == "jsek_cloudLearning" &&
          this.resourceIsBuy(item)
          // item.saleMethod.length > 0
        ) {
          return wx.showToast({
            icon: "error",
@@ -181,16 +183,16 @@
              "请先购买该资源" : "请先点击领取查看按钮",
          });
        }
        if (
          item.saleMethod.length == 0 &&
          item.sysType == "CmsItem" &&
          this.properties.tab == "jsek_cloudLearning"
        ) {
          return wx.showToast({
            icon: "error",
            title: "暂未开始销售,请联系管理员",
          });
        }
        // 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.file || item.freeFile)) {
          let file = item.fileMap[item.file] ? item.fileMap[item.file] : item.fileMap[item.freeFile]
          if (file && file.protectType !== "Public") {
@@ -208,7 +210,9 @@
        wx.navigateTo({
          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}&applyState=${this.properties.applyState}&deadline=${this.properties.deadline}`,
        });
        if (item.selectType == "pdf") {
        // debugger
        if (item.selectType == "pdf" || item.selectType == "document") {
          const fileLink = item.file ? item.file : item.freeFile
          console.log(fileLink);
          wx.navigateTo({
@@ -216,50 +220,49 @@
              fileLink +
              "&fileName=" +
              item.name +
              "&fileType=" +
              item.selectType + "&bookBuy=true"
              "&fileType=pdf" + "&bookBuy=true"
          });
        }
        if (item.selectType == "document") {
          // freeFile
          if (item.selectType == "document") {
            item.selectType = "pptx";
          }
          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");
          //提示加载中
          // 单次下载允许的最大文件为 200MB
          wx.downloadFile({
            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) {
                util.hideLoadingWithErrorTips();
                return false;
              }
              var Path = res.tempFilePath; //返回的文件临时地址,用于后面打开本地预览所用
              let data = res.filePath;
              wx.openDocument({
                filePath: data,
                showMenu: true,
                success: function (res) {
                  console.log("打开成功");
                  util.hideLoading();
                },
              });
            },
            fail: function (err) {
              console.log(err, "wx.downloadFile fail err");
              util.hideLoadingWithErrorTips();
            },
          });
        }
        // if (item.selectType == "document") {
        //   // freeFile
        //   // if (item.selectType == "document") {
        //   //   item.selectType = "pptx";
        //   // }
        //   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");
        //   //提示加载中
        //   // 单次下载允许的最大文件为 200MB
        //   wx.downloadFile({
        //     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) {
        //         util.hideLoadingWithErrorTips();
        //         return false;
        //       }
        //       var Path = res.tempFilePath; //返回的文件临时地址,用于后面打开本地预览所用
        //       let data = res.filePath;
        //       wx.openDocument({
        //         filePath: data,
        //         showMenu: true,
        //         success: function (res) {
        //           console.log("打开成功");
        //           util.hideLoading();
        //         },
        //       });
        //     },
        //     fail: function (err) {
        //       console.log(err, "wx.downloadFile fail err");
        //       util.hideLoadingWithErrorTips();
        //     },
        //   });
        // }
        if (item.selectType == "webpage") {
          this.setData({
            webpageSrc: item.jsek_link,