import { remarkOrReply } from '../../utils/api' Page({ data: { textareaValue: '', faCommentId: '', detailType: 'issue', issueId: '', projectId: '', isFlag:false, isFirstNum:0,//0:初始状态,1:提交一次审核违规不通过 isConReview:false,//true 强制发送 }, 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) { wx.showToast({ title: '请输入回复内容', icon: 'none' }) return false } // if(this.data.isFlag){ // wx.showToast({ // title: '您的评论已提交,请勿重复提交', // icon: 'none', // duration: 3000 // }) // return false // } // this.setData({ // isFlag:true // }) const para = { issueId: this.data.detailType === 'issue' ? this.data.issueId : '', faCommentId: this.data.faCommentId, content: this.data.textareaValue, itemId: this.data.detailType === 'project' ? this.data.projectId : '', isConReview:this.data.isConReview } wx.showLoading({ title: '加载中...', mask:true }) remarkOrReply(para).then(res => { console.log('评论或回复', res) this.setData({ isConReview:false }) const pages = getCurrentPages() const page = pages[pages.length - 2] if (page.getRemarkList) { page.getRemarkList() } setTimeout(() => { wx.navigateBack() wx.showToast({ title: '评论成功', icon: 'none', duration: 1000 }) wx.hideLoading() // this.setData({ // isFlag:false // }) }, 500) }).catch(err => { let {code} = err if(code==533){ this.checkTitle() }else{ wx.showToast({ title: err, icon: 'none', duration: 6000, mask:true, complete: () => { setTimeout(() => { wx.hideLoading() wx.navigateBack() }, 2000) } }) } // setTimeout(() => { // wx.hideLoading() // }, 2000) }) }, checkTitle(){ let that = this if(this.data.isFirstNum==0){ this.setData({ isFirstNum:++this.data.isFirstNum }) // wx.hideLoading() // wx.showToast({ // title:'内容存在违规信息,请修改后重新提交!', // icon:'none', // duration: 3000, // mask:true // }) }else if(this.data.isFirstNum==1){ wx.hideLoading() wx.showToast({ title:'', icon:'none', duration: 100, mask:true }) wx.showModal({ title: '提示', content: '您提交的内容再次被判定为违规,您确定是否要提交?', success (res) { if (res.confirm) { that.setData({ isConReview:true }) that.remarkOrReply () } else if (res.cancel) { wx.navigateBack() } } }) } }, })