From bbba5d26e9e26c910ed337dcb65f462752ee6dce Mon Sep 17 00:00:00 2001
From: litian <C21AF165>
Date: 星期四, 12 九月 2024 09:11:47 +0800
Subject: [PATCH] fenxiang

---
 packageDomain/pages/resourceDetails/myAudio/index.js |  109 +++++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 90 insertions(+), 19 deletions(-)

diff --git a/packageDomain/pages/resourceDetails/myAudio/index.js b/packageDomain/pages/resourceDetails/myAudio/index.js
index 2e996c8..afd12cd 100644
--- a/packageDomain/pages/resourceDetails/myAudio/index.js
+++ b/packageDomain/pages/resourceDetails/myAudio/index.js
@@ -1,6 +1,9 @@
 // pages/resourceDetails/index.js
 const app = getApp()
 const myAudio = wx.createInnerAudioContext();
+import {
+  loginInfo
+} from '../../../../assets/js/login';
 // innerAudioContext.onPlay(function callback),
 // InnerAudioContext.onTimeUpdate(function callback)
 Page({
@@ -19,6 +22,7 @@
     dialogKey: false,
     style: 'border: 2rpx solid rgba(220,220,220,1);border-radius: 12rpx;',
     activeId: '',
+    storeInfo: '',
     bookId: '',
     bookName: '',
     cmsId: '',
@@ -26,6 +30,7 @@
     parentProductLinkPath: '',
     productLinkPath: '',
     threeLeveData: [],
+    source: "",
     showData: '',
     src: '',
     selectedId: null,
@@ -47,7 +52,9 @@
     pauseTime: 0, //鏆傚仠鏃堕棿
     formPath: '',
     loading: true,
-    hidden: true
+    hidden: true,
+    playerList: [],
+    progress: 0,
   },
 
   format(time) {
@@ -87,12 +94,14 @@
       navBarHeight: navBarHeight,
       barHeight: systInfo.statusBarHeight,
       activeId: options.activeId,
+      storeInfo: options.storeInfo,
       bookId: options.bookId,
       bookName: options.bookName,
       cmsId: options.cmsId,
       parentProductLinkPath: options.parentProductLinkPath,
       productLinkPath: options.productLinkPath,
-      formPath: options.formPath
+      formPath: options.formPath,
+      source: options.source,
     })
 
     if (options.parentName !== "鏁欏璧勬簮" && options.parentName !== "浜戝涔�") {
@@ -100,8 +109,21 @@
         parentName: options.parentName,
       })
     }
-    this.resourceDetailsData()
-    this.getNoteList()
+    const token = wx.getStorageSync(app.config.tokenKey)
+    if (!token) {
+      loginInfo(app, (data) => {
+        if (data) {
+          this.resourceDetailsData()
+          this.getNoteList()
+        } else {
+          this.resourceDetailsData()
+          this.getNoteList()
+        }
+      })
+    } else {
+      this.resourceDetailsData()
+      this.getNoteList()
+    }
   },
 
   /**
@@ -130,6 +152,7 @@
       let duration = this.data.pauseTime - this.data.startTime
       this.count(duration)
     }
+    this.setPlayerList()
   },
 
   /**
@@ -162,6 +185,7 @@
     myAudio.stop();
     // 閿�姣� InnerAudioContext 瀹炰緥
     // myAudio.destroy();
+    this.setPlayerList()
   },
   count(timeStr) {
     const data = {
@@ -198,9 +222,8 @@
   /**
    * 鐢ㄦ埛鐐瑰嚮鍙充笂瑙掑垎浜�
    */
-  onShareAppMessage() {
-
-  },
+  onShareAppMessage() {},
+  onShareTimeline() {},
   onTabsChange(event) {},
 
   onTabsClick(event) {},
@@ -251,28 +274,36 @@
         size: 999
       }
     }
-
+    if (this.data.storeInfo) {
+      query.storeInfo = this.data.storeInfo
+    }
     app.MG.store.getProductDetail(query).then(res => {
       let selectedId = -1; // 鍒濆鍖栭�変腑椤圭储寮�
       let showDataUrl = '';
       let titleName = '';
 
       res.datas.cmsDatas[0].datas.forEach((item, index) => {
-        if (item.selectType === "audio" || item.learnSelectType === "audio") {
-          this.data.threeLeveData.push(item);
+        if (this.data.source == 'qrcode') {
+          if (item.id == this.data.activeId) {
+            this.data.threeLeveData.push(item);
+          }
+        } else {
+          if (item.selectType === "audio" || item.learnSelectType === "audio") {
+            this.data.threeLeveData.push(item);
+          }
         }
+
       });
       this.data.threeLeveData.forEach((items, indexs) => {
         if (this.data.productLinkPath == items.productLinkPath) {
           selectedId = indexs;
-
         }
       })
       if (selectedId !== -1) {
         let datas = this.data.threeLeveData[selectedId];
-
         if (this.data.formPath == 'jsek_cloudLearning') {
-          showDataUrl = app.config.requestCtx + '/file/api/ApiDownloadForAuthorize?md5=' + datas.protectedFile + '&token=' + wx.getStorageSync(app.config.tokenKey);
+          let file = datas.protectedFile ? datas.protectedFile : datas.file
+          showDataUrl = app.config.requestCtx + '/file/api/ApiDownloadForAuthorize?md5=' + file + '&token=' + wx.getStorageSync(app.config.tokenKey);
         } else {
           showDataUrl = datas.file ? app.config.requestCtx + '/file/api/ApiDownload?md5=' + datas.file : app.config.requestCtx + '/file/api/ApiDownload?md5=' + datas.freeFile
         }
@@ -288,29 +319,33 @@
         hidden: false
       });
       this.pubulicPlayFun();
-
     });
   },
 
   onVideo(e) {
+    this.setPlayerList()
     this.setData({
       myAudioCurrent: '00:00',
       myAudioPos: '',
       isplay: false
     })
     const item = e.currentTarget.dataset.item
+    console.log(item, 222)
     if (this.data.showData != '') {
       this.setData({
         titleName: item.name,
         selectId: item.id,
         selectedId: e.currentTarget.dataset.index,
-        showData: ''
+        showData: '',
+        activeId: item.id
+
       })
       if (item.selectType == "audio" || item.learnSelectType === "audio") {
         if (this.data.formPath == 'jsek_cloudLearning') {
+          let file = item.protectedFile ? item.protectedFile : item.file
           // 杩欓噷澶勭悊浜戝涔犵殑
           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)
           })
           this.pubulicPlayFun()
         } else {
@@ -563,7 +598,6 @@
   },
   // 鎾斁鍏叡浠g爜
   pubulicPlayFun() {
-    // debugger
     this.setData({
       speed: 1.0,
     })
@@ -609,8 +643,9 @@
         myAudioPos: myAudio.currentTime / myAudio.duration * 100,
         myAudioCurrent: this.format(myAudio.currentTime),
         myAudioDuration: this.format(myAudio.duration),
+        progress: ((myAudio.currentTime / myAudio.duration) * 100).toFixed(2)
       });
-      console.log(myAudio.currentTime.toFixed(3), myAudio.duration);
+      // console.log(myAudio.currentTime.toFixed(3), myAudio.duration);
     })
   },
 
@@ -760,5 +795,41 @@
       myAudio.playbackRate = this.data.speed; //  鎾斁閫熺巼
     }, 200);
   },
-
+  //鑾峰彇闊抽瀛︿範
+  getPlayerList() {
+    app.MG.identity
+      .getUserKey({
+        domain: 'videoPlayer',
+        keys: [this.data.bookId]
+      })
+      .then((res) => {
+        if (res.length > 0) {
+          this.setData({
+            playerList: JSON.parse(res[0].value)
+          })
+        }
+      })
+  },
+  setPlayerList() {
+    let that = this
+    if (that.data.progress > 0) {
+      let index = that.data.playerList.findIndex((itemData) => itemData.cmsItemId == that.data.selectId)
+      if (index > -1) {
+        that.data.playerList.splice(index, 1)
+      }
+      that.data.playerList.push({
+        cmsItemId: that.data.selectId,
+        progress: that.data.progress
+      })
+      app.MG.identity
+        .setUserKey({
+          setKeyRequests: [{
+            domain: 'videoPlayer',
+            key: that.data.bookId,
+            value: JSON.stringify(that.data.playerList)
+          }]
+        })
+        .then((res) => {})
+    }
+  },
 })
\ No newline at end of file

--
Gitblit v1.9.1