yiming
2024-06-21 f5932f85898de7284c9f16d314b4a1c572b31c73
packageDomain/pages/resourceDetails/myVideo/index.js
@@ -34,13 +34,14 @@
    style: 'height: 248rpx',
    submitType: "new", //  新建 or 编辑
    noteId: '',
    videoChange: true,
    startTime: "", //进入页面当前时间
    pauseTime: 0, //暂停时间
    formPath: '',
    loading: true,
    hidden: true
    hidden: true,
    videoError: false,
    videoLoaidng: false
  },
  // 格式化笔记时间
  convertTimestamp(timestamp) {
@@ -58,16 +59,12 @@
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    wx.setNavigationBarTitle({
      title: '资源详情-音频'
      title: '资源详情-视频'
    });
    const systInfo = wx.getSystemInfoSync();
    const menu = wx.getMenuButtonBoundingClientRect(); // 胶囊信息
    const navBarHeight = (menu.top - systInfo.statusBarHeight) * 2 + menu.height; // 导航栏高度
    console.log(options, 'options');
    this.setData({
      navBarHeight: navBarHeight,
      barHeight: systInfo.statusBarHeight,
@@ -85,7 +82,6 @@
        parentName: options.parentName,
      })
    }
    console.log(options, 'options');
    this.resourceDetailsData()
    this.getNoteList()
  },
@@ -188,7 +184,6 @@
  showDialog(e) {
    this.setData({
      dialogKey: true,
      textvalue: '',
      submitTitle: this.data.titleName
@@ -206,6 +201,9 @@
    wx.navigateBack();
  },
  resourceDetailsData() {
    this.setData({
      videoLoaidng: true
    })
    let query = {
      path: '*',
      queryType: '*',
@@ -232,7 +230,6 @@
    }
    app.MG.store.getProductDetail(query).then(res => {
      res.datas.cmsDatas[0].datas.forEach((item) => {
        console.log(item);
        if (item.selectType === "video" || item.learnSelectType === "video") {
          this.data.threeLeveData.push(item)
          this.setData({
@@ -241,18 +238,18 @@
          this.data.threeLeveData.forEach((items, index) => { // 修改此处添加index参数
            if (this.data.productLinkPath == items.productLinkPath) {
              if (this.data.formPath === "jsek_cloudLearning") {
                console.log(items);
                let file
                items.protectedFile ? file = items.protectedFile : file = items.freeFile
                this.setData({
                  showData: app.config.requestCtx + '/file/api/ApiDownloadForAuthorize?md5=' + items.protectedFile + '&token=' + wx.getStorageSync(app.config.tokenKey),
                  showData: app.config.requestCtx + '/file/api/ApiDownloadForAuthorize?md5=' + file + '&token=' + wx.getStorageSync(app.config.tokenKey),
                  titleName: items.name
                })
              } else {
                this.setData({
                  showData: app.config.requestCtx + '/file/api/ApiDownload?md5=' + items.file,
                  showData: item.file ? app.config.requestCtx + '/file/api/ApiDownload?md5=' + item.file : app.config.requestCtx + '/file/api/ApiDownload?md5=' + item.freeFile,
                  titleName: items.name
                })
              }
              console.log(index, 'index');
              let selectedIndex = index; // 存储选中项的索引
              this.setData({
                selectedId: selectedIndex // 设置选中项的索引
@@ -261,49 +258,34 @@
          });
        }
      })
      this.data.threeLeveData.forEach((item) => {
        console.log(item.name);
      })
      this.setData({
        loading: false,
        hidden: false
      })
      console.log('地址', this.data.showData);
    })
  },
  onVideo(e) {
    if (this.data.showData != '') {
      this.setData({
        showData: ''
      })
    }
    this.setData({
      selectedId: e.currentTarget.dataset.index,
    })
    const item = e.currentTarget.dataset.item
    this.setData({
      videoLoaidng: true,
      selectedId: e.currentTarget.dataset.index,
      showData: '',
      titleName: item.name
    })
    if (item.selectType == "video" || item.learnSelectType === "video") {
      // if (!item.file) {
      //   console.log(1111);
      // }
      if (this.data.formPath === "jsek_cloudLearning") {
        let file
        item.protectedFile ? file = item.protectedFile : file = item.freeFile
        this.setData({
          showData: app.config.requestCtx + '/file/api/ApiDownloadForAuthorize?md5=' + item.protectedFile + '&token=' + wx.getStorageSync(app.config.tokenKey)
          showData: app.config.requestCtx + '/file/api/ApiDownloadForAuthorize?md5=' + file + '&token=' + wx.getStorageSync(app.config.tokenKey)
        })
        console.log(this.data.showData);
      } else {
        this.setData({
          showData: app.config.requestCtx + '/file/api/ApiDownload?md5=' + item.file
          showData: item.file ? app.config.requestCtx + '/file/api/ApiDownload?md5=' + item.file : app.config.requestCtx + '/file/api/ApiDownload?md5=' + item.freeFile,
        })
      }
      console.log(this.data.showData, 'item.file');
    }
  },
@@ -312,15 +294,11 @@
      productId: this.data.bookId,
      appRefCode: app.config.appRefCode
    }).then((res) => {
      console.log(res);
      this.setData({
        topicId: res.id
      })
    })
  },
  newTopicMessageGet() {
    let query = {
@@ -338,7 +316,6 @@
  // 标题改变
  changeTitle(e) {
    console.log(e.currentTarget.dataset.value);
    this.setData({
      flag: e.currentTarget.dataset.value
    })
@@ -381,8 +358,6 @@
      textvalue: e.detail.value
    })
  },
  // 获取笔记列表
  async getNoteList() {
    // this.setData({
@@ -429,7 +404,6 @@
        noteList: res.datas,
        loading: false
      })
      console.log('笔记列表', res.datas);
    })
  },
  // 编辑按钮
@@ -442,7 +416,6 @@
      noteId: note.id,
      dialogKey: true,
    })
    // this.showDialog()
  },
  // 删除笔记
@@ -564,5 +537,16 @@
  },
  videoErrorCallback(e) {
    console.log(e);
  },
  videoError: function (e) {
    console.log('视频加载失败', e);
    this.setData({
      videoError: true
    });
  },
  loadedmetadata(e) {
    this.setData({
      videoLoaidng: false
    })
  }
})