
var app = getApp()
var api = require('../../utils/api.js');

Page({
  data: {
    titles: [],
    course_name: '',
    teacher: ''
  },
  onLoad: function (options) {
    let that = this;
    that.setData({
      course_name: options.course_name,
      teacher: options.teacher
    })
    wx.request({
      url: api.getRemarkTitlesUrl,
      method: 'GET',
      success: res => {
        if (res.data.status == 'success') {
          that.setData({
            titles: res.data.titles
          })
        }
      }
    })
  },
  formSubmit: function (e) {
    let data = e.detail.value;
    data.student_id = wx.getStorageSync('pt_student').id
    wx.request({
      url: api.remarkTeacherUrl,
      method: 'GET',
      data: data,
      success: res => {
        if (res.data.status == 'success') {
          wx.showModal({
            title: '评价成功',
            content: '感谢评价',
            success: function (res) {
              wx.switchTab({
                url: '/pages/userinfo/userinfo',
              })
            }
          })
          
        } else {
          wx.showToast({
            title: res.data.info,
            icon: 'none',
            duration: 800
          })
          
        }
      }
    })
  },
  onSubmit: function() {
    wx.navigateTo({url: '/pages/rate-review/rate-review'})
  }
})
