1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- var app = getApp()
- var api = require('../../utils/api.js');
- Page({
- data: {
- titles: [],
- course_name: '',
- teacher: '',
- teachers: [],
- is_new: true
- },
- onLoad: function (options) {
- let that = this;
- that.setData({
- course_name: options.course_name,
- teacher: options.teacher
- })
- wx.request({
- url: api.getRemarkTitlesUrl,
- data: {
- id: wx.getStorageSync('pt_student').id
- },
- method: 'GET',
- success: res => {
- // console.log(res.data)
- that.setData({
- is_new: res.data.is_new,
- titles: res.data.titles,
- teachers: res.data.teachers
- })
- }
- })
- },
- formSubmit: function (e) {
- let data = e.detail.value;
- for(var i in data) {
- if(data[i] === null) {
- wx.showModal({
- title: '评价失败',
- content: '评分不能为空',
- })
- return false;
- }
- data[i] = parseInt(data[i])
- if (!(data[i] >= 0 && data[i] <= 10)) {
- wx.showModal({
- title: '评价失败',
- content: '评分只能为0到10',
- })
- return false;
- }
- }
- 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'})
- }
- })
|