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.
|
|
|
// pages/topics/common/message/index.js
|
|
|
|
import { TopicModel } from '../../../models/topic.js'
|
|
|
|
let topicModel = new TopicModel()
|
|
|
|
|
|
|
|
Component({
|
|
|
|
/**
|
|
|
|
* 组件的属性列表
|
|
|
|
*/
|
|
|
|
properties: {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 组件的初始数据
|
|
|
|
*/
|
|
|
|
data: {
|
|
|
|
messageTitle:"",
|
|
|
|
messageDetail:"",
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 组件的方法列表
|
|
|
|
*/
|
|
|
|
methods: {
|
|
|
|
bindTextInput(e) {
|
|
|
|
this.setData({
|
|
|
|
messageTitle: e.detail.value
|
|
|
|
})
|
|
|
|
},
|
|
|
|
bindTextAreaInput(e) {
|
|
|
|
this.setData({
|
|
|
|
messageDetail: e.detail.value
|
|
|
|
})
|
|
|
|
},
|
|
|
|
submit() {
|
|
|
|
if (this.data.messageTitle === '') {
|
|
|
|
wx.showModal({
|
|
|
|
title: '提示',
|
|
|
|
content: '请输入标题',
|
|
|
|
showCancel: false
|
|
|
|
})
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if (this.data.messageDetail === ''){
|
|
|
|
wx.showModal({
|
|
|
|
title: '提示',
|
|
|
|
content: '请输入正文内容',
|
|
|
|
showCancel:false
|
|
|
|
})
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
topicModel.addMessage(this.data.messageTitle, this.data.messageDetail,res=>{
|
|
|
|
if(res.code === 200){
|
|
|
|
this.setData({
|
|
|
|
messageTitle:'',
|
|
|
|
messageDetail: ''
|
|
|
|
},()=>{
|
|
|
|
wx.showToast({
|
|
|
|
title: res.message,
|
|
|
|
icon: 'none'
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|