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.
110 lines
2.4 KiB
110 lines
2.4 KiB
5 years ago
|
const app = getApp();
|
||
5 years ago
|
|
||
|
const getDataForRender = class_ => ({
|
||
|
name: class_.get('name'),
|
||
|
objectId: class_.get('objectId')
|
||
|
});
|
||
|
|
||
|
Page({
|
||
5 years ago
|
options:{},
|
||
5 years ago
|
data: {
|
||
5 years ago
|
categories: [{ name: "所有", value: "",checked:true }, { name: "我管理的", value: "manage" }, { name:"我学习的", value:"study"}],
|
||
|
statuses: [{ name: "所有", value: "",checked:true}, { name:"正在进行", value:"processing"},{name:"已结束",value:"end"}],
|
||
5 years ago
|
courses: [],
|
||
5 years ago
|
loading: true,
|
||
5 years ago
|
},
|
||
5 years ago
|
presences: [],
|
||
5 years ago
|
classes: [],
|
||
5 years ago
|
|
||
|
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);
|
||
|
},
|
||
5 years ago
|
show_join_course_modal: function (event) {
|
||
|
this.setData({ show_join_course_modal: true });
|
||
|
},
|
||
|
|
||
|
enter_course: function(event){
|
||
5 years ago
|
console.log(event);
|
||
5 years ago
|
let {id, course_name} = event.currentTarget.dataset;
|
||
5 years ago
|
wx.navigateTo({
|
||
5 years ago
|
url: "../course/course?course_id="+id+"&course_name="+course_name,
|
||
5 years ago
|
})
|
||
|
},
|
||
|
|
||
5 years ago
|
pull_courses: function({category="",status=""}={}){
|
||
|
app.client.get_user_courses({
|
||
|
category: category,
|
||
|
status: status,
|
||
|
complete:()=>{console.log("pull_courses complete!!!!!!");this.setData({loading:false})}
|
||
|
})
|
||
5 years ago
|
.then(res=>{
|
||
|
console.log("pull_courses");
|
||
|
console.log(res);
|
||
5 years ago
|
this.setData({courses: res.data.courses||[]});
|
||
5 years ago
|
}).catch(console.error);
|
||
|
console.log(this.data);
|
||
|
},
|
||
5 years ago
|
/**
|
||
|
* 生命周期函数--监听页面加载
|
||
|
*/
|
||
|
onLoad: function (options) {
|
||
5 years ago
|
|
||
5 years ago
|
},
|
||
|
|
||
|
/**
|
||
|
* 生命周期函数--监听页面初次渲染完成
|
||
|
*/
|
||
|
onReady: function () {
|
||
|
|
||
|
},
|
||
|
|
||
5 years ago
|
|
||
5 years ago
|
/**
|
||
|
* 生命周期函数--监听页面显示
|
||
|
*/
|
||
|
onShow: function () {
|
||
5 years ago
|
this.pull_courses(this.options);
|
||
5 years ago
|
},
|
||
|
|
||
|
/**
|
||
|
* 生命周期函数--监听页面隐藏
|
||
|
*/
|
||
|
onHide: function () {
|
||
|
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 生命周期函数--监听页面卸载
|
||
|
*/
|
||
|
onUnload: function () {
|
||
|
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 页面相关事件处理函数--监听用户下拉动作
|
||
|
*/
|
||
|
onPullDownRefresh: function () {
|
||
5 years ago
|
this.pull_courses(this.options);
|
||
5 years ago
|
},
|
||
|
|
||
|
/**
|
||
|
* 页面上拉触底事件的处理函数
|
||
|
*/
|
||
|
onReachBottom: function () {
|
||
|
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 用户点击右上角分享
|
||
|
*/
|
||
|
onShareAppMessage: function () {
|
||
|
|
||
|
}
|
||
|
})
|