|
@@ -1,9 +1,10 @@
|
|
|
const app = getApp()
|
|
|
Page({
|
|
|
data: {
|
|
|
- frameStyle: { useTop: true, name: '公开课信息', leftArrow: true, useBar: false },
|
|
|
+ frameStyle: { useTop: true, name: '报名', leftArrow: true, useBar: false },
|
|
|
id: '',
|
|
|
form: {},
|
|
|
+ user: {},
|
|
|
//状态
|
|
|
statusList: []
|
|
|
},
|
|
@@ -15,20 +16,20 @@ Page({
|
|
|
onSubmit: async function (e) {
|
|
|
const that = this;
|
|
|
const form = that.data.form;
|
|
|
- const params = e.detail.value;
|
|
|
- params.icon = form.icon;
|
|
|
- params.school_id = that.data.school_id;
|
|
|
- if (!this.WxValidate.checkForm(params)) {
|
|
|
- const error = this.WxValidate.errorList[0];
|
|
|
- wx.showToast({ title: `${error.msg}`, icon: 'error', duration: 2000 })
|
|
|
- return false
|
|
|
- } else {
|
|
|
- let arr;
|
|
|
- if (form._id) arr = await app.$post(`/student/${form._id}`, params);
|
|
|
- else arr = await app.$post(`/student`, params)
|
|
|
- if (arr.errcode == '0') { wx.showToast({ title: `维护信息完成`, icon: 'success', duration: 2000 }); that.back(); }
|
|
|
- else wx.showToast({ title: `${errmsg}`, icon: 'error', duration: 2000 })
|
|
|
- }
|
|
|
+ const user = that.data.user;
|
|
|
+ wx.showModal({
|
|
|
+ title: '提示',
|
|
|
+ content: '您是否确定报名?',
|
|
|
+ async success(res) {
|
|
|
+ if (res.confirm) {
|
|
|
+ var student = { id: user.info.id, name: user.info.name }
|
|
|
+ form.student.push(student);
|
|
|
+ let arr = await app.$post(`/student/${form._id}`, form);
|
|
|
+ if (arr.errcode == '0') { wx.showToast({ title: `报名完成`, icon: 'success', duration: 2000 }); that.back(); }
|
|
|
+ else wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 })
|
|
|
+ } else if (res.cancel) { }
|
|
|
+ }
|
|
|
+ });
|
|
|
},
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|
|
@@ -55,6 +56,7 @@ Page({
|
|
|
wx.getStorage({
|
|
|
key: 'user',
|
|
|
success: async res => {
|
|
|
+ that.setData({ user: res.data })
|
|
|
if (that.data.id) {
|
|
|
const arr = await app.$get(`/lessonPublic/${that.data.id}`);
|
|
|
if (arr.errcode == '0') {
|