锦水居民端小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

160 lines
4.2 KiB

5 years ago
import {
// remarkOrReply,
issueCom, issueComReply, itemCom, itemComReply
} from "../../utils/api"
6 years ago
Page({
data: {
textareaValue: "",
faCommentId: "",
detailType: "issue",
issueId: "",
projectId: ""
6 years ago
},
onLoad (options) {
if (options.detailType === "issue") {
6 years ago
this.setData({
detailType: "issue",
6 years ago
issueId: options.detailId,
faCommentId: options.faCommentId
})
} else if (options.detailType === "project") {
6 years ago
this.setData({
detailType: "project",
6 years ago
projectId: options.detailId,
faCommentId: options.faCommentId
})
}
},
onShow () {
5 years ago
6 years ago
},
// textarea 双向绑定
bindTextareaValue (e) {
6 years ago
this.setData({
textareaValue: e.detail.value
})
},
remarkOrReply () {
6 years ago
if (!this.data.textareaValue) {
wx.showToast({
title: "请输入回复内容",
icon: "none"
6 years ago
})
return false
}
const para = {
issueId: this.data.detailType === "issue" ? this.data.issueId : "",
6 years ago
faCommentId: this.data.faCommentId,
content: this.data.textareaValue,
itemId: this.data.detailType === "project" ? this.data.projectId : ""
6 years ago
}
wx.showLoading({
title: "加载中..."
6 years ago
})
5 years ago
if (this.data.faCommentId) { //评论 回复 回调
if (this.data.detailType === "issue") { //议题
5 years ago
issueComReply(para).then(res => {
wx.hideLoading()
console.log("评论或回复", res)
5 years ago
wx.showToast({
title: "评论成功",
icon: "none",
5 years ago
duration: 1000
})
const pages = getCurrentPages()
const page = pages[pages.length - 2]
if (page.getRemarkList) {
page.getRemarkList()
}
setTimeout(() => {
wx.navigateBack()
}, 500)
}).catch(err => {
console.log(err)
})
} else { //项目
itemComReply(para).then(res => {
wx.hideLoading()
console.log("评论或回复", res)
5 years ago
wx.showToast({
title: "评论成功",
icon: "none",
5 years ago
duration: 1000
})
const pages = getCurrentPages()
const page = pages[pages.length - 2]
if (page.getRemarkList) {
page.getRemarkList()
}
setTimeout(() => {
wx.navigateBack()
}, 500)
}).catch(err => {
console.log(err)
})
6 years ago
}
5 years ago
} else { //对 议题/项目 进行评论
if (this.data.detailType === "issue") { //议题
5 years ago
issueCom(para).then(res => {
wx.hideLoading()
console.log("评论或回复", res)
5 years ago
wx.showToast({
title: "评论成功",
icon: "none",
5 years ago
duration: 1000
})
const pages = getCurrentPages()
const page = pages[pages.length - 2]
if (page.getRemarkList) {
page.getRemarkList()
}
setTimeout(() => {
wx.navigateBack()
}, 500)
}).catch(err => {
console.log(err)
})
} else { //项目
itemCom(para).then(res => {
wx.hideLoading()
console.log("评论或回复", res)
5 years ago
wx.showToast({
title: "评论成功",
icon: "none",
5 years ago
duration: 1000
})
const pages = getCurrentPages()
const page = pages[pages.length - 2]
if (page.getRemarkList) {
page.getRemarkList()
}
setTimeout(() => {
wx.navigateBack()
}, 500)
}).catch(err => {
console.log(err)
})
}
}
// remarkOrReply(para).then(res => {
// wx.hideLoading()
// console.log('评论或回复', res)
// wx.showToast({
// title: '评论成功',
// icon: 'none',
// duration: 1000
// })
// const pages = getCurrentPages()
// const page = pages[pages.length - 2]
// if (page.getRemarkList) {
// page.getRemarkList()
// }
// setTimeout(() => {
// wx.navigateBack()
// }, 500)
// }).catch(err => {
// console.log(err)
// })
6 years ago
}
})