我的课程增加分类选择按钮

smart_class
educoder_weapp 5 years ago
parent 8ed4f73a4b
commit 6eb07316b6

@ -0,0 +1,23 @@
// components/educoder/course/course.js
Component({
/**
* 组件的属性列表
*/
properties: {
},
/**
* 组件的初始数据
*/
data: {
},
/**
* 组件的方法列表
*/
methods: {
}
})

@ -0,0 +1,4 @@
{
"component": true,
"usingComponents": {}
}

@ -0,0 +1 @@
/* components/educoder/course/course.wxss */

@ -294,10 +294,14 @@ export class Client{
});
}
get_user_courses({page=1, per_page=16, success, fail, complete}={}){
get_user_courses({category="",status="",sort_by="",sort_direction="",page=1, per_page=16, success, fail, complete}={}){
return new Promise((resolve, reject) => {
Account.get_user_courses({
session: this.session,
category: category,
status: status,
sort_by: sort_by,
sort_direction: sort_direction,
page: page,
per_page: per_page,
login: this.current_user.login,

@ -38,7 +38,7 @@ Page({
console.info("create course")
console.info(res);
wx.navigateTo({
url:"/pages/course/course?course_id="+res.course_id
url:"/pages/course/course?course_id="+res.data.course_id
})
wx.showToast({
title: "创建成功",

@ -26,7 +26,7 @@
bindblur="leaveSchool"
bindfocus="focusSchool"
hold-keyboard="1"
cursor-spacing="200"
cursor-spacing="240"
value="{{form_data.school}}">
</input>
</view>

@ -10,7 +10,7 @@ input.form-item{
}
.selector{
max-height:340rpx;
max-height:320rpx;
border-radius:6rpx;
margin-top:8rpx;
background: white;

@ -18,12 +18,26 @@ Page({
class.objectId 课程唯一主键
class.name 课程名称
*/
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 });
},
@ -73,8 +87,12 @@ Page({
})
},
pull_courses: function(event){
app.client.get_user_courses({complete:()=>{console.log("pull_courses complete!!!!!!");this.setData({loading:false})}})
pull_courses: function({category="",status=""}={}){
app.client.get_user_courses({
category: category,
status: status,
complete:()=>{console.log("pull_courses complete!!!!!!");this.setData({loading:false})}
})
.then(res=>{
console.log("pull_courses");
console.log(res);
@ -101,7 +119,7 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow: function () {
this.pull_courses();
this.pull_courses(this.options);
},
/**
@ -122,7 +140,7 @@ Page({
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
this.pull_courses();
this.pull_courses(this.options);
},
/**

@ -1,8 +1,17 @@
<view class="container">
<radio-group class="flex-wrap categories top" name="category" bindchange="onCategoryChange">
<radio class="category" wx:for="{{categories}}" wx:for-item="category" value="{{category.value}}" checked="{{category.checked}}">{{category.name}}</radio>
</radio-group>
<radio-group class="flex-wrap statuses top" name="status" bindchange="onStatusChange">
<radio class="status" wx:for="{{statuses}}" wx:for-item="status" value="{{status.value}}" checked="{{status.checked}}">{{status.name}}</radio>
</radio-group>
<view class="loading" wx:if="{{loading}}">
<image src="../../images/loading_min.gif" style="width:20px;height:20px;"></image>
</view>
<view class="course-list">
<view wx:if="{{courses.length==0 && !loading}}" class="none-content">
<image class="none-content" src="../../images/none.png" mode="aspectFit"></image>
<text class="none-content hint">你的课程空空如也</text>
<text class="none-content hint">空空如也!</text>
</view>
<block wx:for="{{courses}}" wx:for-item="course" wx:key="id">
<view class="classroom flex-wrap" data-id="{{course.id}}" data-course_name="{{course.name}}" bindtap="enter_course">
@ -13,6 +22,8 @@
</block>
</view>
</view>
<myicon class="add-class" type="add" color="#00C7B7" size="56" bindtap="show_join_course_modal"></myicon>
<modal id="modal" hidden="{{!show_join_course_modal}}" title="加入课堂" confirm-text="提交" cancel-text="取消" bindcancel="cancel_join_course_modal" bindconfirm="join_course">

@ -1,3 +1,10 @@
.top{
margin: 8rpx 0;
transform: scale(0.8);
}
.top radio{
width: 32%;
}
.course-list {
display: flex;
@ -71,4 +78,9 @@ image.none-content{
}
lable.identity{
margin-right: 16rpx;
}
.loading{
text-align:center;
padding: 14rpx 0;
}
Loading…
Cancel
Save