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.
82 lines
2.0 KiB
82 lines
2.0 KiB
const app = getApp();
|
|
|
|
const getDataForRender = class_ => ({
|
|
name: class_.get('name'),
|
|
objectId: class_.get('objectId')
|
|
});
|
|
const categories= [{ text: "我学习的", value: "study" }, { text: "我管理的", value: "manage" }];
|
|
Page({
|
|
options:{},
|
|
data: {
|
|
imgDir:global.config.imgDir,
|
|
categories,
|
|
statuses: [{ text:"正在进行", value:"processing"},{text:"已结束",value:"end"}],
|
|
courses: [],
|
|
status:0,
|
|
user:{},
|
|
current_cate:-1
|
|
},
|
|
presences: [],
|
|
classes: [],
|
|
|
|
onCategoryChange: function({detail:{current,value}}){
|
|
this.options["category"] = value.value;
|
|
if(current>=0)
|
|
this.pull_courses(this.options);
|
|
},
|
|
onStatusChange: function ({detail: {value} }){
|
|
this.options["status"] = value.value;
|
|
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/pages/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:()=>{this.setData({loading:false})}
|
|
})
|
|
.then(res=>{
|
|
console.log(res);
|
|
this.setData({courses: res.courses||[]});
|
|
}).catch(e=>{
|
|
this.setData({courses:[]});
|
|
console.error
|
|
});
|
|
console.log(this.data);
|
|
},
|
|
onLoad: function (options) {
|
|
app.syncUser().then(r=>{
|
|
if(r.user.is_teacher)
|
|
var current_cate = 1;
|
|
else
|
|
var current_cate = 0;
|
|
this.setData({current_cate});
|
|
})
|
|
},
|
|
|
|
onShow: function () {
|
|
app.syncUser().then(r =>{
|
|
this.setData({ user: r.user })
|
|
});
|
|
if(this.data.current_cate>=0)
|
|
this.pull_courses(this.options);
|
|
},
|
|
|
|
onPullDownRefresh: function () {
|
|
this.pull_courses(this.options);
|
|
},
|
|
onShareAppMessage: function () {
|
|
return app.shareApp();
|
|
}
|
|
}) |