import { remarkOrReply } from '../../utils/api' Page({ data: { textareaValue: '', topicId: '', faCommentId: '', isFlag:false, isFirstNum:0,//0:初始状态,1:提交一次审核违规不通过 isConReview:false,//true 强制发送 }, onLoad (options) { const { topicId, faCommentId } = options this.setData({ topicId, faCommentId }) }, onShow () { }, onReady () { wx.setNavigationBarTitle({ title: '评论' }) }, // textarea 双向绑定 bindTextareaValue (e) { this.setData({ textareaValue: e.detail.value }) }, publish () { if (this.data.textareaValue === '') { wx.showToast({ title: '请输入评论内容', icon: 'none', duration: 2000 }) return false } const para = { topicId: this.data.topicId, faCommentId: this.data.faCommentId, content: this.data.textareaValue, isConReview:this.data.isConReview } wx.showLoading({ title: '加载中', mask:true }) remarkOrReply(para).then(res => { console.log('评论或者回复', res) this.setData({ isConReview:false }) wx.showToast({ title: '评论成功', icon: 'none', duration: 2000 }) wx.navigateBack() wx.hideLoading() }).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() }, 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 // }) setTimeout(()=>{ wx.hideLoading() },3000) }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.publish () } else if (res.cancel) { } } }) } }, })