From 2d3276fce97e33f5c7f04a74632e18ebb01c3a4d Mon Sep 17 00:00:00 2001
From: yiming <m13691596795@163.com>
Date: 星期一, 15 四月 2024 17:30:16 +0800
Subject: [PATCH] 音频优化1

---
 packageDomain/pages/resourceDetails/myAudio/index.js |   79 +++++++++++++++++++++------------------
 1 files changed, 42 insertions(+), 37 deletions(-)

diff --git a/packageDomain/pages/resourceDetails/myAudio/index.js b/packageDomain/pages/resourceDetails/myAudio/index.js
index c15864e..9a00794 100644
--- a/packageDomain/pages/resourceDetails/myAudio/index.js
+++ b/packageDomain/pages/resourceDetails/myAudio/index.js
@@ -161,7 +161,7 @@
     // 鍋滄闊抽鎾斁
     myAudio.stop();
     // 閿�姣� InnerAudioContext 瀹炰緥
-    myAudio.destroy();
+    // myAudio.destroy();
   },
   count(timeStr) {
     const data = {
@@ -218,7 +218,7 @@
   },
   showDialog(e) {
     this.setData({
-      submitTitle: this.data.bookName,
+      submitTitle: this.data.titleName,
       dialogKey: true,
       textvalue: ''
     });
@@ -240,7 +240,6 @@
       cmsPath: this.data.parentProductLinkPath,
       itemFields: {
         SysType: 'CmsFolder',
-        // 璧勬簮绫诲瀷锛岃瘯璇绘枃浠讹紝鏄惁鍏佽涓嬭浇绛夊弬鏁�
         selectType: [],
         freeFile: [],
         file: [],
@@ -257,44 +256,51 @@
         size: 999
       }
     }
+
     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)
-          this.setData({
-            threeLeveData: this.data.threeLeveData
-          })
-          this.data.threeLeveData.forEach((items, index) => { // 淇敼姝ゅ娣诲姞index鍙傛暟
-            if (this.data.productLinkPath == items.productLinkPath) {
-              if (this.data.formPath == 'jsek_cloudLearning') {
-                // 杩欓噷澶勭悊浜戝涔犵殑
-                this.setData({
-                  showData: app.config.requestCtx + '/file/api/ApiDownloadForAuthorize?md5=' + items.protectedFile + '&token=' + wx.getStorageSync(app.config.tokenKey),
-                  titleName: items.name
-                })
-                this.pubulicPlayFun()
-              } else {
-                this.setData({
-                  showData: app.config.requestCtx + '/file/api/ApiDownload?md5=' + items.file,
-                  titleName: items.name
-                })
-                this.pubulicPlayFun()
-              }
-              let selectedIndex = index; // 瀛樺偍閫変腑椤圭殑绱㈠紩
-              this.setData({
-                selectedId: selectedIndex // 璁剧疆閫変腑椤圭殑绱㈠紩
-              });
-            }
-          });
+          this.data.threeLeveData.push(item);
+        }
+
+
+      });
+      console.log(this.data.threeLeveData);
+      this.data.threeLeveData.forEach((items, indexs) => {
+        if (this.data.productLinkPath == items.productLinkPath) {
+          selectedId = indexs;
+
         }
       })
-      this.data.threeLeveData.forEach((item) => {})
+      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);
+        } else {
+          console.log(datas);
+          showDataUrl = app.config.requestCtx + '/file/api/ApiDownload?md5=' + datas.file;
+        }
+        titleName = datas.name;
+      }
+
       this.setData({
+        threeLeveData: this.data.threeLeveData,
+        selectedId: selectedId,
+        showData: showDataUrl,
+        titleName: titleName,
         loading: false,
         hidden: false
-      })
-    })
+      });
+      this.pubulicPlayFun();
+
+    });
   },
+
   onVideo(e) {
     this.setData({
       myAudioCurrent: '00:00',
@@ -447,7 +453,7 @@
       this.setData({
         "pageCount.total": res.totalSize,
         noteList: res.datas,
-        loading: false
+        // loading: false
       })
       // console.log('绗旇鍒楄〃', res.datas);
     })
@@ -591,15 +597,14 @@
     // 鍦╫nCanplay閲岃幏鍙栧苟璁剧疆闊抽鏃堕暱鍜屾挱鏀捐繘搴�
     myAudio.onCanplay(() => {
       myAudio.duration; //蹇呴』鍐欙紝涓嶇劧鑾峰彇涓嶅埌
-      this.setData({
-        myAudioDuration: this.format(myAudio.duration),
-      })
 
       setTimeout(() => {
+
         this.setData({
           myAudioDuration: this.format(myAudio.duration),
           myAudioCurrent: this.format(myAudio.currentTime)
         });
+
       }, 100);
     });
 
@@ -613,7 +618,7 @@
 
     //杩涘害鏉″彉鍖�   
     myAudio.onTimeUpdate(() => {
-      console.log(this.format(myAudio.duration));
+      // console.log(this.format(myAudio.duration));
       this.setData({
         myAudioPos: myAudio.currentTime / myAudio.duration * 100,
         myAudioCurrent: this.format(myAudio.currentTime),

--
Gitblit v1.9.1