From 1cff70baec64adfe2709da44b287f0d9e56402bb Mon Sep 17 00:00:00 2001 From: fanp Date: Tue, 22 Oct 2019 17:31:31 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E8=AE=AE=E9=A2=98=E8=AF=84=E8=AE=BA?= =?UTF-8?q?=E5=92=8C=E7=82=B9=E8=B5=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/topic.js | 14 ++++ .../topics/interactive/topicArticle/index.js | 73 +++++++++++++++---- .../interactive/topicArticle/index.wxml | 9 ++- .../interactive/topicArticle/index.wxss | 1 - pages/user/index.js | 7 +- pages/user/myActivity/index.js | 7 +- pages/user/myFavorite/index.js | 12 ++- pages/user/myIdea/index.js | 7 +- pages/user/myMessage/index.js | 7 +- pages/user/myTopics/index.js | 7 +- 10 files changed, 114 insertions(+), 30 deletions(-) diff --git a/models/topic.js b/models/topic.js index f01061d..a1c55c1 100644 --- a/models/topic.js +++ b/models/topic.js @@ -6,6 +6,7 @@ const TopicBaseUrl = { topic_goldenList_url:'/api/comment/goldenList', // 金点子列表 topic_detail_url:'/api/group/queryById/', // 议题详情 topic_detailComment_url:'/api/comment/page', // 评论列表 + topic_addComment_url:'/api/comment/addComment',// 新建议题评论 topic_collect_url:'/api/group/collectGroup/', // 收藏 topic_unCollect_url: '/api/collect/deleteCollection/', // 取消收藏 topic_commentPraise_url: '/api/comment/addSupport/', // 点赞 @@ -89,11 +90,24 @@ class TopicModel extends HTTP { } this.request(params) } + topicAddComment(comment,id,success){ + let params = { + url: TopicBaseUrl.topic_addComment_url, + method: Method.POST, + data:{ + comment: comment, + groupId:id, + }, + success: success + } + this.request(params) + } topicCommentPraise(id,success){ let params = { url: TopicBaseUrl.topic_commentPraise_url + `${id}`, method: Method.POST, + data:{}, success: success } this.request(params) diff --git a/pages/topics/interactive/topicArticle/index.js b/pages/topics/interactive/topicArticle/index.js index 8750720..0578daf 100644 --- a/pages/topics/interactive/topicArticle/index.js +++ b/pages/topics/interactive/topicArticle/index.js @@ -20,16 +20,17 @@ Page({ position:String, detail: String, imgArr:[], - comments:[], unStar: '/images/common/star.png', star: '/images/common/star_light.png', isStar:false, topicId:String, + collectionId:String, isCollect:Number, currPage: 1, commentList: [], - unPraise: '/images/common/zan.png', - praise: '/images/common/star_light.png' + praise: '/images/common/zan.png', + hiddenmodalput:true, + currentComment:'', }, /** @@ -60,6 +61,7 @@ Page({ let data = res.result this.setData({ topicId: data.id, + collectionId: data.collectionId, isCollect: data.isCollect, title:data.title, time: data.createTime, @@ -82,9 +84,8 @@ Page({ let tempDatas = [] datas.forEach(item => { tempDatas.push({ - isPraise: false, id:item.id, - userIcon: item.commentAvator, + commentAvator: item.commentAvator, userName: item.username, detail: item.comment, time: item.createTime, @@ -112,6 +113,7 @@ Page({ }) } } + console.log(this.data.commentList) wx.stopPullDownRefresh() }) }, @@ -130,8 +132,8 @@ Page({ }, fetchTopicUnCollect(){ - let topicId = this.data.topicId - topicModel.topicUnCollect(topicId, res => { + let collectionId = this.data.collectionId + topicModel.topicUnCollect(collectionId, res => { console.log('取消收藏') if (res.code === 200) { this.fetchDetail() @@ -170,19 +172,18 @@ Page({ const tempList = [] commentList.forEach( (item,index)=>{ if (sIndex === index){ - item.isPraise = !item.isPraise + this.fetchTopicCommentPraise(selectItem.id) } - tempList.push(item) - }) - this.setData({ - commentList:tempList, + // tempList.push(item) }) - this.fetchTopicCommentPraise(selectItem.id) + // this.setData({ + // commentList:tempList, + // }) + // this.fetchTopicCommentPraise(selectItem.id) // 评论点赞 }, - onTapComment(){ - }, + // 点击查看图片 previewImg: function (e) { console.log(e.currentTarget.dataset.index); var index = e.currentTarget.dataset.index; @@ -194,5 +195,47 @@ Page({ fail: function (res) { }, complete: function (res) { }, }) + }, + + // 点击评论 + onTapComment(){ + this.setData({ + hiddenmodalput: !this.data.hiddenmodalput + }) + }, + // 弹出框 取消 + cancel: function () { + this.setData({ + hiddenmodalput: true, + currentComment: '' + }); + }, + // 弹出框 确认 + confirm: function () { + + if (!this.data.currentComment){ + wx.showToast({ + title: '请输入评论', + icon: 'none' + }) + return + } + topicModel.topicAddComment(this.data.currentComment, this.data.topicId,res=>{ + if(res.code === 200){ + this.setData({ + hiddenmodalput: true, + currentComment: '' + }) + this.fetchDetailComment() + } + }) + }, + + // 评论输入框 + bingTextAreaInput(e){ + console.log(e.detail.value) + this.setData({ + currentComment: e.detail.value + }) } }) \ No newline at end of file diff --git a/pages/topics/interactive/topicArticle/index.wxml b/pages/topics/interactive/topicArticle/index.wxml index 5bb3b96..7bec99d 100644 --- a/pages/topics/interactive/topicArticle/index.wxml +++ b/pages/topics/interactive/topicArticle/index.wxml @@ -40,13 +40,13 @@ - {{'评论 ' + comments.length}} + {{'评论 ' + commentList.length}} - + {{item.userName}} @@ -55,10 +55,13 @@ {{item.time}} {{item.praiseNum}} - + +