Przeglądaj źródła

各个页面适配音频

bayi 1 rok temu
rodzic
commit
9d5a771397

+ 2 - 2
components/videoPreview/index.wxml

@@ -38,7 +38,7 @@
     </view>
   </view>
   <!-- 视频 -->
-  <view class="workContent">
+  <view class="workContent" wx:if="{{else}}">
     <!-- 审核中遮罩 -->
     <view class="videoBox" wx:if="{{videoInfoCopy.userRead.status=='CHECK'&&videoInfoCopy.userRead.id!=currentId}}">
       <view class="maskBg"></view>
@@ -57,7 +57,7 @@
     </video>
   </view>
   <!-- 音频 -->
-  <view class="workContent" wx:if="{{else}}">
+  <view class="workContent" >
     <view class="audioBox">
       <image src="{{videoInfoCopy.userRead.coverImg}}" class="audioBg" mode="" />
       <view class="mask"></view>

+ 1 - 2
components/worksList/index.js

@@ -6,7 +6,6 @@ Component({
       type: Array,
       value: [],
       observer(newVal) {
-        console.log(newVal);
         this.setData({
           worksListCopy: newVal
         })
@@ -21,6 +20,7 @@ Component({
   data: {
     worksListCopy: {}
   },
+
   methods: {
     setListFans({
       detail
@@ -36,5 +36,4 @@ Component({
       })
     }
   },
-
 })

+ 16 - 0
mixins/video.js

@@ -3,6 +3,11 @@ module.exports = Behavior({
     currentId: '',
   },
   properties: {},
+  pageLifetimes: {
+    hide() {
+      this.resetAudio()
+    },
+  },
   methods: {
     // 开始播放
     playVideo({
@@ -12,6 +17,7 @@ module.exports = Behavior({
         currentId: currentTarget.dataset.id
       })
     },
+    // 播放音频
     playAudio({
       currentTarget
     }) {
@@ -39,6 +45,16 @@ module.exports = Behavior({
         currentId: currentTarget.dataset.id
       })
     },
+    // 重置音频
+    resetAudio() {
+      console.log('触发重置');
+      if (this.innerAudioContext) {
+        this.innerAudioContext.stop();
+      }
+      this.setData({
+        currentId: ''
+      })
+    },
     // 打开评论
     openComment({
       target

+ 1 - 0
pages/index/index.js

@@ -105,6 +105,7 @@ Page({
         currentType: target.dataset.type
       })
       this.resetData()
+      this.selectComponent('#worksList').resetAudio()
     }
   },
 })

+ 28 - 27
pages/pkPage/index.wxml

@@ -1,29 +1,30 @@
 <view class="pkBox">
-    <videoPreview videoInfo="{{videoInfo}}" currentId="{{currentId}}" data-id="{{videoInfo.userRead.id}}"
-        bind:playVideo="playVideo" bind:openComment="openComment" videoType='pk' />
-    <!-- 挑战记录列表 -->
-    <view class="pkRecord">
-        <view class="title">挑战记录</view>
-        <scroll-view scroll-y="true" class="scrollBox" enhanced="true" show-scrollbar="{{false}}">
-            <view class="record" wx:for="{{20}}" wx:key="index">
-                <view class="record-left">
-                    <view class="rl-avatar">
-                        <image src="/static/contact.png" mode="" class="avatar" />
-                    </view>
-                    <view class="rl-info">
-                        <view class="nickName">叮当猫</view>
-                        <view class="time">2023-02-12 13:13</view>
-                    </view>
-                </view>
-                <view class="record-right">
-                    <view class="score">
-                        96分
-                    </view>
-                    <image src="/static/play.png" class="play" mode="" />
-                </view>
-            </view>
-        </scroll-view>
-    </view>
-    <Comment id="comment" />
-    <canvas id='share' type="2d"> </canvas>
+  <videoPreview videoInfo="{{videoInfo}}" currentId="{{currentId}}" data-id="{{videoInfo.userRead.id}}"
+    bind:playVideo="playVideo" bind:playAudio="playAudio" data-audio="{{videoInfo.userRead.audioPath}}"
+    bind:openComment="openComment" videoType='pk' />
+  <!-- 挑战记录列表 -->
+  <view class="pkRecord">
+    <view class="title">挑战记录</view>
+    <scroll-view scroll-y="true" class="scrollBox" enhanced="true" show-scrollbar="{{false}}">
+      <view class="record" wx:for="{{20}}" wx:key="index">
+        <view class="record-left">
+          <view class="rl-avatar">
+            <image src="/static/contact.png" mode="" class="avatar" />
+          </view>
+          <view class="rl-info">
+            <view class="nickName">叮当猫</view>
+            <view class="time">2023-02-12 13:13</view>
+          </view>
+        </view>
+        <view class="record-right">
+          <view class="score">
+            96分
+          </view>
+          <image src="/static/play.png" class="play" mode="" />
+        </view>
+      </view>
+    </scroll-view>
+  </view>
+  <Comment id="comment" />
+  <canvas id='share' type="2d"> </canvas>
 </view>