闫增涛
2024-09-11 51ad1f2614bc1f976aad98254649bb3c207332ee
packageBookService/pages/bookServices/detail/components/tree/index.js
@@ -137,88 +137,82 @@
    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 : "教学资源";
        if (this.properties.isShowCheck && this.resourceIsBuy(item)) {
          return false;
        }
        if (
          this.properties.tab == "jsek_cloudLearning" &&
          this.resourceIsBuy(item)
        ) {
          return wx.showToast({
            icon: "error",
            title: item.saleMethod[0].Price > 0 ?
              "请先购买该资源" : "请先点击领取查看按钮",
          });
        }
        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") {
            return wx.showToast({
              icon: "error",
              title: "资源不可用,请联系管理员",
            });
          }
        } else if ((this.properties.tab == "jsek_teachingResources" || this.properties.tab == "jsek_cloudLearning") && (!item.file && !item.freeFile && !item.protectedFile)) {
          return wx.showToast({
            icon: 'error',
            title: '暂无资源',
          })
        }
        if (item.selectType == 'zip') {
          if (this.properties.applyState == 'Normal') {
            return wx.showToast({
              icon: 'error',
              title: '请前往PC端下载',
            })
          } else {
            return wx.showToast({
              icon: 'error',
              title: '请先申请下载',
            })
          }
        }
        let url;
        if (item.selectType == "webpage") {
          // 网页类型跳转到网址复制页,因为url传参不能传 带参数的网络地址,所以此处要把网络地址里的传参摘出来,放到url里
          let urlData = ''
          const flags = item.jsek_link.indexOf("?")
          if (flags > -1) {
            urlData = item.jsek_link.slice(flags + 1, item.jsek_link.length)
          }
          url = '/packageBookService/pages/bookServices/linkPage/index'
          return wx.navigateTo({
            url: urlData ? url + `?path=${item.jsek_link.slice(0,flags)}` + '&' + urlData : url + `?path=${item.jsek_link}`
          })
        }
        if (item.selectType == "video" || item.learnSelectType == "video") {
          url = "/packageDomain/pages/resourceDetails/myVideo/index";
        }
        if (
          item.selectType == "audio" ||
          item.learnSelectType == "audio"
        ) {
          url = "/packageDomain/pages/resourceDetails/myAudio/index";
        }
        if (item.selectType == "picture") {
          url = "/packageDomain/pages/resourceDetails/document/index";
        }
        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 (!token) return false
      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 : "教学资源";
      // 资源购买页面(只展示未购买资源) 点击不跳转
      if (this.properties.isShowCheck) return false;
      if (
        this.properties.tab == "jsek_cloudLearning" &&
        this.resourceIsBuy(item)
      ) {
        return wx.showToast({
          icon: "error",
          title: item.saleMethod[0].Price > 0 ?
            "请先购买该资源" : "请先点击领取查看按钮",
        });
      }
      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") {
          return wx.showToast({
            icon: "error",
            title: "资源不可用,请联系管理员",
          });
        }
      }
      if (!item.file && !item.freeFile && !item.protectedFile) {
        return wx.showToast({
          icon: 'error',
          title: '暂无资源',
        })
      }
      if (item.selectType == 'zip') {
        if (this.properties.applyState == 'Normal') {
          return wx.showToast({
            icon: 'error',
            title: '请前往PC端下载',
          })
        } else {
          return wx.showToast({
            icon: 'error',
            title: '请先申请下载',
          })
        }
      }
      let url;
      if (item.selectType == "webpage") {
        // 网页类型跳转到网址复制页,因为url传参不能传 带参数的网络地址,所以此处要把网络地址里的传参摘出来,放到url里
        let urlData = ''
        const flags = item.jsek_link.indexOf("?")
        if (flags > -1) {
          urlData = item.jsek_link.slice(flags + 1, item.jsek_link.length)
        }
        url = '/packageBookService/pages/bookServices/linkPage/index'
        return wx.navigateTo({
          url: urlData ? url + `?path=${item.jsek_link.slice(0,flags)}` + '&' + urlData : url + `?path=${item.jsek_link}`
        })
      }
      if (item.selectType == "video" || item.learnSelectType == "video") {
        url = "/packageDomain/pages/resourceDetails/myVideo/index";
      }
      if (
        item.selectType == "audio" ||
        item.learnSelectType == "audio"
      ) {
        url = "/packageDomain/pages/resourceDetails/myAudio/index";
      }
      if (item.selectType == "picture") {
        url = "/packageDomain/pages/resourceDetails/document/index";
      }
      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}`,
      });
    },
    // 拿到所有项