Browse Source

优化删除评论

bayi 2 years ago
parent
commit
a30c94582b

+ 8 - 2
components/comment/index.js

@@ -35,10 +35,12 @@ Component({
     postIndex: '',
     ifGetFocus: false,
     replyType: 'works', // 回复类型,works是回复作品,comment是回复评论
-    animation: {}
+    animation: {},
+    author: '',
+    uid: wx.getStorageSync('uid')
   },
   methods: {
-    async open(columnId, type = 'comment', onceId) {
+    async open(author, columnId, type = 'comment', onceId) {
       console.log(columnId, type, onceId);
       // 背景遮罩层
       var animation = wx.createAnimation({
@@ -52,6 +54,7 @@ Component({
         columnId,
         type,
         onceId,
+        author,
         show: true,
       })
       setTimeout(() => {
@@ -240,6 +243,9 @@ Component({
     onLongPress({
       currentTarget
     }) {
+      if (this.data.uid != this.data.author) {
+        return
+      }
       let {
         id,
         type

+ 1 - 1
components/comment/index.less

@@ -61,7 +61,7 @@
     }
 
     .body {
-      height: 700rpx;
+      height: 500rpx;
 
       .body-box {
         padding: 0rpx 22rpx;

+ 1 - 1
components/comment/index.wxss

@@ -56,7 +56,7 @@
   color: #333333;
 }
 .commentBox .comment .body {
-  height: 700rpx;
+  height: 500rpx;
 }
 .commentBox .comment .body .body-box {
   padding: 0rpx 22rpx;

+ 1 - 0
components/worksList/index.wxml

@@ -3,6 +3,7 @@
   <videoPreview class="videoPreview" wx:for="{{worksListCopy}}" wx:key="index" videoType="{{videoType}}"
     currentTime="{{currentTime}}" sliderValue="{{sliderValue}}" videoInfo="{{item}}" index='{{index}}'
     currentId="{{currentId}}" data-id="{{item.userRead.id}}" data-audio="{{item.userRead.audioPath}}"
+    data-uid="{{item.user.uid}}"
     data-type="{{!item.userReadExtend||item.userReadExtend.resourcesType==0?0:1}}" bind:openComment="openComment"
     bind:setSeek="setSeek" bind:setListFans="setListFans" bind:playAudio="playAudio" bind:playVideo="playVideo"
     bind:deleteVideo='deleteVideo'>

+ 3 - 2
mixins/video.js

@@ -87,13 +87,14 @@ module.exports = Behavior({
     openComment({
       target
     }) {
-      this.selectComponent('#comment').open(target.dataset.id)
+      console.log(target);
+      this.selectComponent('#comment').open(target.dataset.uid,target.dataset.id)
     },
     // 打开设置类型的评论组件
     openTypeComment({
       target
     }) {
-      this.selectComponent('#comment').open(target.dataset.id, target.dataset.type, target.dataset.onceId)
+      this.selectComponent('#comment').open(target.dataset.uid,target.dataset.id, target.dataset.type, target.dataset.onceId)
     },
     // 分享
     creatShare(video) {