|
|
|
const app = getApp();
|
|
|
|
|
|
|
|
const getDataForRender = class_ => ({
|
|
|
|
name: class_.get('name'),
|
|
|
|
objectId: class_.get('objectId')
|
|
|
|
});
|
|
|
|
|
|
|
|
Page({
|
|
|
|
options:{},
|
|
|
|
data: {
|
|
|
|
categories: [{ name: "所有", value: "",checked:true }, { name: "我管理的", value: "manage" }, { name:"我学习的", value:"study"}],
|
|
|
|
statuses: [{ name: "所有", value: "",checked:true}, { name:"正在进行", value:"processing"},{name:"已结束",value:"end"}],
|
|
|
|
courses: [],
|
|
|
|
loading: true,
|
|
|
|
},
|
|
|
|
presences: [],
|
|
|
|
classes: [],
|
|
|
|
|
|
|
|
onCategoryChange: function({detail:{value}}){
|
|
|
|
this.options["category"] = value;
|
|
|
|
this.setData({loading: true});
|
|
|
|
this.pull_courses(this.options);
|
|
|
|
},
|
|
|
|
onStatusChange: function ({detail: {value} }){
|
|
|
|
this.options["status"] = value;
|
|
|
|
this.setData({loading: true});
|
|
|
|
this.pull_courses(this.options);
|
|
|
|
},
|
|
|
|
show_join_course_modal: function (event) {
|
|
|
|
this.setData({ show_join_course_modal: true });
|
|
|
|
},
|
|
|
|
|
|
|
|
enter_course: function(event){
|
|
|
|
console.log(event);
|
|
|
|
let {id, course_name} = event.currentTarget.dataset;
|
|
|
|
wx.navigateTo({
|
|
|
|
url: "../course/course?course_id="+id+"&course_name="+course_name,
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
pull_courses: function({category="",status=""}={}){
|
|
|
|
app.callApi({name:"users.courses",data:{
|
|
|
|
category: category,
|
|
|
|
status: status},
|
|
|
|
complete:()=>{console.log("pull_courses complete!!!!!!");this.setData({loading:false})}
|
|
|
|
})
|
|
|
|
.then(res=>{
|
|
|
|
console.log("pull_courses");
|
|
|
|
console.log(res);
|
|
|
|
this.setData({courses: res.courses||[]});
|
|
|
|
}).catch(console.error);
|
|
|
|
console.log(this.data);
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面加载
|
|
|
|
*/
|
|
|
|
onLoad: function (options) {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面显示
|
|
|
|
*/
|
|
|
|
onShow: function () {
|
|
|
|
this.pull_courses(this.options);
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
|
|
*/
|
|
|
|
onPullDownRefresh: function () {
|
|
|
|
this.pull_courses(this.options);
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 用户点击右上角分享
|
|
|
|
*/
|
|
|
|
onShareAppMessage: function () {
|
|
|
|
return app.shareApp();
|
|
|
|
}
|
|
|
|
})
|