QYF-GitLab1
5 天以前 0b04ed8c61813de116127100c5236bb2ff040682
packageDomain/pages/resourceDetails/myVideo/index.js
@@ -5,7 +5,6 @@
} from '../../../../assets/js/login';
import moment from 'moment'
Page({
  /**
   * 页面的初始数据
   */
@@ -96,6 +95,8 @@
      activeId: options.activeId,
      storeInfo: options.storeInfo,
      bookId: options.bookId,
      bookName: options.bookName,
      cmsId: options.cmsId,
      parentProductLinkPath: options.parentProductLinkPath,
      productLinkPath: options.productLinkPath,
      formPath: options.formPath,
@@ -115,7 +116,6 @@
    }
    this.getBookInfo(this.data.bookId)
  },
  /**
   * 生命周期函数--监听页面显示
   */
@@ -124,7 +124,6 @@
      startTime: Date.now()
    })
  },
  /**
   * 生命周期函数--监听页面隐藏
   */
@@ -142,7 +141,6 @@
    }
    this.setPlayerList()
  },
  /**
   * 生命周期函数--监听页面卸载
   */
@@ -220,8 +218,6 @@
    app.MG.store.getProductDetail(query).then(async (res) => {
      try {
        this.setData({
          bookName: res.datas.name,
          cmsId: res.datas.rootCmsItemId,
          bookDetail: res.datas,
          buyIdList: res.datas.purchasedSaleMethodIdList,
          learnClassData: res.datas.cmsDatas[0].datas.length > 0 ? res.datas.cmsDatas[0].datas.find(item => item.refCode == "jsek_cloudLearning") : null
@@ -231,9 +227,8 @@
        } else {
          this.resourceDetailsData()
        }
      } catch (error) {
        console.log(err)
        console.log(error)
      }
    });
@@ -282,7 +277,6 @@
      this.resourceDetailsData()
    })
  },
  count(timeStr) {
    const data = {
      appRefCode: app.config.appRefCode,
@@ -301,7 +295,6 @@
    }
    app.MG.job.newJobWithApiNewEvent(data).then((res) => {})
  },
  onTabsChange(event) {
    let tabValue = event.detail.value
    if (tabValue == '1') {
@@ -313,9 +306,7 @@
      activeValues: e.detail.value,
    });
  },
  onTakeNotes() {
  },
  onTakeNotes() {},
  showDialog(e) {
    const token = wx.getStorageSync(app.config.tokenKey);
    if (token) {
@@ -338,6 +329,7 @@
  goBack() {
    wx.navigateBack();
  },
  resourceDetailsData() {
    this.setData({
      videoLoading: true,
@@ -368,24 +360,13 @@
        size: 999
      }
    }
    app.MG.store.getProductDetail(query).then(res => {
      const list = res.datas.cmsDatas[0]?.datas
      if (this.data.source == 'qrcode') {
        let qrData = res.datas.cmsDatas[0].datas.find(ditem => ditem.id == this.data.activeId)
        if (qrData) {
          this.setData({
            threeLeveData: [qrData]
          })
        }
      } else {
        this.setData({
          threeLeveData: []
        })
      }
      list?.forEach(async (item) => {
    app.MG.store.getProductDetail(query).then(async (res) => {
      this.setData({
        isBuy: res.datas.purchasedSaleMethodIdList.includes(res.datas.defaultSaleMethodId)
      })
      res.datas.cmsDatas[0].datas.forEach((item) => {
        if (item.selectType === "video" || item.learnSelectType === "video") {
          if (this.data.storeInfo == 'jsek_digitalCourses') {
            // if (item.sysType == 'CmsItem') this.data.threeLeveData.push(item)
            if (this.data.isBuy) {
              if (item.sysType == 'CmsItem') {
                this.data.threeLeveData.push(item)
@@ -396,36 +377,56 @@
              }
            }
          } else {
            const isBuyCms = await app.MG.file.checkCmsItem({
              cmsItemId: Number(item.id)
            let linkData = this.data.productLinkPath.split("\\");
            linkData.reverse()
            let dataList = linkData.map(item => {
              let data = res.datas.cmsDatas[0].datas.find(citem => citem.id == item);
              if (data) return data;
            })
            if (isBuyCms) {
              this.data.threeLeveData(item)
            } else {
              if (item.freeFile) {
                this.data.threeLeveData(item)
            let isBuy = 1;
            for (let i = 0; i < dataList.length; i++) {
              const dataItem = dataList[i];
              if (dataItem) {
                if (dataItem.saleMethod.length > 0) {
                  isBuy = 2;
                  if (this.data.bookDetail.purchasedSaleMethodIdList.indexOf(dataItem.saleMethod[0].Id) > -1) {
                    isBuy = 3;
                    break;
                  } else {
                    break;
                  }
                }
              }
            }
            if (isBuy == 2) {
              // 未购买
              if (dataList[0].freeFile) {
                this.data.threeLeveData.push(dataList[0])
              } else {
                wx.hideLoading();
                wx.showModal({
                  icon: 'error',
                  title: '温馨提示',
                  content: '请购买资源,即将返回购买页',
                  confirmText: '确定',
                  showCancel: false, // 关闭取消按钮
                  success: (cres) => {
                    if (cres.confirm) {
                      wx.navigateTo({
                        url: '/packageBookService/pages/bookServices/detail/index?id=' + this.data.bookId + '&name=' + this.data.bookName + '&tabValue=' + this.data.formPath,
                      })
                  content: '该资源未购买,将返回购买',
                  success: (res) => {
                    if (res.confirm) {
                      if (this.data.source == 'qrcode') {
                        wx.navigateTo({
                          url: `/packageBookService/pages/bookServices/detail/index?id=${this.data.bookDetail.id}&name=${this.data.bookDetail.name}&tabValue=${this.data.formPath}`,
                        });
                      } else {
                        wx.navigateBack()
                      }
                    }
                  }
                });
                return; // 直接返回,避免执行后续代码
                })
              }
            } else {
              if (this.data.productLinkPath == item.productLinkPath) {
                this.data.threeLeveData.push(dataList[0])
              }
            }
          }
        }
        // }
      })
      if (this.data.threeLeveData.length > 0) {
        this.data.threeLeveData.forEach((items, index) => { // 修改此处添加index参数
@@ -515,7 +516,6 @@
      }
    }
  },
  aliVod(md5, currentVideo) {
    if (md5) {
      let query = {
@@ -558,13 +558,11 @@
      })
    }
  },
  timeUpdate(e) {
    let {
      currentTime,
      duration
    } = e.detail
    this.setData({
      progress: ((currentTime / duration) * 100).toFixed(2)
    })
@@ -608,7 +606,6 @@
        .then((res) => {})
    }
  },
  getProductUserSubmitTopicGet() {
    app.MG.ugc.getProductUserSubmitTopic({
      productId: this.data.bookId,
@@ -619,7 +616,6 @@
      })
    })
  },
  newTopicMessageGet() {
    let query = {
      topicIdOrRefCode: topicId + '',
@@ -633,7 +629,6 @@
      console.log(res);
    })
  },
  // 标题改变
  changeTitle(e) {
    this.setData({
@@ -646,7 +641,6 @@
      submitTitle: e.detail.value
    })
  },
  confirmSuggest() {
    if (!this.data.textvalue.trim()) {
      return wx.showToast({
@@ -734,7 +728,6 @@
      dialogKey: true,
    })
  },
  // 删除笔记
  deleteNote(e) {
    const id = e.currentTarget.dataset.id