const app = require('../../utils/util.js');
Page({
  data: {
    active: 0,
    form:{
      type:'',
      neirong:'',
      tel:''
    },
    arr:[{
      time:'2020-09-09',
      status:'已回复',
      type:'XX问题回复啦啦啦啦啦啦啦啦啦啦啦',
      title:'我遇到了一个什么问题回复啦啦啦啦啦啦啦啦啦啦啦',
      neirong:'我是正文我是正文我是正文我是正文我是正文我是正文',
      reply:'回复啦啦啦啦啦啦啦啦啦啦啦回复啦啦啦啦啦啦啦啦啦啦啦',
      replyTime:'2020-09-09'
    },
    {
      time:'2020-09-09',
      status:'待回复',
      type:'XX问题回复啦啦啦啦啦啦啦啦啦啦啦',
      title:'我遇到了一个什么问题回复啦啦啦啦啦啦啦啦啦啦啦',
      neirong:'我是正文我是正文我是正文我是正文我是正文我是正文',
      reply:'',
      replyTime:''
    }],
    activeNames: ['1'],
    questionArr: [
    {
      value: '其它',
      checked: true
    }
  ],
  },
  collapseonChange(event) {
    this.setData({
      activeNames: event.detail,
    });
  },
  onChange(event) {
    // wx.showToast({
    //   title: `切换到标签 ${event.detail.name}`,
    //   icon: 'none',
    // });
  },
  tipsChange: function (e) {
    console.log(e.detail.value)
    const items = this.data.questionArr;
    const values = e.detail.value;
    for (let i = 0, lenI = items.length; i < lenI; ++i) {
      items[i].checked = false
      for (let j = 0, lenJ = values.length; j < lenJ; ++j) {
        if (items[i].value === values[j]) {
          items[i].checked = true
          break
        }
      }
    }
    this.setData({
      questionArr: this.data.questionArr
    })
    let type = 'form.type'
    this.setData({
      [type]: e.detail.value
    })
  },
  neirongChange(e){
    let neirong = 'form.neirong'
    this.setData({
      [neirong]: e.detail.value
    })

  },
  telChange(e){
    let tel = 'form.tel'
    this.setData({
      [tel]: e.detail.value
    })
  },
  formSubmit(e){
    if(!this.data.form.neirong){
      wx.showModal({
        content: "您还没有填写投诉内容哦",
        showCancel: false
      })
    }else{
      console.log(e.detail.value)
    }
    
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})