Browse Source

接口拆分

integral
zhaoyongnian 5 years ago
parent
commit
0f3c11387e
  1. 64
      epdc-resident-mp-yushan/subpages/association/pages/topicDetail/topicDetail.js

64
epdc-resident-mp-yushan/subpages/association/pages/topicDetail/topicDetail.js

@ -1,4 +1,4 @@
import { getTopicDetail, getRemarkList, closeTopic, publishStatement, getCloseReason } from '../../utils/api' import { getTopicDetail, getRemarkList, closeTopic, publishStatement, getCloseReason, topicComLike, topicComUnlike } from '../../utils/api'
import { getTimestamp } from '../../utils/common' import { getTimestamp } from '../../utils/common'
const app = getApp() const app = getApp()
@ -292,10 +292,10 @@ Page({
} catch (err) { } catch (err) {
return false return false
} }
publishStatement(para).then(res => { topicComLike(para).then(res => {
this.getTopicAltitudeNum() this.getTopicAltitudeNum()
console.log('支持', res) console.log("支持", res)
this.data.remarkList.forEach((item,index) => { this.data.remarkList.forEach((item, index) => {
if (item.commentId === e.detail.commentId) { if (item.commentId === e.detail.commentId) {
this.setData({ this.setData({
[`remarkList[${index}].userLike`]: true, [`remarkList[${index}].userLike`]: true,
@ -304,8 +304,8 @@ Page({
[`remarkList[${index}].opposeNum`]: parseInt(this.data.remarkList[index].opposeNum) > 0 ? parseInt(this.data.remarkList[index].opposeNum) - 1 : 0 [`remarkList[${index}].opposeNum`]: parseInt(this.data.remarkList[index].opposeNum) > 0 ? parseInt(this.data.remarkList[index].opposeNum) - 1 : 0
}) })
wx.showToast({ wx.showToast({
title: '表态成功', title: "表态成功",
icon: 'none', icon: "none",
duration: 2000 duration: 2000
}) })
} }
@ -313,6 +313,27 @@ Page({
}).catch(err => { }).catch(err => {
console.log(err) console.log(err)
}) })
// publishStatement(para).then(res => {
// this.getTopicAltitudeNum()
// console.log('支持', res)
// this.data.remarkList.forEach((item,index) => {
// if (item.commentId === e.detail.commentId) {
// this.setData({
// [`remarkList[${index}].userLike`]: true,
// [`remarkList[${index}].userDislike`]: false,
// [`remarkList[${index}].approveNum`]: parseInt(this.data.remarkList[index].approveNum) + 1,
// [`remarkList[${index}].opposeNum`]: parseInt(this.data.remarkList[index].opposeNum) > 0 ? parseInt(this.data.remarkList[index].opposeNum) - 1 : 0
// })
// wx.showToast({
// title: '表态成功',
// icon: 'none',
// duration: 2000
// })
// }
// })
// }).catch(err => {
// console.log(err)
// })
}, },
// 反对某条评论 debounce 防抖 // 反对某条评论 debounce 防抖
debiunceDispportReply (e) { debiunceDispportReply (e) {
@ -362,20 +383,20 @@ Page({
} catch (err) { } catch (err) {
return false return false
} }
publishStatement(para).then(res => { topicComUnlike(para).then(res => {
this.getTopicAltitudeNum() this.getTopicAltitudeNum()
console.log('反对', res) console.log("反对", res)
this.data.remarkList.forEach((item, index) => { this.data.remarkList.forEach((item, index) => {
if (item.commentId === e.detail.commentId) { if (item.commentId === e.detail.commentId) {
this.setData({ this.setData({
[`remarkList[${index}].userLike`]: false, [`remarkList[${index}].userLike`]: false,
[`remarkList[${index}].userDislike`]: true, [`remarkList[${index}].userDislike`]: true,
[`remarkList[${index}].approveNum`]: parseInt(this.data.remarkList[index].approveNum) > 0 ? parseInt(this.data.remarkList[index].approveNum) - 1: 0, [`remarkList[${index}].approveNum`]: parseInt(this.data.remarkList[index].approveNum) > 0 ? parseInt(this.data.remarkList[index].approveNum) - 1 : 0,
[`remarkList[${index}].opposeNum`]: parseInt(this.data.remarkList[index].opposeNum) + 1 [`remarkList[${index}].opposeNum`]: parseInt(this.data.remarkList[index].opposeNum) + 1
}) })
wx.showToast({ wx.showToast({
title: '表态成功', title: "表态成功",
icon: 'none', icon: "none",
duration: 2000 duration: 2000
}) })
} }
@ -383,6 +404,27 @@ Page({
}).catch(err => { }).catch(err => {
console.log(err) console.log(err)
}) })
// publishStatement(para).then(res => {
// this.getTopicAltitudeNum()
// console.log('反对', res)
// this.data.remarkList.forEach((item, index) => {
// if (item.commentId === e.detail.commentId) {
// this.setData({
// [`remarkList[${index}].userLike`]: false,
// [`remarkList[${index}].userDislike`]: true,
// [`remarkList[${index}].approveNum`]: parseInt(this.data.remarkList[index].approveNum) > 0 ? parseInt(this.data.remarkList[index].approveNum) - 1: 0,
// [`remarkList[${index}].opposeNum`]: parseInt(this.data.remarkList[index].opposeNum) + 1
// })
// wx.showToast({
// title: '表态成功',
// icon: 'none',
// duration: 2000
// })
// }
// })
// }).catch(err => {
// console.log(err)
// })
}, },
// 对评论进行回复 // 对评论进行回复
replyRemark (e) { replyRemark (e) {

Loading…
Cancel
Save