// pages/noticeDetail/detail.js
const app = getApp();

Page({

  /**
   * 页面的初始数据
   */
  data: {
    content: '',
  },
  
  handleFeedback: function (e) {
    if (e.detail.value.content.length == 0 || e.detail.value.content == '') {
      wx.showToast({
        title: '反馈意见不能为空!',
        icon: 'none',
        duration: 1500
      })
      setTimeout(function () {
        wx.hideToast()
      }, 2000)
    } else {
      app.ajax({
        url: app.globalData.serverUrl + '/feedback/add',
        type: 'POST',
        data: {
          content: e.detail.value.content
        }
      });
      var that = this;
      app.ajaxReadyCallback = res => {
        wx.showToast({
          title: '提交成功!',
          icon: 'success',
          duration: 1500
        });
        that.setData({
          content: ''
        });
        setTimeout(function () {
          wx.navigateBack({ delta: 1 });
        }, 1500);
      }
    }
  },
})
