榆山
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.
 
 

89 lines
2.4 KiB

import { commentSubmit } from '../../../../api/clerkOnline'
Page({
data: {
textareaValue: '',
placeholder: '表达您的观点态度吧~(500字以内)',
topicId: '',
faCommentId: '',//父评论的id
type: ''
},
onLoad(options) {
this.setData({
topicId: options.topicId,
type: options.type,
faCommentId:options.faCommentId
})
if (options.type == "replay") {
// 回复的页面
wx.setNavigationBarTitle({
title: '回复'
})
} else if (options.type == 'comments') {
// 评论的页面
wx.setNavigationBarTitle({
title: '评论'
})
}
},
onShow() {
},
// textarea 双向绑定
bindTextareaValue(e: any) {
this.setData({
textareaValue: e.detail.value
})
},
bindTextareaBlur(e: any){
this.setData({
textareaValue: e.detail.value
})
},
async commentSubmit() {
let obj = {
topicId: this.data.topicId,
faCommentId: this.data.faCommentId,
content: this.data.textareaValue
}
let res: any = await commentSubmit(obj)
},
async goPublish() {
if (this.data.textareaValue === '') {
wx.showToast({
title: '请输入评论内容',
icon: 'none',
duration: 2000
})
return
}
if (this.data.type == 'comments') {
wx.showLoading({
title: '正在提交评论...', //提示的内容,
mask: true, //显示透明蒙层,防止触摸穿透,
success: res => {}
});
await this.commentSubmit()
wx.hideLoading()
wx.setStorageSync('isBackOpenTopic',true)
// wx.navigateTo({ url: `/subpages/clerkOnline/pages/topicDetail/topicDetail?id=${this.data.topicId}` });
wx.navigateBack({
delta: 1 //返回的页面数,如果 delta 大于现有页面数,则返回到首页,
})
}else if(this.data.type == 'replay'){
wx.showLoading({
title: '正在提交评论...', //提示的内容,
mask: true, //显示透明蒙层,防止触摸穿透,
success: res => {}
});
await this.commentSubmit()
wx.hideLoading()
wx.setStorageSync('isBackOpenTopic',true)
wx.navigateBack({
delta: 1 //返回的页面数,如果 delta 大于现有页面数,则返回到首页,
})
// wx.navigateTo({ url: `/subpages/clerkOnline/pages/topicDetail/topicDetail?id=${this.data.topicId}` });
}
}
})