bayi 2 lat temu
rodzic
commit
fc7840ae5c

+ 52 - 13
components/comment/index.js

@@ -30,6 +30,7 @@ Component({
     list: [],
     count: {},
     detailDesc: '',
+    onceId: '',
     postId: '',
     postIndex: '',
     ifGetFocus: false,
@@ -50,6 +51,7 @@ Component({
         animationData: animation.export(),
         columnId,
         type,
+        onceId,
         show: true,
       })
       setTimeout(() => {
@@ -84,7 +86,8 @@ Component({
       let type = currentTarget.dataset.type
       this.setData({
         type,
-        firstData: {}
+        firstData: {},
+        onceId: ''
       })
       this.resetData()
     },
@@ -140,14 +143,12 @@ Component({
       })
     },
     async topping(id) {
-      console.log(this.data.type);
       let res
       if (this.data.type == 'like') {
         res = await getLikeNote(id)
       } else {
         res = await getCommentNote(id)
       }
-      console.log(res);
       this.setData({
         firstData: res
       })
@@ -242,23 +243,61 @@ Component({
       wx.showActionSheet({
         itemList: ['删除评论'],
         success: async () => {
-          let res2 = await delPost({
+          await delPost({
             id,
             type
           })
-          console.log(res2);
+          if (type == '1') {
+            let index = this.data.list.findIndex(item => {
+              return item.id == id
+            })
+            this.data.list.splice(index, 1);
+            this.setData({
+              'count.commentNum': --this.data.count.commentNum,
+              list: this.data.list
+            })
+          } else {
+            let {
+              parent
+            } = currentTarget.dataset
+            let index = this.data.list.findIndex(item => {
+              return item.id == parent
+            })
+            let index2 = this.data.list[index].replyVOList.findIndex(item2 => {
+              return item2.id == id
+            })
+            this.data.list[index].replyVOList.splice(index2, 1);
+            this.setData({
+              list: this.data.list
+            })
+          }
         },
       })
     },
     // 关注
-    async setFans() {
-      /*  if (this.data.videoInfoCopy.isFans) {
-         return
-       }
-       await setFans({
-         uid: this.data.videoInfoCopy.user.uid
-       })
-       this.triggerEvent('setListFans', this.data.videoInfoCopy.user.uid) */
+    async setFans({
+      currentTarget
+    }) {
+      let user = currentTarget.dataset.user
+      if (user.isFans) {
+        return
+      }
+      await setFans({
+        uid: user.user.uid
+      })
+      let listCopy = JSON.parse(JSON.stringify(this.data.list));
+      listCopy.forEach(item => {
+        if (item.user.uid == user.user.uid) {
+          item.isFans = true;
+        }
+      });
+      this.setData({
+        list: listCopy
+      });
+      wx.showToast({
+        title: '已关注',
+        icon: 'none'
+      });
     },
   }
 })

+ 11 - 0
components/comment/index.less

@@ -187,6 +187,17 @@
               }
             }
 
+            .isFans {
+              border: 1rpx solid #969696;
+              background-color: #E2ECFB;
+              color: #333;
+            }
+
+            .pkNum {
+              color: #30C866;
+              font-size: 44rpx;
+              margin-right: 20rpx;
+            }
           }
         }
 

+ 2 - 2
components/comment/index.wxml

@@ -24,7 +24,7 @@
             <view class="replyList" wx:if="{{item.replyVOList.length>0}}">
               <view class="reply" wx:for="{{item.replyVOList}}" wx:for-item="reply" wx:key='id'>
                 <text class="replyTitle">{{reply.user.nickName||reply.user.eid}}</text>
-                <text class="replyContent" data-id='{{reply.id}}' data-type='2'
+                <text class="replyContent" data-parent="{{item.id}}" data-id='{{reply.id}}' data-type='2'
                   bind:longpress="onLongPress">:{{reply.content}}</text>
               </view>
             </view>
@@ -50,7 +50,7 @@
               </view>
               <view class="time">{{item.gmtCreated}}</view>
             </view>
-            <view class="follow {{item.isFans?'isFans':''}}" bindtap="setFans">
+            <view class="follow {{item.isFans?'isFans':''}}" data-user='{{item}}' bindtap="setFans">
               <image src="{{item.isFans?'/static/follow_2.png':'/static/follow_3.png'}}" class="character" mode="" />
               <text class="text">{{item.isFans?'已关注':'关注'}}</text>
             </view>

+ 10 - 0
components/comment/index.wxss

@@ -162,6 +162,16 @@
   height: 22rpx;
   margin-right: 6rpx;
 }
+.commentBox .comment .body .body-box .content .c-like .isFans {
+  border: 1rpx solid #969696;
+  background-color: #E2ECFB;
+  color: #333;
+}
+.commentBox .comment .body .body-box .content .c-like .pkNum {
+  color: #30C866;
+  font-size: 44rpx;
+  margin-right: 20rpx;
+}
 .commentBox .comment .body .body-box .content:last-child {
   border: none;
 }

+ 1 - 1
pages/comment/index.js

@@ -8,7 +8,7 @@ import reachBottom from '~/mixins/reachBottom'
 Page({
   behaviors: [reachBottom],
   data: {},
-  onLoad(options) {
+  onShow(options) {
     this.resetData()
   },
   loadMore() {

+ 1 - 1
pages/like/index.js

@@ -28,7 +28,7 @@ Page({
       likelog
     } = currentTarget.dataset
     wx.navigateTo({
-      url: `/pages/userWorks/index?id=${id}&onceId=${likelog}&type='like'`,
+      url: `/pages/userWorks/index?id=${id}&onceId=${likelog}&type=like`,
     })
   },
 })