bayi преди 2 години
родител
ревизия
c9e71ac9e7
променени са 3 файла, в които са добавени 26 реда и са изтрити 17 реда
  1. 19 11
      components/worksList/index.js
  2. 5 5
      components/worksList/index.wxml
  3. 2 1
      pages/works/index.wxml

+ 19 - 11
components/worksList/index.js

@@ -10,20 +10,28 @@ Component({
         this.setData({
           worksListCopy: newVal
         })
-        this._observer = this.createIntersectionObserver({
-          observeAll: true
-        })
-        this._observer.relativeTo('.playLine')
-          .observe('.videoPreview', (res) => {
-            let intersectionRatio = res.intersectionRatio
-            if (intersectionRatio > 0) {
-              this.setData({
-                currentId: res.dataset.id
-              })
-            }
+        if (this.properties.autoPlay) {
+          // 自动播放
+          this._observer = this.createIntersectionObserver({
+            observeAll: true
           })
+          this._observer.relativeTo('.playLine')
+            .observe('.videoPreview', (res) => {
+              let intersectionRatio = res.intersectionRatio
+              if (intersectionRatio > 0) {
+                this.setData({
+                  currentId: res.dataset.id
+                })
+              }
+            })
+        }
       }
     },
+    // 是否自动播放
+    autoPlay: {
+      type: Boolean,
+      value: true
+    },
     videoType: {
       type: String,
       // value 为public时是默认公共样式,为my时为“我的”样式,展示下载删除是否公开,pk为pk的样式文案,collection为收藏时的样式,excellent优秀作品展播

+ 5 - 5
components/worksList/index.wxml

@@ -1,9 +1,9 @@
 <view class="worksList">
-  <view class="playLine">
-  </view>
-  <videoPreview class="videoPreview" wx:for="{{worksListCopy}}" wx:key="index" videoType="{{videoType}}" videoInfo="{{item}}"
-    index='{{index}}' currentId="{{currentId}}" data-id="{{item.userRead.id}}" data-audio="{{item.userRead.audioPath}}"
-    bind:playVideo="playVideo" bind:openComment="openComment" bind:setListFans="setListFans" bind:playAudio="playAudio">
+  <view class="playLine" />
+  <videoPreview class="videoPreview" wx:for="{{worksListCopy}}" wx:key="index" videoType="{{videoType}}"
+    videoInfo="{{item}}" index='{{index}}' currentId="{{currentId}}" data-id="{{item.userRead.id}}"
+    data-audio="{{item.userRead.audioPath}}" bind:playVideo="playVideo" bind:openComment="openComment"
+    bind:setListFans="setListFans" bind:playAudio="playAudio">
   </videoPreview>
   <Comment id="comment" tabBarPadding="{{tabBarPadding}}" bind:addCommentNum="addCommentNum" />
   <canvas id='share' type=" 2d"> </canvas>

+ 2 - 1
pages/works/index.wxml

@@ -8,6 +8,7 @@
     <view class="type {{currentType=='2'?'currentType':''}}" data-type='2'>我的作品</view>
   </view>
   <!-- 优秀作品展播及官方推荐列表组件 -->
-  <worksList id="worksList" videoType="{{currentType=='1'?'pk':'my'}}" worksList="{{list}}" tabBarPadding='true' />
+  <worksList id="worksList" videoType="{{currentType=='1'?'pk':'my'}}" worksList="{{list}}" tabBarPadding='true'
+    autoPlay='{{false}}' />
 </view>
 <canvas id='share' type="2d"> </canvas>