// pages/waterabnormal/feedback/feedback.js const app = getApp(); Page({ /** * 页面的初始数据 */ data: { title: '预警反馈', loading: false, color: '#000', background: '#ffffff', show: true, animated: false, formData: { id: "", feedbackStatus: 1, feedbackContent: "" } }, toBack() { wx.navigateBack({ delta: 1 }) }, fieldChange(e) { const { value } = e.detail; this.setData({ 'formData.feedbackStatus': value }) }, contentChange(e) { const { value } = e.detail; this.setData({ 'formData.feedbackContent': value }) }, submit() { const { id, feedbackStatus, feedbackContent } = this.data.formData; if (feedbackStatus == 2 && !feedbackContent) { wx.showToast({ title: '请输入反馈信息内容', icon: 'none' }) return; } app.$http.postForm('/warningMessage/feedback', { id, feedbackStatus, feedbackContent }).then(({ status, msg, data = {} }) => { if (status == 0) { wx.showToast({ title: '反馈成功', icon: 'none' }) setTimeout(() => { this.toBack(); }, 1500) } else { wx.showToast({ title: msg, icon: 'none' }) } }).catch(() => {}) }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { this.setData({ 'formData.id': options.id }) }, })