Jelajahi Sumber

优化评论组件

bayi 2 tahun lalu
induk
melakukan
846cd46186

+ 2 - 0
components/comment/index.js

@@ -97,6 +97,8 @@ Component({
           detailDesc: this.data.detailDesc,
         }
         await postReply(data)
+        // 评论数+1
+        this.triggerEvent('addCommentNum', this.data.columnId)
       } else {
         let data = {
           postsId: this.data.postId,

+ 4 - 1
components/videoPreview/index.js

@@ -171,7 +171,10 @@ Component({
         uid
       } = this.properties.videoInfo.userRead
       if (wx.getStorageSync('uid') == uid) {
-        return
+        return wx.showToast({
+          title: '不能收藏自己作品哦!',
+          icon: "none"
+        })
       }
       await collectVideo({
         targetCode: id,

+ 18 - 0
components/worksList/index.js

@@ -16,6 +16,11 @@ Component({
       // value 为public时是默认公共样式,为my时为“我的”样式,展示下载删除是否公开,pk为pk的样式文案,collection为收藏时的样式,excellent优秀作品展播
       value: 'public'
     },
+    // 是否在tabbar页面使用
+    tabBarPadding: {
+      type: Boolean,
+      value: false
+    }
   },
   data: {
     worksListCopy: {}
@@ -34,6 +39,19 @@ Component({
       this.setData({
         worksListCopy
       })
+    },
+    addCommentNum({
+      detail
+    }) {
+      let worksListCopy = JSON.parse(JSON.stringify(this.data.worksListCopy))
+      worksListCopy.forEach(item => {
+        if (item.userRead.id == detail) {
+          item.userRead.commentAmount = ++item.userRead.commentAmount
+        }
+      })
+      this.setData({
+        worksListCopy
+      })
     }
   },
 })

+ 1 - 1
components/worksList/index.wxml

@@ -3,6 +3,6 @@
     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="{{videoType!='my'&&videoType!='collection'?true:false}}" />
+  <Comment id="comment" tabBarPadding="{{tabBarPadding}}" bind:addCommentNum="addCommentNum" />
   <canvas id='share' type=" 2d"> </canvas>
 </view>

+ 1 - 1
pages/index/index.wxml

@@ -31,7 +31,7 @@
   <view class="{{isFixed?'brace':''}}" />
   <!-- 优秀作品展播及官方推荐列表组件 -->
   <worksList id="worksList" wx:if="{{currentType!='3'}}" worksList="{{list}}"
-    videoType="{{currentType=='1'?'excellent':'public'}}" />
+    videoType="{{currentType=='1'?'excellent':'public'}}" tabBarPadding='true' />
   <activityList wx:if="{{currentType=='3'}}" />
 </view>
 <canvas id='share' type="2d"> </canvas>

+ 1 - 1
pages/works/index.wxml

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