yiming
2024-04-16 cb15c57d0ff984f5a100cf25d560fb0a69c00984
packageBookService/pages/bookServices/detail/components/tree/index.js
@@ -58,6 +58,7 @@
    selectAll: [],
    shoppingCart: true,
    stop: false,
    cart: true
  },
  ready() {},
@@ -131,9 +132,12 @@
    goPlayer(e) {
      // 检查登录状态
      const token = wx.getStorageSync(app.config.tokenKey);
      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,8 +163,10 @@
          });
        }
        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}`,
        });
        if (item.selectType == "document" || item.selectType == "pdf") {
          const fileLink =
            app.config.requestCtx + "/file/api/ApiDownload?md5=" + item.file;
@@ -169,7 +175,7 @@
          util.showLoading();
          // 单次下载允许的最大文件为 200MB
          wx.downloadFile({
            url: fileLink, // 地址已打码,自己换个其他的地址("https://www.xxxxx.com/file/测试通知.pdf")
            url: fileLink,
            success: function (res) {
              console.log(res, "wx.downloadFile success res");
              if (res.statusCode != 200) {
@@ -192,6 +198,84 @@
            },
          });
        }
        // if (item.selectType == "document" || item.selectType == "pdf") {
        //   const fileLink = app.config.requestCtx + "/file/api/ApiDownload?md5=" + item.file;
        //   let filePath = wx.env.USER_DATA_PATH + '/' + item.name
        //   console.log(filePath, 'filePath');
        //   //提示加载中
        //   util.showLoading();
        //   // 单次下载允许的最大文件为 200MB
        //   wx.downloadFile({
        //     url: fileLink,
        //     success: function (res) {
        //       if (res.statusCode != 200) {
        //         util.hideLoadingWithErrorTips();
        //         return false;
        //       }
        //       var Path = res.tempFilePath; //返回的文件临时地址,用于后面打开本地预览所用
        //       wx.saveFile({
        //         tempFilePath: Path,
        //         success: function (res) {
        //           var savedFilePath = res.savedFilePath;
        //           // 将文件保存为 item.name
        //           wx.saveFile({
        //             tempFilePath: savedFilePath,
        //             filePath: wx.env.USER_DATA_PATH + '/' + item.name,
        //             success: function (res) {
        //               wx.openDocument({
        //                 filePath: res.savedFilePath,
        //                 showMenu: true,
        //                 success: function (res) {
        //                   util.hideLoading();
        //                 },
        //               });
        //             },
        //             fail: function (err) {
        //               util.hideLoadingWithErrorTips();
        //             }
        //           });
        //         },
        //         fail: function (err) {
        //           util.hideLoadingWithErrorTips();
        //         }
        //       });
        //     },
        //     fail: function (err) {
        //       util.hideLoadingWithErrorTips();
        //     },
        //   });
        // }
        if (item.selectType == "webpage") {
          this.setData({
            webpageSrc: item.jsek_link,
@@ -200,6 +284,7 @@
        }
      }
    },
    // 拿到所有项
    getAllChildren(id) {
      let result = [];
@@ -469,6 +554,9 @@
    // 加入购物车
    async onCloudShoppingCart(e) {
      let shoppingCartGetId = [];
      const item = e.currentTarget.dataset.item
      console.log(item.isShopCar);
      const saleMethodId = e.currentTarget.dataset.item.saleMethod[0].Id;
      console.log(saleMethodId);
      let query = {
@@ -504,10 +592,15 @@
        };
        const addRes = await app.MG.store.addShoppingCart(query);
        console.log(addRes, "addRes");
        wx.showToast({
          icon: "success",
          title: "添加成功",
        });
        if (addRes) {
          wx.showToast({
            icon: "success",
            title: "添加成功",
          });
          item.isShopCar = false
          this.triggerEvent("updateCloudLearning")
        }
      }
    },
    sadd() {