Suggest.js 2.1 KB
// pages/Suggest/Suggest.js
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    list: []
  },
  setcontent(e) {
    let list = this.data.list;
    list.content = e.detail.value;
    this.setData({
      list: list
    })
  },
  setreprt(e) {
    let list = this.data.list;
    list.report = e.detail.value;
    this.setData({
      list: list
    })
  },

  //查看预设建议列表
  getAdviseLook() {
    let that = this;
    let url = 'counselor/AdviseLook';
    app.post(url, {
      userId: app.globalData.UserId
    }).then((res) => {
      if (res.data.code == 200) {
        that.setData({
          list: res.data.data
        })
      }
    }).catch((err) => {
      console.log(err)
    })
  },

  save_btn() {
    let that = this;
    let url = 'counselor/AdviseSave';
    let params = {
      userId: app.globalData.UserId,
      report: that.data.list.report,
      advise: that.data.list.content
    }
    app.post(url, params).then((res) => {
      console.log(res)
      if (res.data.code == 200) {
        wx.showToast({
          title: '保存成功',
          icon: 'none',
          duration: 2000,
        })
        setTimeout(function() {
          wx.navigateBack({
            delta: 1,
          })
        }, 1000)
      }
    }).catch((err) => {
      console.log(err)
    })

  },

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

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

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {
    let that = this;
    that.getAdviseLook();
  },

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

  },

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

  },

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

  },

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

  },

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

  }
})