Browse Source

update 议题评论和点赞

master
fanp 6 years ago
parent
commit
1cff70baec
  1. 14
      models/topic.js
  2. 73
      pages/topics/interactive/topicArticle/index.js
  3. 9
      pages/topics/interactive/topicArticle/index.wxml
  4. 1
      pages/topics/interactive/topicArticle/index.wxss
  5. 7
      pages/user/index.js
  6. 7
      pages/user/myActivity/index.js
  7. 12
      pages/user/myFavorite/index.js
  8. 7
      pages/user/myIdea/index.js
  9. 7
      pages/user/myMessage/index.js
  10. 7
      pages/user/myTopics/index.js

14
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)

73
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
})
}
})

9
pages/topics/interactive/topicArticle/index.wxml

@ -40,13 +40,13 @@
<view class="topic_comment">
<view class="topic_comment_top">
<view>
{{'评论 ' + comments.length}}
{{'评论 ' + commentList.length}}
</view>
<button class="commnetBtn" size="mini" bindtap="onTapComment">评论</button>
</view>
<view class="comment_info" wx:for="{{commentList}}" wx:key="{{index}}">
<view class="comment_info_left">
<image class="comment_icon" src=""></image>
<image class="comment_icon" src="{{item.commentAvator}}"></image>
</view>
<view class="comment_info_right">
<view class="comment_info_userName">{{item.userName}}</view>
@ -55,10 +55,13 @@
<view class="comment_info_time_left">{{item.time}}</view>
<view class="comment_info_time_right" bindtap="onClickPraise" data-item="{{item}}" data-index='{{index}}'>
<view class="praiseNum">{{item.praiseNum}}</view>
<image class="praiseIcon" src="{{item.isPraise ? praise : unPraise}}"></image>
<image class="praiseIcon" src="{{praise}}"></image>
</view>
</view>
</view>
</view>
</view>
</view>
<modal hidden="{{hiddenmodalput}}" confirm-text="提交" cancel-text="取消" bindcancel="cancel" bindconfirm="confirm">
<textarea bindinput="bingTextAreaInput" value="{{currentComment}}" maxlength="400" placeholder="请输入评论" auto-focus/>
</modal>

1
pages/topics/interactive/topicArticle/index.wxss

@ -120,7 +120,6 @@ image{
width: 30px;
height: 30px;
border-radius: 50%;
background-color: red;
}
.comment_icon{
width: 30px;

7
pages/user/index.js

@ -140,11 +140,10 @@ Page({
onTapItem (e) {
const { type } = e.currentTarget.dataset
console.log(type)
console.log(this.data.userInfo)
if (type === 'myInfo'){
wx.navigateTo({
url: `/pages/user/${type}/index?userIcon=${this.data.userInfo.avatarUrl}&userName=${this.data.userInfo.nickName}&userPhone=${this.data.userInfo.phone || ''}&company=${this.data.userInfo.company || ''}&position=${this.data.userInfo.position || ''}`,
})
// wx.navigateTo({
// url: `/pages/user/${type}/index?userIcon=${this.data.userInfo.avatarUrl}&userName=${this.data.userInfo.nickName}&userPhone=${this.data.userInfo.phone || ''}&company=${this.data.userInfo.company || ''}&position=${this.data.userInfo.position || ''}`,
// })
} else {
wx.navigateTo({
url: `/pages/user/${type}/index`,

7
pages/user/myActivity/index.js

@ -24,7 +24,12 @@ Page({
let page = this.data.currentPage
userModel.getMyActivityList(page,res=>{
console.log(res)
if (res.result.list.length == 0) {
wx.showToast({
title: '暂无数据',
icon: 'none'
})
}
const datas = res.result.list
let tempDatas = []
datas.forEach(item => {

12
pages/user/myFavorite/index.js

@ -18,16 +18,22 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
onShow :function (){
this.fetchMyFavoriteList()
},
fetchMyFavoriteList () {
console.log('啦啦啦')
let page = this.data.currentPage
userModel.getMyFavoriteList(page, res => {
console.log(res)
if (res.result.list.length == 0) {
wx.showToast({
title: '暂无数据',
icon: 'none'
})
}
const datas = res.result.list
let tempDatas = []
datas.forEach(item => {

7
pages/user/myIdea/index.js

@ -26,7 +26,12 @@ Page({
let page = this.data.currentPage
userModel.goldenList(page,res=>{
console.log(res)
if (res.result.list.length == 0) {
wx.showToast({
title: '暂无数据',
icon: 'none'
})
}
const datas = res.result.list
let tempDatas = []
datas.forEach(item => {

7
pages/user/myMessage/index.js

@ -27,7 +27,12 @@ Page({
userModel.getMyMessageList(page,res=>{
console.log('我的消息')
console.log(res)
if (res.result.list.length == 0){
wx.showToast({
title: '暂无数据',
icon: 'none'
})
}
const datas = res.result.list
let tempDatas = []
datas.forEach(item => {

7
pages/user/myTopics/index.js

@ -30,7 +30,12 @@ Page({
let page = this.data.currentPage
userModel.getMyTopics(page,this.data.selectedTitle+1,res=>{
console.log(res)
if (res.result.list.length == 0) {
wx.showToast({
title: '暂无数据',
icon: 'none'
})
}
const datas = res.result.list
let tempDatas = []
datas.forEach(item => {

Loading…
Cancel
Save