diff --git a/subpages/associationNew/pages/eventlist/eventlist.js b/subpages/associationNew/pages/eventlist/eventlist.js index 0889a45..e80ac2e 100644 --- a/subpages/associationNew/pages/eventlist/eventlist.js +++ b/subpages/associationNew/pages/eventlist/eventlist.js @@ -24,6 +24,7 @@ Page({ focus: false, topicId: '',//被评论的话题ID commentContent: '', + index:0,//点击的第几条数据,用于评论的局部刷新用 }, /** * 生命周期函数--监听页面加载 @@ -108,6 +109,11 @@ Page({ */ onShow: function () { this.setData({ + pageIndex: 1, + pageSize: 10, + nodata: false, + loadMoreType: 'none', + loadMoreVisible: false, topiclist: [], }) this.topiclist() @@ -157,7 +163,6 @@ Page({ //点赞 clicklike(e) { - console.log(JSON.stringify(e)) let index = e.currentTarget.dataset.index // if (this.data.bannedFlag == '1') {//被禁言 @@ -181,24 +186,20 @@ Page({ } statement(para).then(res => { // 点赞成功以后实现局部刷新功能 - console.log(JSON.stringify(that.data.topiclist[index])) var obj= that.data.topiclist[index] // obj.likeFlag = obj.likeFlag == '0' ? '1' : '0' + obj.supportNum = obj.likeFlag == '1' ? obj.supportNum+1 : obj.supportNum-1 that.setData({ ["topiclist["+index+"]"]:obj }) - console.log(JSON.stringify(that.data.topiclist[index])) - // that.setData({ - // topiclist: [], - // }) - // this.topiclist() }).catch(err => { console.log(err) }) }, // Textarea获取焦点 clickTextarea(e) { + let index = e.currentTarget.dataset.index if (this.data.bannedFlag == '1') {//被禁言 wx.showToast({ title: '您已经被禁言', @@ -210,7 +211,8 @@ Page({ this.setData({ ifcomment: true, focus: true, - topicId: e.currentTarget.dataset.id + topicId: e.currentTarget.dataset.id, + index:index }) }, @@ -232,19 +234,24 @@ Page({ let that = this; const para = { - topicId: this.data.topicId,//被评论的话题ID + topicId: that.data.topicId,//被评论的话题ID faCommentId: '',//父评论(被评论)ID - content: this.data.commentContent,//评论内容 + content: that.data.commentContent,//评论内容 } commentSubmit(para).then(res => { + // 评论成功以后实现局部刷新功能 + var obj= that.data.topiclist[that.data.index] + // 评论成功以后评论数量加1 + obj.commentNum = obj.commentNum + 1 + obj.comments.splice(0, 0, {username:obj.nickname,content:para.content}); that.setData({ - topiclist: [], + ["topiclist["+that.data.index+"]"]:obj }) - this.topiclist() }).catch(err => { console.log(err) }) }, + //列表照片的放大查看 previewImage(e) { app.globalData.previewImage = true wx.previewImage({