diff --git a/pages/topics/goodIdea/cell/index.js b/pages/topics/goodIdea/cell/index.js index bb4d002..db0f855 100644 --- a/pages/topics/goodIdea/cell/index.js +++ b/pages/topics/goodIdea/cell/index.js @@ -1,13 +1,14 @@ // pages/topics/common/goodIdea/cell/index.js -import { TopicModel } from '../../../../models/topic.js' -let topicModel = new TopicModel() Component({ /** * 组件的属性列表 */ properties: { - itemData:Object, + itemData:{ + type:Object, + value:{} + }, itemIndex:Number }, @@ -16,53 +17,21 @@ Component({ */ data: { unPraise: '/images/common/zan.png', - praise: '/images/common/star_light.png', - currentPage:1 + praise: '/images/common/star_light.png' }, /** * 组件的方法列表 */ methods: { - onTap() { - this.triggerEvent('clickListItem', { itemData: this.properties.itemData }) - }, onClickPraise(e) { - const sIndex = e.currentTarget.dataset.index - var selectItem = e.currentTarget.dataset.item - console.log(selectItem) - // var isPraise = "itemData.isPraise" - // this.setData({ - // [isPraise]:!isPraise - // }) - console.log('啦啦啦') - this.triggerEvent('tapGoodIdeaPraise', {index:sIndex}) - // const commentList = this.data.commentList - // const tempList = [] - // commentList.forEach((item, index) => { - // if (sIndex === index) { - // item.isPraise = !item.isPraise - // } - // tempList.push(item) - // }) - // this.setData({ - // commentList: tempList, - // }) - this.fetchGoodIdeaPraise(selectItem.groupId) - // 评论点赞 + this.triggerEvent('onClickPraise', { itemData: this.properties.itemData }) }, - - fetchGoodIdeaPraise(id) { - topicModel.topicCommentPraise(id, res => { - console.log(res) - if (res.code === 200) { - wx.showToast({ - title: res.message, - icon: 'none' - }) - // this.fetchDetailComment() - } + pushTopic(){ + const topicId = this.properties.itemData.topicGroupId; + wx.navigateTo({ + url: `/pages/topics/interactive/topicArticle/index?topicId=${topicId}`, }) - }, + } } }) diff --git a/pages/topics/goodIdea/cell/index.wxml b/pages/topics/goodIdea/cell/index.wxml index fc576cc..d935294 100644 --- a/pages/topics/goodIdea/cell/index.wxml +++ b/pages/topics/goodIdea/cell/index.wxml @@ -1,13 +1,13 @@ - + - + - {{itemData.userName}} - {{itemData.time}} + {{itemData.commentName}} + {{itemData.commentTime}} @@ -20,24 +20,24 @@ {{itemData.comment}} - - {{itemData.detail.title}} + + {{itemData.topicTtitle}} - + - {{itemData.detail.userName}} - {{itemData.detail.time}} + {{itemData.topicAuthor}} + {{itemData.topicGroupCreateTime}} - {{itemData.detail.commentNum}} + {{itemData.topicCommentNum}} - {{itemData.detail.text}} + {{itemData.topicDetail}} diff --git a/pages/topics/goodIdea/index.js b/pages/topics/goodIdea/index.js index 69baa7c..37b3221 100644 --- a/pages/topics/goodIdea/index.js +++ b/pages/topics/goodIdea/index.js @@ -1,4 +1,7 @@ // pages/topics/goodIdea/index.js +import { TopicModel } from '../../../models/topic.js' +let topicModel = new TopicModel() + Component({ /** * 组件的属性列表 @@ -14,20 +17,18 @@ Component({ * 组件的初始数据 */ data: { - list: [] + commentId:'' }, /** * 组件的方法列表 */ methods: { - clickListItem(e){ + onClickPraise(e){ const itemData = e.detail.itemData; - console.log(itemData); - }, - tapGoodIdeaPraise(e) { - console.log('华加快速度') - console.log(e) + // console.log(itemData); + // this.fetchGoodIdeaPraise(itemData.commentId) + this.triggerEvent('tapGoodIdeaPraise', { commentId: itemData.commentId }) } } }) diff --git a/pages/topics/goodIdea/index.wxml b/pages/topics/goodIdea/index.wxml index 7f3f5d7..601211c 100644 --- a/pages/topics/goodIdea/index.wxml +++ b/pages/topics/goodIdea/index.wxml @@ -4,6 +4,6 @@ + bind:onClickPraise="onClickPraise"/> diff --git a/pages/topics/index.js b/pages/topics/index.js index ee4b634..e61d3a5 100644 --- a/pages/topics/index.js +++ b/pages/topics/index.js @@ -37,7 +37,15 @@ Page({ onShow: function () { // 页面出现在前台时执行 console.log('啦啦啦') - this.fetchTopicList(); + this.setData({ + currPage: 1, + }) + switch (this.data.segmentIndex) { + case 0: + return this.fetchTopicList() + case 1: + return this.fetchGoodIdeaList() + } }, fetchTopicList () { let page = this.data.currPage @@ -51,6 +59,7 @@ Page({ tempDatas.push({ topicId: item.id, title: item.title, + userIcon: item.groupAvator, userName: item.author, commentNum: item.commentNum, topicImg: item.image, @@ -95,22 +104,21 @@ Page({ let tempDatas = [] datas.forEach(item => { tempDatas.push({ - id: item.id, - userIcon: item.image, - groupId: item.groupId, - userName: item.username, - time: item.createTime, + // 评论数据 + commentId: item.id, + commentIcon: item.commentAvator, + commentName: item.username, + commentTime: item.createTime, comment: item.comment, praiseNum: item.supportNum, - isPraise: false, - detail: { - userIcon: item.groupAvator, - userName: item.author, - commentNum: item.commentNum, - title: item.title, - text: item.content, - - } + // 议题数据 + topicTtitle: item.title, + topicGroupAvator: item.groupAvator, + topicAuthor: item.author, + topicGroupCreateTime: item.groupCreateTime, + topicCommentNum: item.commentNum, + topicGroupId: item.groupId, + topicDetail: item.content }) }) if (page == 1) { @@ -185,5 +193,20 @@ Page({ case 1: return this.fetchGoodIdeaList() } - } + }, + tapGoodIdeaPraise(e){ + this.fetchGoodIdeaPraise(e.detail.commentId) + }, + fetchGoodIdeaPraise(id) { + topicModel.topicCommentPraise(id, res => { + console.log(res) + if (res.code === 200) { + wx.showToast({ + title: res.message, + icon: 'none' + }) + this.onPullDownRefresh() + } + }) + }, }) \ No newline at end of file diff --git a/pages/topics/index.wxml b/pages/topics/index.wxml index 62bf97a..526bee8 100644 --- a/pages/topics/index.wxml +++ b/pages/topics/index.wxml @@ -2,6 +2,6 @@ - + diff --git a/pages/topics/interactive/cell/index.wxss b/pages/topics/interactive/cell/index.wxss index 50be128..6fa2f38 100644 --- a/pages/topics/interactive/cell/index.wxss +++ b/pages/topics/interactive/cell/index.wxss @@ -30,12 +30,12 @@ .user-icon{ width: 20px; height: 20px; - border-radius: 50%; - border: 1px solid #ddd; - background-color: #EEEEEE; + /* border-radius: 50%; */ + /* border: 1px solid #ddd; */ + /* background-color: #EEEEEE; */ } .user-icon image { - border-radius: 50%; + /* border-radius: 50%; */ } .userName{ margin: 0 5px 0 5px; diff --git a/pages/topics/interactive/index.wxml b/pages/topics/interactive/index.wxml index 7eed0c1..c29217f 100644 --- a/pages/topics/interactive/index.wxml +++ b/pages/topics/interactive/index.wxml @@ -4,6 +4,7 @@ { tempDatas.push({ - ideaId: item.id, - userIcon: item.image, - groupId: item.groupId, - userName: item.username, - time: item.createTime, + // 评论数据 + commentId: item.id, + commentIcon: item.commentAvator, + commentName: item.username, + commentTime: item.createTime, comment: item.comment, praiseNum: item.supportNum, - detail: { - userIcon: item.groupAvator, - userName: item.author, - commentNum: item.commentNum, - title: item.title, - text: item.content - } + // 议题数据 + topicTtitle: item.title, + topicGroupAvator: item.groupAvator, + topicAuthor: item.author, + topicGroupCreateTime: item.groupCreateTime, + topicCommentNum: item.commentNum, + topicGroupId: item.groupId, + topicDetail: item.content }) }) if (page == 1) { diff --git a/pages/user/myTopics/index.js b/pages/user/myTopics/index.js index e83b735..31c3605 100644 --- a/pages/user/myTopics/index.js +++ b/pages/user/myTopics/index.js @@ -42,6 +42,7 @@ Page({ tempDatas.push({ topicId: item.id, title: item.title, + userIcon: item.groupAvator, userName: item.author, commentNum: item.commentNum, topicImg: item.image, @@ -73,54 +74,6 @@ Page({ wx.stopPullDownRefresh() }) }, - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { - - }, // 定义点击标题的事件处理函数,将选中标题的id赋值给selectedTitle tapSegment: function (e) { diff --git a/pages/user/myTopics/myParticipant/cell/index.wxml b/pages/user/myTopics/myParticipant/cell/index.wxml index e22691b..d32a89f 100644 --- a/pages/user/myTopics/myParticipant/cell/index.wxml +++ b/pages/user/myTopics/myParticipant/cell/index.wxml @@ -8,7 +8,7 @@ - + {{userName}} {{time}} diff --git a/pages/user/myTopics/myParticipant/cell/index.wxss b/pages/user/myTopics/myParticipant/cell/index.wxss index 07c439e..feb5cc7 100644 --- a/pages/user/myTopics/myParticipant/cell/index.wxss +++ b/pages/user/myTopics/myParticipant/cell/index.wxss @@ -42,6 +42,10 @@ border-radius: 50%; background-color: #EEEEEE; } +.img{ + width: 20px; + height: 20px; +} .userName{ margin: 0 5px 0 5px; font-size: 12px; diff --git a/pages/user/myTopics/myParticipant/index.wxml b/pages/user/myTopics/myParticipant/index.wxml index e500879..8a503c9 100644 --- a/pages/user/myTopics/myParticipant/index.wxml +++ b/pages/user/myTopics/myParticipant/index.wxml @@ -3,7 +3,8 @@