// pages/change_teacher/change_teacher.js
const app=getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
  
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData(options);
  },

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

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

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

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

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

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

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  },
  /**
   * 底部导航跳转
   */
  redirectCtl: app.redirectCtl,

  /**
   * 路由跳转
   */
  navigateCtl: app.navigateCtl,
  // 理由
  textinput:function(e){
    const { value } = e.detail;
    this.setData({ reason: value})
  },
  // 换老师
  changeTeacher: function () {
    const postData = { fn: this.changeTeacher, param: { ...arguments }}
    const { lessonServiceId, reason } = this.data;
    // console.log(lessonServiceId, reason)
    app.post('/api/parents/parents/applyChangeTeacher', { lessonServiceId, reason }, 0, postData).then(res => {
        wx.showToast({
          title: '提交成功',
          icon: 'success',
          duration: 1000
        })
        setTimeout((function callback() {
          wx.navigateBack({});
        }).bind(this), 2000);
    })
  }
})