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.
120 lines
2.3 KiB
120 lines
2.3 KiB
// pages/course_setting/course_setting.js
|
|
import { getNowFormatDate } from "../../utils/dateutils";
|
|
|
|
const app = getApp();
|
|
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
initial_form_data: {
|
|
//course_module_types
|
|
shixun_homework: true,
|
|
common_homework: true,
|
|
group_homework: true,
|
|
exercise: true,
|
|
attachment: true,
|
|
course_group: true,
|
|
//course_module_types
|
|
end_date: "",
|
|
school: ""
|
|
},
|
|
data: {
|
|
current_date: getNowFormatDate(),
|
|
form_data: {}
|
|
},
|
|
reset: function () {
|
|
this.setData({ form_data: this.initial_form_data });
|
|
},
|
|
create_course: function ({ detail: { value } }) {
|
|
console.info(value);
|
|
if (this.intent == "create") {
|
|
app.client.create_course({
|
|
data: value,
|
|
success: res => {
|
|
console.info("create course")
|
|
console.info(res);
|
|
wx.navigateTo({
|
|
url:"/pages/course/course?course_id="+res.course_id
|
|
})
|
|
wx.showToast({
|
|
title: "创建成功",
|
|
duration: 5000
|
|
});
|
|
},
|
|
fail: error => {
|
|
wx.showToast({
|
|
title: error.toString(),
|
|
icon: "none"
|
|
})
|
|
}
|
|
})
|
|
}
|
|
},
|
|
updateCourseListName({ detail: { value } }) {
|
|
this.setData({ "form_data.name": value });
|
|
},
|
|
updateEndDate({ detail: { value } }) {
|
|
console.log(value);
|
|
this.setData({ "form_data.end_date": value });
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
this.intent = options.intent;
|
|
if (this.intent == "create") this.reset();
|
|
console.log(options);
|
|
console.log(this.intent);
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage: function () {
|
|
|
|
}
|
|
}) |