diff --git a/README.md b/README.md index f73023b..857454f 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,9 @@ # 简介 educoder微信小程序,帮助使用[educoder平台](https://www.educoder.net)的应用,方便在手机上使用。利用educoder网站的API搭建 +## 源码 +[https://github/jinke18/smart_class](https://github.com/jinke18/smart_class) + ## 小程序码 ![小程序码](./images/weapp_code.png) diff --git a/data/client.js b/data/client.js index 48bf5bd..4b50522 100644 --- a/data/client.js +++ b/data/client.js @@ -1,4 +1,10 @@ -import {Account, Course, Exercise, ExerciseQuestion, Ui} from "./eduapi" +/** + * https://github.com/jinke18/educoder_weapp + * @licence GPL-3.0 + * @author jinke18 + */ + +import {Account, Course, Exercise, ExerciseQuestion, School, Ui} from "./eduapi" import {Session} from "./requests"; import {Cookie} from "./cookie"; @@ -507,7 +513,25 @@ export class Client{ }) }); } - + search_schools({search = "", success, fail, complete} = {}){ + return new Promise((resolve, reject) => { + School.search({ + session: this.session, search: search, complete: complete, + success: res => { + if (typeof success == "function") { + success(res); + } + resolve(res); + }, + fail: error => { + if (typeof fail == "function") { + fail(error); + } + reject(error); + } + }); + }); + } get_home_page({success, fail, complete}={}){ return new Promise((resolve, reject) => { Ui.get_home_page({ diff --git a/data/cookie.js b/data/cookie.js index 6e0dfd1..d1c2fa2 100644 --- a/data/cookie.js +++ b/data/cookie.js @@ -1,3 +1,9 @@ +/** + * https://github.com/jinke18/educoder_weapp + * @licence GPL-3.0 + * @author jinke18 + */ + /** * Cookie类,用于网络中cookie的各类操作 */ diff --git a/data/eduapi.js b/data/eduapi.js index 14e908c..c773c27 100644 --- a/data/eduapi.js +++ b/data/eduapi.js @@ -1,3 +1,9 @@ +/** + * https://github.com/jinke18/educoder_weapp + * @licence GPL-3.0 + * @author jinke18 + */ + const api_base_url = "https://www.educoder.net/api"; /** * https://www.educoder.net的api接口,通过其实现用户与后端进行交互 @@ -154,7 +160,27 @@ export class Account{ } } - +export class School{ + static search({ session, search = "", success, fail, complete}){ + let data = {search: search}; + session.request({ + url: api_base_url + "/schools/school_list.json", + method: "GET", + data: data, + success: res => { + if ("status" in res.data && res.data.status < 0) { + fail(new Error(res.data.message)); + return; + } + if (typeof success == "function") { + success(res); + } + }, + fail: fail, + complete: complete + }) + } +} export class Course{ static create({session, data, success, fail, complete}){ return session.request({ diff --git a/data/error.js b/data/error.js index 282f42e..8a190a3 100644 --- a/data/error.js +++ b/data/error.js @@ -1,3 +1,4 @@ + /** * @todo: Error类, to be finished */ diff --git a/data/requests.js b/data/requests.js index a15575b..6c3e5a7 100644 --- a/data/requests.js +++ b/data/requests.js @@ -1,3 +1,8 @@ +/** + * https://github.com/jinke18/educoder_weapp + * @licence GPL-3.0 + * @author jinke18 + */ import {Cookie} from "./cookie"; /** diff --git a/images/loading.svg b/images/loading.svg new file mode 100644 index 0000000..e96fb5d --- /dev/null +++ b/images/loading.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/images/loading_big.gif b/images/loading_big.gif new file mode 100644 index 0000000..915c198 Binary files /dev/null and b/images/loading_big.gif differ diff --git a/images/loading_min.gif b/images/loading_min.gif new file mode 100644 index 0000000..3288d10 Binary files /dev/null and b/images/loading_min.gif differ diff --git a/pages/about/about.js b/pages/about/about.js index 952d727..348927c 100644 --- a/pages/about/about.js +++ b/pages/about/about.js @@ -6,8 +6,7 @@ Page({ /** * 页面的初始数据 */ - md: '# 功能介绍\n\n## 教室\n- 学员可以输入邀请码进入课堂\n\n- 进入教室界面会显示在位,头像为彩色,若退出课堂界面则会显示灰色头像\n\n- 教员在教室界面中可以直观地看到学员在位情况,可以选择学员让其起立回答问题,并且对学员可以进行加分、减分操作\n\n- 学员可以收到教员让其起立提问、回答的提示,还可以点击“我要提问、回答”\n\n- 教室内有讨论区,可以交流\n\n## 课程资源\n\n- 在课程界面进入“资源”可以查看本课堂的课程文件资源\n\n- 支持打开ppt doc xls pdf文件\n\n## 试卷作答\n\n- 学员在课程内可以看到老师发布的试卷,并且回答\n\n- 试卷截止后可以学生可以看到公布的答案' -, + md: '# 简介\neducoder微信小程序,帮助使用[educoder平台](https://www.educoder.net)的应用,方便在手机上使用。利用educoder网站的API搭建\n\n## 源码\n[https://github/jinke18/smart_class](https://github.com/jinke18/smart_class)\n\n## 小程序码\n![小程序码](../../images/weapp_code.png)\n\n\n# 功能介绍\n\n## 教室\n- 学员可以输入邀请码进入课堂\n\n- 进入教室界面会显示在位,头像为彩色,若退出课堂界面则会显示灰色头像\n\n- 教员在教室界面中可以直观地看到学员在位情况,可以选择学员让其起立回答问题,并且对学员可以进行加分、减分操作\n\n- 学员可以收到教员让其起立提问、回答的提示,还可以点击“我要提问、回答”\n\n- 教室内有讨论区,可以交流\n\n## 课程资源\n\n- 在课程界面进入“资源”可以查看本课堂的课程文件资源\n\n- 支持打开ppt doc xls pdf文件\n\n## 试卷作答\n\n- 学员在课程内可以看到老师发布的试卷,并且回答\n\n- 试卷截止后可以学生可以看到公布的答案', data: { article: {} diff --git a/pages/course_setting/course_setting.js b/pages/course_setting/course_setting.js index 0b7e499..92a62bf 100644 --- a/pages/course_setting/course_setting.js +++ b/pages/course_setting/course_setting.js @@ -18,11 +18,13 @@ Page({ course_group: true, //course_module_types end_date: "", - school: "" + school: app.client.current_user.school }, data: { current_date: getNowFormatDate(), - form_data: {} + form_data: {}, + bindSource: [], //绑定到页面的数据,根据用户输入动态变化 + hideScroll: true, }, reset: function () { this.setData({ form_data: this.initial_form_data }); @@ -52,6 +54,47 @@ Page({ }) } }, + itemtap: function (e) { + console.log(e); + this.setData({ + "form_data.school": e.currentTarget.id, + hideScroll: true + }) + }, + leaveSchool: function(){ + + }, + focusSchool: function({detail:{value}}){ + if(this.data.bindSource.length==0){ + app.client.search_schools({ search: value }) + .then(res => { + console.log(res); + const schools = res.data.school_names; + this.setData({ + bindSource: schools, + }); + }) + } + this.setData({hideScroll: false}); + }, + updateSchool: function({detail:{value}}){ + console.log("updateSchool"); + if(!value){ + this.setData({ + hideScroll: true, + }) + }else{ + app.client.search_schools({ search: value }) + .then(res => { + console.log(res); + const schools = res.data.school_names; + this.setData({ + hideScroll: false, + bindSource: schools, + }); + }) + } + }, updateCourseListName({ detail: { value } }) { this.setData({ "form_data.name": value }); }, diff --git a/pages/course_setting/course_setting.wxml b/pages/course_setting/course_setting.wxml index 88c4485..a194043 100644 --- a/pages/course_setting/course_setting.wxml +++ b/pages/course_setting/course_setting.wxml @@ -17,6 +17,27 @@ name="name"> + + 课堂所属单位 + + + + + + 总学时 公开设置 公开课堂 - - 课堂所属单位 - - - \ No newline at end of file diff --git a/pages/course_setting/course_setting.wxss b/pages/course_setting/course_setting.wxss index 6a63586..a2e72eb 100644 --- a/pages/course_setting/course_setting.wxss +++ b/pages/course_setting/course_setting.wxss @@ -7,4 +7,23 @@ input.form-item{ .form-wrap{ margin: 24rpx -12rpx; padding: 2rpx 10rpx; +} + +.selector{ + max-height:340rpx; + border-radius:6rpx; + margin-top:8rpx; + background: white; + box-shadow: 1px 2px 10px grey; +} + +.selector-item{ + padding: 8rpx 18rpx; +} + +.selector-item text{ + display: block; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; } \ No newline at end of file diff --git a/pages/courses/courses.js b/pages/courses/courses.js index 65a3425..ac68fed 100644 --- a/pages/courses/courses.js +++ b/pages/courses/courses.js @@ -8,6 +8,7 @@ Page({ loading: true, page: 1, show_join_course_modal:false, + loaded_all: false, }, show_join_course_modal: function(event){ this.setData({show_join_course_modal: true}); @@ -95,11 +96,20 @@ Page({ onReachBottom: function () { - this.fetch_courses({ page: this.data.page + 1 }) - .then(res => { - this.setData({ page: this.data.page + 1 }) - this.add_courses(res.data.courses); + if(!this.data.loaded_all){ + wx.pageScrollTo({ + selector: ".loading" }) + this.fetch_courses({ page: this.data.page + 1 }) + .then(res => { + this.setData({ page: this.data.page + 1}); + if(res.data.courses.length==0){ + this.setData({loaded_all: true}) + }else{ + this.add_courses(res.data.courses); + } + }) + } }, diff --git a/pages/courses/courses.wxml b/pages/courses/courses.wxml index 6b81c1b..9c80940 100644 --- a/pages/courses/courses.wxml +++ b/pages/courses/courses.wxml @@ -10,6 +10,9 @@ + + + diff --git a/pages/courses/courses.wxss b/pages/courses/courses.wxss index c4db5aa..5a5cc54 100644 --- a/pages/courses/courses.wxss +++ b/pages/courses/courses.wxss @@ -60,4 +60,9 @@ image.none-content{ } lable.identity{ margin-right: 16rpx; +} + +.loading{ + padding-top: 16rpx; + text-align: center; } \ No newline at end of file diff --git a/pages/findmore/findmore.wxml b/pages/findmore/findmore.wxml index 22563ad..3628605 100644 --- a/pages/findmore/findmore.wxml +++ b/pages/findmore/findmore.wxml @@ -11,8 +11,9 @@ 实训课程 TRAINING COURSE - + + @@ -32,6 +33,7 @@ + diff --git a/pages/findmore/findmore.wxss b/pages/findmore/findmore.wxss index 6c0199a..db61ecd 100644 --- a/pages/findmore/findmore.wxss +++ b/pages/findmore/findmore.wxss @@ -61,5 +61,8 @@ text.name{ text-overflow: ellipsis; white-space: nowrap; } - +.loading{ + text-align:center; + padding: 12px 0; +} /**动画*/ diff --git a/pages/image_crop/image_crop.js b/pages/image_crop/image_crop.js index 9016fe5..8609eb5 100644 --- a/pages/image_crop/image_crop.js +++ b/pages/image_crop/image_crop.js @@ -3,7 +3,7 @@ import WeCropper from '../../we-cropper/dist/we-cropper.min.js' const device = wx.getSystemInfoSync() const width = device.windowWidth -const height = device.windowHeight - 30 +const height = device.windowHeight - 40 const app = getApp(); Page({ @@ -45,14 +45,30 @@ Page({ if (avatar) { console.info("avatar"); console.log(avatar); + wx.showLoading({ + title: '上传中', + }); app.client.upload_avatar({ avatar_path: avatar, success: res=>{ console.log("upload avatar success"); console.log(res); + wx.navigateBack({ + delta: 1 + }); + wx.showToast({ + title: '更改成功', + }) }, fail: error=>{ console.error(error); + wx.showToast({ + title: '失败', + icon: "none" + }); + }, + complete:()=>{ + wx.hideLoading() } }); } else { @@ -101,6 +117,7 @@ Page({ console.log(`before canvas draw,i can do something`) console.log(`current canvas context:`, ctx) }) + .updateCanvas(); } } }) \ No newline at end of file diff --git a/pages/image_crop/image_crop.wxss b/pages/image_crop/image_crop.wxss index 568a8a1..0f88b7f 100644 --- a/pages/image_crop/image_crop.wxss +++ b/pages/image_crop/image_crop.wxss @@ -11,6 +11,7 @@ left: 0; position: fixed; bottom: 0; width: 100%; + height: 50px; align-items: center }