You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

108 lines
2.0 KiB

// pages/createclass/createclass.js
const AV = require("../../lib/av-live-query-weapp-min")
const Presence = require("../../model/presence")
const Class = require("../../model/class")
Page({
/**
* 页面的初始数据
*/
data: {
new_classname: '',
new_class_teacher_username: '',
},
updateName: function ({ detail: { value } }) {
this.setData({ new_classname: value });
},
create_class: function (event) {
let { new_classname } = this.data;
new_classname = new_classname.trim();
if (new_classname == "") {
wx.showToast({
title: "课程名称不能为空",
icon: "none"
})
return;
}
class_ = new Class({
name: new_classname,
teacher: AV.User.current()
})
wx.showLoading({
title: '请稍候',
})
class_.save().then(() => {
wx.hideLoading();
wx.showToast({
title: '创建成功,可在首页课程列表以教师身份进入课堂',
icon: "none",
duration: 4000
});
this.setData({ new_classname: "" });
},
() => {
wx.hideLoading();
wx.showToast({
title: '操作失败',
icon: "none"
});
});
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.setData({ new_class_teacher_username: AV.User.current().get("username") });
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})