|
|
@ -1,4 +1,4 @@ |
|
|
const request = require('../../../utils/request') //导入模块
|
|
|
|
|
|
|
|
|
import { getMomentDetail, getCommentList, likeMoment, likeComment, commentMoment } from "../../api/moment" |
|
|
const util = require('../../../utils/util') |
|
|
const util = require('../../../utils/util') |
|
|
const app = getApp() |
|
|
const app = getApp() |
|
|
// pages/moment/detail/index.js
|
|
|
// pages/moment/detail/index.js
|
|
|
@ -42,7 +42,7 @@ Page({ |
|
|
this.data.form.articleId = options.id |
|
|
this.data.form.articleId = options.id |
|
|
wx.showLoading({ title: '加载中', mask: true }) |
|
|
wx.showLoading({ title: '加载中', mask: true }) |
|
|
// /article/get/Article-detail/{id}文章详情
|
|
|
// /article/get/Article-detail/{id}文章详情
|
|
|
request.get('/information-center/article/get/Article-detail/' + options.id).then(result => { |
|
|
|
|
|
|
|
|
getMomentDetail(options.id).then(result => { |
|
|
//成功回调
|
|
|
//成功回调
|
|
|
this.setData({ momentDetail: result.data }) |
|
|
this.setData({ momentDetail: result.data }) |
|
|
this.fetchCommentList() |
|
|
this.fetchCommentList() |
|
|
@ -68,7 +68,7 @@ Page({ |
|
|
} |
|
|
} |
|
|
this.setData({ requesting: true }) |
|
|
this.setData({ requesting: true }) |
|
|
// /article-reply/get/reply-list/in/{articleId} 帖子评论列表
|
|
|
// /article-reply/get/reply-list/in/{articleId} 帖子评论列表
|
|
|
request.get('/information-center/article-reply/get/reply-list/in/' + this.data.id, this.data.form).then(result => { |
|
|
|
|
|
|
|
|
getCommentList(this.data.id, this.data.form).then(result => { |
|
|
if (result.data.records.length) { |
|
|
if (result.data.records.length) { |
|
|
var respList = result.data.records |
|
|
var respList = result.data.records |
|
|
let nowList = `commentList[${this.data.commentList.length}]` |
|
|
let nowList = `commentList[${this.data.commentList.length}]` |
|
|
@ -139,7 +139,7 @@ Page({ |
|
|
wx.showLoading({ title: '处理中', mask: true }) |
|
|
wx.showLoading({ title: '处理中', mask: true }) |
|
|
var form = { content: this.data.comment, articleId: this.data.id} |
|
|
var form = { content: this.data.comment, articleId: this.data.id} |
|
|
// /article-reply/reply 评论
|
|
|
// /article-reply/reply 评论
|
|
|
request.post('/information-center/article-reply/reply', form).then(result => { |
|
|
|
|
|
|
|
|
commentMoment(form).then(result => { |
|
|
this.setData({ inputBottom: 0, focus: false, comment: '' }) |
|
|
this.setData({ inputBottom: 0, focus: false, comment: '' }) |
|
|
wx.hideLoading() |
|
|
wx.hideLoading() |
|
|
util.showToast('评论成功') |
|
|
util.showToast('评论成功') |
|
|
@ -149,7 +149,7 @@ Page({ |
|
|
util.showToast(error) |
|
|
util.showToast(error) |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
likeComment: function(e){ |
|
|
|
|
|
|
|
|
postLikeComment: function(e){ |
|
|
if(!app.globalData.userInfo){ |
|
|
if(!app.globalData.userInfo){ |
|
|
wx.navigateTo({ url: '/pages/login/index' }) |
|
|
wx.navigateTo({ url: '/pages/login/index' }) |
|
|
return |
|
|
return |
|
|
@ -160,7 +160,7 @@ Page({ |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
// /article-reply/like-or-cancel/reply 点赞评论
|
|
|
// /article-reply/like-or-cancel/reply 点赞评论
|
|
|
request.post('/information-center/article-reply/like-or-cancel/reply', {replyId: item.id}).then(result => { |
|
|
|
|
|
|
|
|
likeComment({replyId: item.id}).then(result => { |
|
|
if(item.isLiked){ |
|
|
if(item.isLiked){ |
|
|
this.setData({ |
|
|
this.setData({ |
|
|
['commentList[' + e.currentTarget.dataset.page + '][' + e.currentTarget.dataset.index + '].likeQuantity']: result.data.likeQuantity, |
|
|
['commentList[' + e.currentTarget.dataset.page + '][' + e.currentTarget.dataset.index + '].likeQuantity']: result.data.likeQuantity, |
|
|
@ -185,7 +185,7 @@ Page({ |
|
|
util.showToast('请勿重复点赞') |
|
|
util.showToast('请勿重复点赞') |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
request.post('/information-center/article-reply/like-or-cancel/article', {articleId: this.data.id}).then(result => { |
|
|
|
|
|
|
|
|
likeMoment({articleId: this.data.id}).then(result => { |
|
|
this.setData({ |
|
|
this.setData({ |
|
|
['momentDetail.likeQuantity']: result.data.likeQuantity, |
|
|
['momentDetail.likeQuantity']: result.data.likeQuantity, |
|
|
['momentDetail.isLiked']: 1 |
|
|
['momentDetail.isLiked']: 1 |
|
|
|