瀏覽代碼

更新评论

Rorschach 6 年之前
父節點
當前提交
1b22f89479

+ 7 - 5
pages/groupPage/collage-details/collage-details.js

@@ -70,14 +70,16 @@ Page({
       orderId
     })
     httpRequestApi.getMygroupInfo(orderId).success( res => {
-      console.log('支付详情', res.data.data);
-      const surplusNum = res.data.data.groupPurchaseOrder.headcount - res.data.data.groupPurchaseOrder.joinCount;
+      const groupOrder = res.data.data.groupPurchaseOrder;
+      const surplusNum = groupOrder.headcount - groupOrder.joinCount - 1;
       for(var i = 0; i < surplusNum; i++) {
         this.data.surplusList.push(1);
       }
       //console.log(res.data.data.groupPurchaseOrder.closeTime - res.data.data.groupPurchaseOrder.gmtModified)
       //时间转换
-      const timeList = util.formatTime(res.data.data.groupPurchaseOrder.closeTime - res.data.data.groupPurchaseOrder.gmtModified);
+      const timeList = util.formatTime(groupOrder.closeTime - Date.parse(new Date()));
+      console.log(timeList)
+      res.data.data.joinUserList.unshift(res.data.data.organizer);
       this.setData({
         groupPurchaseInfo: res.data.data.groupPurchaseInfo,
         organizer: res.data.data.organizer,
@@ -85,8 +87,8 @@ Page({
         joinUserList: res.data.data.joinUserList,
         surplusList: this.data.surplusList,
         timeList,
-        productId: res.data.data.groupPurchaseOrder.productId,
-        groupId: res.data.data.groupPurchaseOrder.groupId
+        productId: groupOrder.productId,
+        groupId: groupOrder.groupId
       })
     }).fail( error => {
       console.log('错误', error)

+ 19 - 7
pages/groupPage/group-details/group-details.js

@@ -145,14 +145,15 @@ Page({
   jionSuccess: function (orderId, type) {
     httpRequestApi.getMygroupInfo(orderId).success(res => {
       console.log('拼团详情', res.data.data);
-      const surplusNum = res.data.data.groupPurchaseOrder.headcount - res.data.data.groupPurchaseOrder.joinCount;
+      const groupOrder = res.data.data.groupPurchaseOrder;
+      const surplusNum = groupOrder.headcount - groupOrder.joinCount;
       if (type === 'join') {
         this.data.surplusList.pop();
 
-        if (res.data.data.groupPurchaseOrder.status === 'SUCCESSED') {
-          this.showSuccess(res.data.data.groupPurchaseOrder.organizer, res.data.data.groupPurchaseOrder.organizerPrice)
+        if (groupOrder.status === 'SUCCESSED') {
+          this.showSuccess(groupOrder.organizer, groupOrder.organizerPrice)
         } else {
-          this.goToDetail(res.data.data.groupPurchaseOrder.id)
+          this.goToDetail(groupOrder.id)
         }
 
       } else {
@@ -161,16 +162,27 @@ Page({
         }
       }
 
-      console.log(res.data.data.groupPurchaseOrder.closeTime - res.data.data.groupPurchaseOrder.gmtModified)
+      console.log(groupOrder.closeTime - groupOrder.gmtModified)
       //时间转换
-      const timeList = util.formatTime(res.data.data.groupPurchaseOrder.closeTime - res.data.data.groupPurchaseOrder.gmtModified);
-      console.log(timeList)
+      let timeNow = new Date()
+      // const timeList = util.formatTime(groupOrder.closeTime - groupOrder.gmtModified);
+      const timeList = util.formatTime(groupOrder.closeTime - Date.parse(new Date()));
       this.setData({
         surplusNum,
         joinUserList: res.data.data.joinUserList,
         surplusList: this.data.surplusList,
         timeList,
       })
+      if(groupOrder.groupType === 'PROMOTION'){
+        this.data.joinUserList.unshift(res.data.data.organizer);
+        this.data.surplusList.pop();
+        this.setData({
+          joinUserList: this.data.joinUserList,
+          surplusList: this.data.surplusList,
+          surplusNum: this.data.surplusNum - 1
+        })
+      }
+      console.log(this.data.joinUserList)
       // this.groupSuccess(res.data.data.groupPurchaseOrder.productId, detailId);
     }).fail(error => {
       console.log('错误', error)

+ 1 - 1
pages/groupPage/group-details/group-details.wxss

@@ -157,7 +157,7 @@ scroll-view {
 }
 
 .group-details-btn {
-    position: absolute;
+    position: fixed;
     bottom: 0;
     display: flex;
     width: 100%;

+ 4 - 1
pages/social/replyDetail/replyDetail.js

@@ -16,7 +16,8 @@ Page({
             postId: option.id
         })
         wx.setNavigationBarTitle({
-            title: option.count + '条回复' //页面标题为路由参数
+            // title: option.count + '条回复' //页面标题为路由参数
+            title: '回复详情' //页面标题为路由参数
         })
         this.uid = wx.getStorageSync('uid');
         this.getReplyDetail();
@@ -83,6 +84,8 @@ Page({
         httpRequestApi.postReplyComment(this.uid, data).success(res => {
             this.setData({
                 replyModal: false
+            },()=>{
+                this.getReplyDetail();
             })
         });
     },

+ 51 - 12
pages/social/works/works.js

@@ -22,7 +22,9 @@ Page({
         id: '',
         path: '',
         replyModal: false,
-        totalRead: 0
+        totalRead: 0,
+        pageNo: 1,
+        pageSize: 2
         // shareFlag: false
     },
     onLoad: function (option) {
@@ -33,11 +35,13 @@ Page({
             title: option.title //页面标题为路由参数
         })
 
+        
+        this.uid = wx.getStorageSync('uid');
         this.setData({
             title: option.title,
-            id
+            id,
+            myUid: this.uid
         })
-        this.uid = wx.getStorageSync('uid');
         this.getWorks(this.uid, id);
     },
     onHide: function () {
@@ -85,9 +89,18 @@ Page({
                 // 播放音频失败的回调
             })
             this.innerAudioContext.src = this.data.audioSrc; // 这里可以是录音的临时路径
-            this.getReply();
+
         });
     },
+    onShow() {
+        this.setData({
+            replyList: [],
+            pageNo: 1,
+            pageSize: 2
+        }, () => {
+            this.getReply();
+        })
+    },
     likeWorks: function (e) {
         if (this.data.isLike) {
             wx.showToast({
@@ -236,12 +249,12 @@ Page({
     getReply: function () {
         // let uid = wx.getStorageSync('uid');
         let columnId = this.data.id;
-        let pageNo = 1;
-        let pageSize = 10;
+        let pageNo = this.data.pageNo;
+        let pageSize = this.data.pageSize;
         httpRequestApi.getReply(this.uid, columnId, pageNo, pageSize).success((res) => {
             console.log(res.data.data.list);
             const replyList = res.data.data.list;
-            const replyTemp = [];
+            // const replyTemp = [];
             replyList.forEach((item) => {
                 const temp = {};
                 temp.nickName = item.user.wechatName;
@@ -252,11 +265,12 @@ Page({
                 temp.time = formatDate(item.gmtModified, 3);
                 temp.likes = item.postsAttributeInfo.favors || 0;
                 console.log(temp.time)
-                replyTemp.push(temp);
+                this.data.replyList.push(temp);
             });
             this.setData({
-                replyList: replyTemp,
-                total: res.data.data.totalSize
+                replyList: this.data.replyList,
+                total: res.data.data.totalSize,
+                totalPage: res.data.data.totalNo
             })
         });
     },
@@ -287,15 +301,35 @@ Page({
             }
             httpRequestApi.postReply(this.uid, data).success(res => {
                 console.log(res);
+                this.setData({
+                    inputValue: ''
+                })
+                this.getReply();
             });
+            // 评论成功后刷新数据
+
         }
     },
+    // 触底加载
+    onReachBottom: function () {
+        // 当前在推荐页面 加载推荐
+        if (this.data.pageNo <= this.data.totalPage) {
+            this.setData({
+                pageNo: this.data.pageNo + 1
+            }, () => {
+                this.getReply();
+            })
+        }
+
+
+    },
     // 设置点击时的id
     setSBId: function (e) {
         console.log(e)
         this.setData({
             replySBId: e.currentTarget.dataset.id,
-            replyModal: true
+            replyModal: true,
+            replyIndex: e.currentTarget.dataset.index
         })
     },
     // 回复某个评论
@@ -305,8 +339,13 @@ Page({
             content: this.data.inputSBValue
         }
         httpRequestApi.postReplyComment(this.uid, data).success(res => {
+            console.log(res)
+            const replyWho = this.data.replyList[this.data.replyIndex];
+            const indexStr = `replyList[${this.data.replyIndex}]`;
+            replyWho.replyCount++;
             this.setData({
-                replyModal: false
+                replyModal: false,
+                [indexStr]: replyWho
             })
         });
     },

+ 4 - 1
pages/social/works/works.json

@@ -3,5 +3,8 @@
     "usingComponents": {
         "shareDialog": "/component/share/share",
         "popup": "/component/popup/popup"
-    }
+    },
+    "window": {
+        "onReachBottomDistance": 50
+      }
 }

+ 9 - 9
pages/social/works/works.wxml

@@ -3,12 +3,12 @@
     <view class="readAuthorSection">
         <image class="avatar" src="{{authorAvatar}}" />
         <text class="nickName">{{author}}</text>
-        <view class="like" bindtap="likeWorks">
+        <view class="like" bindtap="likeWorks" wx:if="{{authorUid !== myUid}}">
             <image src="{{isLike? '../../../static/image/liked.png' : '../../../static/image/like.png'}}" />
             <text class="likeBtn">{{isLike ? '已' : ''}}点赞</text>
         </view>
-        <view class="follow">
-            <text class="followBtn" bindtap="follow">{{isFans ? '已' : ''}}关注</text>
+        <view class="follow" wx:if="{{authorUid !== myUid}}">
+            <text class="followBtn" bindtap="follow" >{{isFans ? '已' : ''}}关注</text>
         </view>
     </view>
     <view class="userSection">
@@ -24,10 +24,10 @@
             </view>
         </scroll-view>
     </view>
-    <!-- <view class="commentSection">
+    <view class="commentSection">
         <view class="title">评论({{total}})</view>
         <input class="commentInput" bindconfirm="sendHandler" confirm-type="send" placeholder="听了这么多,说点什么吧" bindinput="inputValue"></input>
-    </view> -->
+    </view>
     <view class="commentArea">
         <view class="commentItem" wx:for="{{replyList}}" wx:key="{{index}}">
             <image class="avatar" src="{{item.avatar}}" />
@@ -35,15 +35,15 @@
                 <text class="nickName">{{item.nickName}}</text>
                 <text class="time">{{item.time}}</text>
                 <text class="gut">{{item.text}}</text>
-                <view class="commentAll" bindtap="goToDetail" data-id="{{item.id}}" data-count="{{item.replyCount}}">
+                <view class="commentAll" bindtap="goToDetail" data-id="{{item.id}}" data-count="{{item.replyCount}}" wx:if="{{item.replyCount}}">
                     共有{{item.replyCount}}条评论
                 </view>
             </view>
             <view class="btnWrapper">
-                <image class="commentBtn" src="../../../static/image/comment.png" bindtap="setSBId" data-id="{{item.id}}" />
-                <text class="commentText">评论</text>
+                <image class="commentBtn" src="../../../static/image/comment.png" bindtap="setSBId" data-id="{{item.id}}" data-index="{{index}}" />
+                <text class="commentText" bindtap="setSBId" data-id="{{item.id}}" data-index="{{index}}" >评论</text>
                 <image class="likeBtn" src="../../../static/image/like.png" data-index="{{index}}" data-likes="{{item.likes}}" data-id="{{item.id}}" bindtap="likeCommend" />
-                <text class="likeText">{{item.likes}}</text>
+                <text class="likeText"  data-index="{{index}}" data-likes="{{item.likes}}" data-id="{{item.id}}" bindtap="likeCommend">{{item.likes}}</text>
             </view>
         </view>
     </view>