const api = require('../../../../utils/understandJs') Page({ data: { textareaValue: "", faCommentId: "", noticeId: "", violationsCount: 0, //违规次数 isConReview: false, lock: false, //锁定提交状态,防止双击 }, onLoad (options) { this.setData({ noticeId: options.noticeId, faCommentId: options.faCommentId }) }, // textarea 双向绑定 bindTextareaValue (e) { this.setData({ textareaValue: e.detail.value.trim(' ') }) }, remarkOrReply () { if (!this.data.textareaValue) { wx.showToast({ title: "请输入评论内容", icon: "none" }) return false } if (this.data.lock) { return false } this.setData({ lock: true }) const para = { noticeId: this.data.noticeId, faCommentId: this.data.faCommentId, content: this.data.textareaValue, // isConReview: this.data.isConReview } wx.showLoading({ title: "提交中..." }) let that = this if (this.data.faCommentId) { //评论 回复 回调 api.commentReplySubmit(para).then(res => { wx.hideLoading() this.setData({ lock: false }) console.log("评论或回复", res) 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) }).catch(err => { console.log(err) this.setData({ lock: false }) }) } else { //对 内容 进行评论 api.commentSubmit(para).then(res => { wx.hideLoading() this.setData({ lock: false }) console.log("评论或回复", res) 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) }).catch(err => { console.log(err) this.setData({ lock: false }) }) } } })