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.
328 lines
9.7 KiB
328 lines
9.7 KiB
import {
|
|
// remarkOrReply,
|
|
issueCom, issueComReply, itemCom, itemComReply
|
|
} from "../../utils/api"
|
|
|
|
Page({
|
|
data: {
|
|
textareaValue: "",
|
|
faCommentId: "",
|
|
detailType: "issue",
|
|
issueId: "",
|
|
projectId: "",
|
|
violationsCount: 0, //违规次数
|
|
isConReview: false,
|
|
lock: false, //锁定提交状态,防止双击
|
|
},
|
|
onLoad (options) {
|
|
if (options.detailType === "issue") {
|
|
this.setData({
|
|
detailType: "issue",
|
|
issueId: options.detailId,
|
|
faCommentId: options.faCommentId
|
|
})
|
|
} else if (options.detailType === "project") {
|
|
this.setData({
|
|
detailType: "project",
|
|
projectId: options.detailId,
|
|
faCommentId: options.faCommentId
|
|
})
|
|
}
|
|
},
|
|
onShow () {
|
|
|
|
},
|
|
// textarea 双向绑定
|
|
bindTextareaValue (e) {
|
|
this.setData({
|
|
textareaValue: e.detail.value
|
|
})
|
|
},
|
|
remarkOrReply () {
|
|
if (!this.data.textareaValue.trim('')) {
|
|
wx.showToast({
|
|
title: "请输入回复内容",
|
|
icon: "none"
|
|
})
|
|
return false
|
|
}
|
|
const para = {
|
|
issueId: this.data.detailType === "issue" ? this.data.issueId : "",
|
|
faCommentId: this.data.faCommentId,
|
|
content: this.data.textareaValue.trim(''),
|
|
itemId: this.data.detailType === "project" ? this.data.projectId : "",
|
|
isConReview: this.data.isConReview
|
|
}
|
|
this.setData({
|
|
lock: true
|
|
})
|
|
wx.showLoading({
|
|
title: "加载中..."
|
|
})
|
|
let that = this
|
|
if (this.data.faCommentId) { //评论 回复 回调
|
|
if (this.data.detailType === "issue") { //议题
|
|
issueComReply(para).then(res => {
|
|
wx.hideLoading()
|
|
this.setData({
|
|
lock: false
|
|
})
|
|
console.log("评论或回复", res)
|
|
if (res.code == 0) {
|
|
wx.showToast({
|
|
title: "评论成功",
|
|
icon: "none",
|
|
duration: 1000
|
|
})
|
|
this.setData({
|
|
textareaValue: ''
|
|
})
|
|
const pages = getCurrentPages()
|
|
const page = pages[pages.length - 2]
|
|
if (page.getRemarkList) {
|
|
page.getRemarkList()
|
|
}
|
|
setTimeout(() => {
|
|
wx.navigateBack()
|
|
}, 500)
|
|
} else if (res.code == 533) {
|
|
this.data.violationsCount++
|
|
if (this.data.violationsCount == 1){
|
|
wx.showToast({
|
|
title: res.msg,
|
|
icon: "none",
|
|
duration: 2000
|
|
})
|
|
} else if (this.data.violationsCount == 2) {
|
|
wx.showModal({
|
|
title: '提示',
|
|
content: '您提交的内容再次被判定为违规,您确定是否要提交?',
|
|
success (res) {
|
|
if (res.confirm) {
|
|
console.log('用户点击确定')
|
|
that.setData({
|
|
isConReview: true
|
|
})
|
|
that.remarkOrReply()
|
|
} else if (res.cancel) {
|
|
console.log('用户点击取消')
|
|
that.setData({
|
|
violationsCount: 0,
|
|
isConReview: false
|
|
})
|
|
}
|
|
}
|
|
})
|
|
}
|
|
}
|
|
}).catch(err => {
|
|
console.log(err)
|
|
this.setData({
|
|
lock: false
|
|
})
|
|
})
|
|
} else { //项目
|
|
itemComReply(para).then(res => {
|
|
wx.hideLoading()
|
|
this.setData({
|
|
lock: false
|
|
})
|
|
console.log("评论或回复", res)
|
|
if (res.code == 0) {
|
|
wx.showToast({
|
|
title: "评论成功",
|
|
icon: "none",
|
|
duration: 1000
|
|
})
|
|
this.setData({
|
|
textareaValue: ''
|
|
})
|
|
const pages = getCurrentPages()
|
|
const page = pages[pages.length - 2]
|
|
if (page.getRemarkList) {
|
|
page.getRemarkList()
|
|
}
|
|
setTimeout(() => {
|
|
wx.navigateBack()
|
|
}, 500)
|
|
} else if (res.code == 533) {
|
|
this.data.violationsCount++
|
|
if (this.data.violationsCount == 1){
|
|
wx.showToast({
|
|
title: res.msg,
|
|
icon: "none",
|
|
duration: 2000
|
|
})
|
|
} else if (this.data.violationsCount == 2) {
|
|
wx.showModal({
|
|
title: '提示',
|
|
content: '您提交的内容再次被判定为违规,您确定是否要提交?',
|
|
success (res) {
|
|
if (res.confirm) {
|
|
console.log('用户点击确定')
|
|
that.setData({
|
|
isConReview: true
|
|
})
|
|
that.remarkOrReply()
|
|
} else if (res.cancel) {
|
|
console.log('用户点击取消')
|
|
that.setData({
|
|
violationsCount: 0,
|
|
isConReview: false
|
|
})
|
|
}
|
|
}
|
|
})
|
|
}
|
|
}
|
|
}).catch(err => {
|
|
console.log(err)
|
|
this.setData({
|
|
lock: false
|
|
})
|
|
})
|
|
}
|
|
} else { //对 议题/项目 进行评论
|
|
if (this.data.detailType === "issue") { //议题
|
|
issueCom(para).then(res => {
|
|
wx.hideLoading()
|
|
this.setData({
|
|
lock: false
|
|
})
|
|
console.log("评论或回复", res)
|
|
if (res.code == 0) {
|
|
wx.showToast({
|
|
title: "评论成功",
|
|
icon: "none",
|
|
duration: 1000
|
|
})
|
|
this.setData({
|
|
textareaValue: ''
|
|
})
|
|
const pages = getCurrentPages()
|
|
const page = pages[pages.length - 2]
|
|
if (page.getRemarkList) {
|
|
page.getRemarkList()
|
|
}
|
|
setTimeout(() => {
|
|
wx.navigateBack()
|
|
}, 500)
|
|
} else if (res.code == 533) {
|
|
this.data.violationsCount++
|
|
if (this.data.violationsCount == 1){
|
|
wx.showToast({
|
|
title: res.msg,
|
|
icon: "none",
|
|
duration: 2000
|
|
})
|
|
} else if (this.data.violationsCount == 2) {
|
|
wx.showModal({
|
|
title: '提示',
|
|
content: '您提交的内容再次被判定为违规,您确定是否要提交?',
|
|
success (res) {
|
|
if (res.confirm) {
|
|
console.log('用户点击确定')
|
|
that.setData({
|
|
isConReview: true
|
|
})
|
|
that.remarkOrReply()
|
|
} else if (res.cancel) {
|
|
console.log('用户点击取消')
|
|
that.setData({
|
|
violationsCount: 0,
|
|
isConReview: false
|
|
})
|
|
}
|
|
}
|
|
})
|
|
}
|
|
}
|
|
}).catch(err => {
|
|
console.log(err)
|
|
this.setData({
|
|
lock: false
|
|
})
|
|
})
|
|
} else { //项目
|
|
itemCom(para).then(res => {
|
|
wx.hideLoading()
|
|
this.setData({
|
|
lock: false
|
|
})
|
|
console.log("评论或回复", res)
|
|
if (res.code == 0) {
|
|
wx.showToast({
|
|
title: "评论成功",
|
|
icon: "none",
|
|
duration: 1000
|
|
})
|
|
this.setData({
|
|
textareaValue: ''
|
|
})
|
|
const pages = getCurrentPages()
|
|
const page = pages[pages.length - 2]
|
|
if (page.getRemarkList) {
|
|
page.getRemarkList()
|
|
}
|
|
setTimeout(() => {
|
|
wx.navigateBack()
|
|
}, 500)
|
|
} else if (res.code == 533) {
|
|
this.data.violationsCount++
|
|
if (this.data.violationsCount == 1){
|
|
wx.showToast({
|
|
title: res.msg,
|
|
icon: "none",
|
|
duration: 2000
|
|
})
|
|
} else if (this.data.violationsCount == 2) {
|
|
wx.showModal({
|
|
title: '提示',
|
|
content: '您提交的内容再次被判定为违规,您确定是否要提交?',
|
|
success (res) {
|
|
if (res.confirm) {
|
|
console.log('用户点击确定')
|
|
that.setData({
|
|
isConReview: true
|
|
})
|
|
that.remarkOrReply()
|
|
} else if (res.cancel) {
|
|
console.log('用户点击取消')
|
|
that.setData({
|
|
violationsCount: 0,
|
|
isConReview: false
|
|
})
|
|
}
|
|
}
|
|
})
|
|
}
|
|
}
|
|
}).catch(err => {
|
|
console.log(err)
|
|
this.setData({
|
|
lock: false
|
|
})
|
|
})
|
|
}
|
|
}
|
|
// 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)
|
|
// })
|
|
}
|
|
})
|