|
@@ -36,12 +36,24 @@ Page({
|
|
|
//试课
|
|
|
toClass: function () {
|
|
|
const that = this;
|
|
|
+ const form = that.data.form;
|
|
|
+ const user = that.data.user;
|
|
|
wx.showModal({
|
|
|
title: '提示',
|
|
|
content: '您是否确定试课?',
|
|
|
async success(res) {
|
|
|
if (res.confirm) {
|
|
|
- that.setData({ is_try: '1' })
|
|
|
+ let arr;
|
|
|
+ let params = {
|
|
|
+ school_id: form.school_id,
|
|
|
+ lesson_id: form._id,
|
|
|
+ student_id: user.info.id,
|
|
|
+ }
|
|
|
+ const lesson = await app.$get(`/tryLessonApply`, { school_id: form.school_id, lesson_id: that.data.id, student_id: user.info.id })
|
|
|
+ if (lesson.errcode == '0' && lesson.total > 0) arr = await app.$post(`/tryLessonApply/${lesson.data[0]._id}`, params);
|
|
|
+ else arr = await app.$post(`/tryLessonApply`, params);
|
|
|
+ if (arr.errcode == '0') { wx.showToast({ title: `试课申请完成`, icon: 'success', duration: 2000 }); that.watchLogin(); }
|
|
|
+ else wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 })
|
|
|
} else if (res.cancel) { }
|
|
|
}
|
|
|
});
|
|
@@ -65,7 +77,7 @@ Page({
|
|
|
is_try: that.data.is_try,
|
|
|
try_status: '0'
|
|
|
}
|
|
|
- const student = await app.$get(`/lessonStudent`, { lesson_id: that.data.id, student_id: user.info.id })
|
|
|
+ const student = await app.$get(`/lessonStudent`, { school_id: form.school_id, lesson_id: that.data.id, student_id: user.info.id })
|
|
|
if (student.errcode == '0' && student.total > 0) arr = await app.$post(`/lessonStudent/${student.data[0]._id}`, params);
|
|
|
else arr = await app.$post(`/lessonStudent`, params);
|
|
|
if (arr.errcode == '0') { wx.showToast({ title: `报名申请完成`, icon: 'success', duration: 2000 }); that.watchLogin(); }
|