feedback.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. // pages/waterabnormal/feedback/feedback.js
  2. const app = getApp();
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. title: '预警反馈',
  9. loading: false,
  10. color: '#000',
  11. background: '#ffffff',
  12. show: true,
  13. animated: false,
  14. formData: {
  15. id: "",
  16. feedbackStatus: 1,
  17. feedbackContent: ""
  18. }
  19. },
  20. toBack() {
  21. wx.navigateBack({
  22. delta: 1
  23. })
  24. },
  25. fieldChange(e) {
  26. const {
  27. value
  28. } = e.detail;
  29. this.setData({
  30. 'formData.feedbackStatus': value
  31. })
  32. },
  33. contentChange(e) {
  34. const {
  35. value
  36. } = e.detail;
  37. this.setData({
  38. 'formData.feedbackContent': value
  39. })
  40. },
  41. submit() {
  42. const {
  43. id,
  44. feedbackStatus,
  45. feedbackContent
  46. } = this.data.formData;
  47. if (feedbackStatus == 2 && !feedbackContent) {
  48. wx.showToast({
  49. title: '请输入反馈信息内容',
  50. icon: 'none'
  51. })
  52. return;
  53. }
  54. app.$http.postForm('/warningMessage/feedback', {
  55. id,
  56. feedbackStatus,
  57. feedbackContent
  58. }).then(({
  59. status,
  60. msg,
  61. data = {}
  62. }) => {
  63. if (status == 0) {
  64. wx.showToast({
  65. title: '反馈成功',
  66. icon: 'none'
  67. })
  68. setTimeout(() => {
  69. this.toBack();
  70. }, 1500)
  71. } else {
  72. wx.showToast({
  73. title: msg,
  74. icon: 'none'
  75. })
  76. }
  77. }).catch(() => {})
  78. },
  79. /**
  80. * 生命周期函数--监听页面加载
  81. */
  82. onLoad: function (options) {
  83. this.setData({
  84. 'formData.id': options.id
  85. })
  86. },
  87. })