diff --git a/app.json b/app.json index 6f2a219..acf2136 100644 --- a/app.json +++ b/app.json @@ -1,5 +1,6 @@ { "pages": [ + "pages/classes/classes", "pages/changeuser/changeuser", "pages/index/index", @@ -12,7 +13,8 @@ "pages/outside/outside", "pages/classroom/classroom", "pages/setting/setting", - "pages/user/user" + "pages/user/user", + "pages/addclass/addclass" ], "window": { "backgroundTextStyle": "light", diff --git a/app.wxss b/app.wxss index 774db91..6429400 100644 --- a/app.wxss +++ b/app.wxss @@ -8,19 +8,28 @@ page { } .form-wrap { border-top: 1px solid #eee; - margin: 8px 0; + margin: 12px 0; } .tappable:hover { opacity: .6; } - +.container { + padding: 4px 12px; +} .hint, -.error { +.error +.warning { display: block; margin: 8px 0; color: #888; font-size: 14px; } +.error{ + color:red; +} +.warning{ + color: orange; +} .lab { display: flex; diff --git a/components/icon/myicon.js b/components/icon/myicon.js new file mode 100644 index 0000000..df19878 --- /dev/null +++ b/components/icon/myicon.js @@ -0,0 +1,34 @@ +// components/icon/myicon.js +Component({ + /** + * 组件的属性列表 + */ + properties: { + addGlobalClass: true + }, + + + externalClasses: ['custom-class'], + + properties: { + info: null, + type: String, + size: String, + color: String + }, + /** + * 组件的初始数据 + */ + data: { + + }, + + /** + * 组件的方法列表 + */ + methods: { + onClick() { + this.triggerEvent('click'); + } + } +}) diff --git a/components/icon/myicon.json b/components/icon/myicon.json new file mode 100644 index 0000000..e8cfaaf --- /dev/null +++ b/components/icon/myicon.json @@ -0,0 +1,4 @@ +{ + "component": true, + "usingComponents": {} +} \ No newline at end of file diff --git a/components/icon/myicon.wxml b/components/icon/myicon.wxml new file mode 100644 index 0000000..53de1e6 --- /dev/null +++ b/components/icon/myicon.wxml @@ -0,0 +1,7 @@ + + + {{ info }} + diff --git a/components/icon/myicon.wxss b/components/icon/myicon.wxss new file mode 100644 index 0000000..9b67b59 --- /dev/null +++ b/components/icon/myicon.wxss @@ -0,0 +1,51 @@ +@font-face {font-family: "iconfont"; + src: url('iconfont.eot?t=1571740835844'); /* IE9 */ + src: url('iconfont.eot?t=1571740835844#iefix') format('embedded-opentype'), /* IE6-IE8 */ + url('data:application/x-font-woff2;charset=utf-8;base64,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') format('woff2'), + url('iconfont.woff?t=1571740835844') format('woff'), + url('iconfont.ttf?t=1571740835844') format('truetype'), /* chrome, firefox, opera, Safari, Android, iOS 4.2+ */ + url('iconfont.svg?t=1571740835844#iconfont') format('svg'); /* iOS 4.1- */ +} + +.iconfont { + font-family: "iconfont" !important; + font-size: 16px; + font-style: normal; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +.myicon-absent_student:before { + content: "\e635"; +} + +.myicon-present_student:before { + content: "\e60d"; +} +.myicon-answer:before { + content: "\e647"; +} +.myicon-question:before { + content: "\e670"; +} + +.myicon-internet_class:before { + content: "\e67f"; +} +.myicon__info { + color: #fff; + left: 100%; + top: -.5em; + font-size: 0.5em; + padding: 0 0.3em; + text-align: center; + min-width: 1.2em; + line-height: 1.2; + position: absolute; + border-radius: 0.6em; + box-sizing: border-box; + background-color: #f44; + -webkit-transform: translateX(-50%); + transform: translateX(-50%); + font-family: PingFang SC, Helvetica Neue, Arial, sans-serif; +} diff --git a/model/presence.js b/model/presence.js index 6e5ae65..ee253b7 100644 --- a/model/presence.js +++ b/model/presence.js @@ -37,10 +37,10 @@ class Presence extends AV.Object{ enter(){ console.log("presence.enter"); console.log(this); - this.set("present", true).save().catch(error=>console.error(error.message)); + this.set("present", true).set("isasking", 0).save().catch(error=>console.error(error.message)); } leave(){ - this.set("present", false).save() + this.set("present", false).set("isasking", 0).save(); } } diff --git a/pages/addclass/addclass.js b/pages/addclass/addclass.js new file mode 100644 index 0000000..3b3f0f5 --- /dev/null +++ b/pages/addclass/addclass.js @@ -0,0 +1,169 @@ +// pages/addclass/addclass.js +const AV = require("../../lib/av-live-query-weapp-min") +const Presence = require("../../model/presence") +const Class = require("../../model/class") +const { jsonify } = require('../../utils/leancloudutils'); + +Page({ + + /** + * 页面的初始数据 + */ + classes: [], + data: { + new_classname:'', + new_class_teacher_username: '', + classes: [] + }, + updateName: function ({detail: {value}}){ + this.setData({new_classname:value}); + }, + create_class: function(event){ + const {new_classname} = this.data; + class_ = new Class({ + name: new_classname, + teacher: AV.User.current() + }) + presence = new Presence({ + user: AV.User.current(), + class: class_ + }); + wx.showLoading({ + title: '请稍候', + }) + presence.save().then(()=>{ + wx.hideLoading(); + wx.showToast({ + title: '创建成功,可在首页课程列表以教师身份进入课堂', + icon:"none", + duration: 4000 + }); + this.setData({new_classname: ""}); + }, + ()=>{ + wx.hideLoading(); + wx.showToast({ + title: '操作失败', + icon: "none" + }); + }); + }, + add_class:function(event){ + class_id = event.currentTarget.dataset.id; + class_name = event.currentTarget.dataset.name; + pull_presences = this.pull_presences.bind(this); + wx.showModal({ + title: '确认', + content: '是否加入学习'+class_name, + success(res) { + if (res.confirm) { + class_ = AV.Object.createWithoutData("Class_", class_id); + presence = new Presence({ + user: AV.User.current(), + class: class_ + }); + wx.showLoading({ + title: '请稍候', + }) + presence.save().then(()=>{ + pull_presences(); + wx.hideLoading(); + wx.showToast({ + title: '加入成功', + icon: "success" + }) + }, + () => { + wx.hideLoading(); + wx.showToast({ + title: '加入失败', + icon: "none" + }) + }).catch(error=>console.error(error.message)); + } + } + }) + }, + + pull_classes: function(){ + query = new AV.Query("Class_"); + return query.find().then(classes=>{console.log(classes);this.classes=classes}); + }, + pull_presences: function(){ + query = new AV.Query("Presence"); + query.equalTo("user", AV.User.current()); + query.include("class"); + query.find().then(this.set_presences.bind(this)); + }, + set_presences: function(presences){ + console.log("set_presences"); + console.log(presences); + present_class_ids = presences.map(presence=>presence.get("class").id); + classes =this.classes.map(class_=>{ + if(present_class_ids.indexOf(class_.id)>-1){ + class_.set("present", true); + }else{ + class_.set("present", false); + } + return class_; + }); + console.log(classes); + this.setData(jsonify({classes})); + }, + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + this.pull_classes().then(this.pull_presences); + this.setData({new_class_teacher_username: AV.User.current().get("username")}); + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { + this.pull_classes().then(this.pull_presences); + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + } +}) \ No newline at end of file diff --git a/pages/addclass/addclass.json b/pages/addclass/addclass.json new file mode 100644 index 0000000..c9282c8 --- /dev/null +++ b/pages/addclass/addclass.json @@ -0,0 +1,7 @@ +{ + "navigationBarTitleText": "未加入的课程", + "usingComponents": { + "myicon": "/components/icon/myicon" + }, + "enablePullDownRefresh": true +} \ No newline at end of file diff --git a/pages/addclass/addclass.wxml b/pages/addclass/addclass.wxml new file mode 100644 index 0000000..6e34cba --- /dev/null +++ b/pages/addclass/addclass.wxml @@ -0,0 +1,23 @@ + + + + + + + + + 创建我的课程 + + 课程名称: + + + + 教师用户名: + + + + + \ No newline at end of file diff --git a/pages/addclass/addclass.wxss b/pages/addclass/addclass.wxss new file mode 100644 index 0000000..53820a4 --- /dev/null +++ b/pages/addclass/addclass.wxss @@ -0,0 +1,67 @@ +/* pages/addclass/addclass.wxss */ +.class-icon{ + margin-left: 2px; + margin-right: 12px; +} + +.class-list{ + display: flex; + flex-direction: column; + margin: 0 -12px +} +.class-item{ + align-items: center; + background: white; + padding: 30rpx 12px; + border-bottom: 1rpx solid #EEE; + position: relative; +} +.class-item:after { + content: '加入学习>'; + display: block; + position: absolute; + right: 3rpx; + top: 50%; + height: 40rpx; + line-height: 40rpx; + margin-top: -20rpx; + margin-right: 30rpx; + color: #999; +} +.class-item text{ + vertical-align: middle; +} + +.input-wrap { + background: #fff; + border-bottom: 1px solid #eee; + margin: 0 -12px; + padding: 0 12px; + height: 46px; + line-height: 46px; +} + +.info-input { + font-size: 18px; + line-height: 100%; + height: 100%; +} + +.disabled{ + color: #999; +} + +.label { + color: #999; + width: 7em; +} + +.create-class{ + position: fixed; + bottom: 0; +} + +button{ + margin: 4px 26px; + font-size: 14px; +} \ No newline at end of file diff --git a/pages/changeuser/changeuser.js b/pages/changeuser/changeuser.js index 0325ad7..4afff9c 100644 --- a/pages/changeuser/changeuser.js +++ b/pages/changeuser/changeuser.js @@ -39,16 +39,19 @@ Page({ }).catch(error=>console.error(error.message)); }, + pull_users: function(){ + this.setData(jsonify({ current_user: AV.User.current() })); + query = new AV.Query("User"); + return query.find().then((users) => { + this.users = users; + this.setData(jsonify({ users })); + }); + }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { - this.setData(jsonify({current_user: AV.User.current()})); - query = new AV.Query("User"); - return query.find().then((users)=>{ - this.users = users; - this.setData(jsonify({users})); - }); + this.pull_users() }, /** @@ -83,7 +86,7 @@ Page({ * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { - + this.pull_users(); }, /** diff --git a/pages/changeuser/changeuser.wxss b/pages/changeuser/changeuser.wxss index 0512d21..b10a823 100644 --- a/pages/changeuser/changeuser.wxss +++ b/pages/changeuser/changeuser.wxss @@ -2,6 +2,7 @@ .user-list{ display: flex; flex-direction: column; + margin: 0 -12px } .user-item{ background: white; diff --git a/pages/classes/classes.js b/pages/classes/classes.js index 1bc8b10..300d570 100644 --- a/pages/classes/classes.js +++ b/pages/classes/classes.js @@ -18,11 +18,41 @@ Page({ class.name 课程名称 */ data: { - classes: [ - ] + //classes: [{objectId: "232323", "name":"测试"}] + classes: [] }, - + presences: [], classes: [], + del_class: function(event){ + class_id = event.currentTarget.dataset.class_id; + class_name = event.currentTarget.dataset.class_name; + presence = this.presences.filter(presence=>presence.get("class").id==class_id)[0]; + pull_classes = this.pull_classes.bind(this); + wx.showModal({ + title: '退出学习', + content: '退出学习会清零你该门课程的分数', + success(res) { + if (res.confirm) { + wx.showLoading({ + title: '', + }) + presence.destroy().then(() => { + pull_classes(); + wx.hideLoading(); + wx.showToast({ + title: '退出成功', + icon: "success" + }) + }, + () => { + wx.hideLoading(); + wx.showToast({ + title: '操作失败', + icon: "none" + }) + }).catch(error => console.error(error.message)); + } } }); + }, enter_class: function(event){ console.log(event); var class_id = event.currentTarget.dataset.class_id; @@ -46,15 +76,24 @@ Page({ }, + pull_classes: function(){ + console.log("classes.pull_classes"); + var query = new AV.Query("Presence"); + query.equalTo("user", AV.User.current()); + query.include("class"); + query.find().then((presences) => { + this.presences = presences; + this.classes = presences.map((presence) => {return presence.get("class")}); + console.log(this.classes); + this.setData(jsonify({ classes: this.classes })); + }) + }, /** * 生命周期函数--监听页面显示 */ onShow: function () { - var query = new AV.Query("Class_"); - query.find().then((classes) => { - this.classes = classes - this.setData(jsonify({ classes })); - }) + console.log("classes.onShow()"); + this.pull_classes(); }, /** @@ -75,11 +114,7 @@ Page({ * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { - var query = new AV.Query("Class_"); - query.find().then((classes) => { - this.classes = classes - this.setData(jsonify({classes})); - }) + this.pull_classes(); }, /** diff --git a/pages/classes/classes.json b/pages/classes/classes.json index 462a05a..d1de74d 100644 --- a/pages/classes/classes.json +++ b/pages/classes/classes.json @@ -1,5 +1,7 @@ { - "navigationBarTitleText": "课程列表", - "usingComponents": {}, + "navigationBarTitleText": "我的课程", + "usingComponents": { + "myicon": "/components/icon/myicon" + }, "enablePullDownRefresh": true } \ No newline at end of file diff --git a/pages/classes/classes.wxml b/pages/classes/classes.wxml index b9ef92a..51ff800 100644 --- a/pages/classes/classes.wxml +++ b/pages/classes/classes.wxml @@ -5,15 +5,19 @@ classes: 课程列表 type: Array class.objectId 唯一键 class.name 课程名称 --> - + + 你还没有加入任何课堂 - + + + {{class.name}} - - 设置 - + + + 设置 + 加入课堂 diff --git a/pages/classes/classes.wxss b/pages/classes/classes.wxss index 8c0de37..5aab06c 100644 --- a/pages/classes/classes.wxss +++ b/pages/classes/classes.wxss @@ -2,9 +2,11 @@ .class-list { display: flex; flex-direction: column; + margin: 0 -12px } .classroom { + align-items: center; background: white; padding: 30rpx 12px; border-bottom: 1rpx solid #EEE; @@ -25,11 +27,12 @@ } .classroom text { - vertical-align: middle; + vertical-align: middle; } -.classroom icon { - margin-right: 25rpx; +.classroom-icon{ + margin-left: 2px; + margin-right: 10px; } .footer { @@ -43,4 +46,17 @@ background: #fff; font-size: 16px; text-align: center; -} \ No newline at end of file +} + +.tappable{ + color: #1aad19; + padding: 0 12px; + position: absolute; +} + +.addclass{ + right:0; +} +.setting{ + left:0; +} diff --git a/pages/classroom/classroom.js b/pages/classroom/classroom.js index 5e62951..e0cb17d 100644 --- a/pages/classroom/classroom.js +++ b/pages/classroom/classroom.js @@ -14,55 +14,68 @@ Page({ student.present 是否出席 student.isasking :0:没有提问,1:提问,2:请回答 */ - presence: null, - origin_presences: [], students: [], - class: null, - presences : [], - class_id: null, - asking_presence: null, + presences: [], my_presence: null, + is_askiny: null, data: { //以下数据的同步由该代码文件实现,数据的呈现由classroom.wxml实现 students: [], // 该课程所有的学生, 元素类型见上文中的student current_user: null, //目前登陆的用户,类型为对象,属性有objectId,username, name teacher: null, + select_stu_id: '', //该课程教员,类型为对象 //请在进入界面时判断用户是否为教员以给与权限或更改界面 //属性如下:objectId, username, name class_name: "", //课程名称 class_id: "", //该课程的主键(编号) }, - sco1: function () { - //打1分的函数 - }, - sco2: function () { - //打2分的函数 - }, - sco3: function () { - //打3分的函数 - }, - ask: function (event) { - //学生提问的函数 - console.log(event); - //set_asking() - }, - rep: function (event) { - console.log(event); - //点这个学生要回答他问题的函数 + + select_stu: function(event){ + id = event.currentTarget.dataset.id; + if(id!='none'){ + console.log(id); + }else{console.log("none");id=""} + this.setData({select_stu_id: id}); }, - set_asking: function(userid, status){ - this.asking_present = this.presents.filter(present=>present.get("user").id==userid)[0]; + + set_isasking: function(event){ + userid = event.currentTarget.dataset.id; + status = event.currentTarget.dataset.status; + console.log("set_isasking"); + console.log(status); + console.log(typeof status); + this.asking_present = this.presences.filter(presence=>presence.get("user").id==userid)[0]; this.asking_present.isasking = status; - this.asking_present.save(); + wx.showLoading({ + title: '', + }) + this.asking_present.save().then(()=>{ + wx.hideLoading(); + }, ()=>{ + wx.hideLoading(); + wx.showToast({ + title: '操作失败', + icon: "none" + }) + }); }, - add_mark: function(mark){ - if(this.asking_present==null){ + add_mark: function(event){ + id = event.currentTarget.dataset.id; + mark = event.currentTarget.dataset.mark; + console.log("add_mark"); + console.log(mark); + console.log(typeof mark); + presence = this.presences.filter(presence => presence.get("user").id == id)[0]; + if(presence==null){ console.warn("没有选择学生"); - }else{ - user = this.asking_present.get("user"); - studentClassMap = this.studentClassMaps.filter(studentClassMap=>studentClassMap.get("user")) } + presence.increment("mark", mark).save().then(()=>{ + wx.showToast({ + title: '操作成功', + icon:"none" + }) + }).catch(error=>console.error(error.message)); }, pull_presence: function(){ @@ -79,8 +92,9 @@ Page({ }, set_presence: function(presences){ console.log("set_presence"); - console.log(presences); + //console.log(presences); this.presences = presences; + console.log(this.presences); students = this.presences.map((presence)=>{ student = presence.get("user"); if(student.get("username")==null){ @@ -96,6 +110,7 @@ Page({ student.set("mark", presence.get("mark")); if(student.id==AV.User.current().id){ this.my_presence = presence; + this.setData({current_user:student.toJSON()}); } return student; }); @@ -106,10 +121,12 @@ Page({ }, fetch_class: function(class_id){ - this.class = AV.Object.createWithoutData("Class_", class_id); - //this.class.include("teacher"); - return this.class.fetch().then((class_) => { + query = new AV.Query("Class_"); + query.equalTo("objectId", class_id); + query.include("teacher"); + return query.find().then((classes) => { //console.log(this.class); + this.class = classes[0]; teacher = this.class.get("teacher"); console.log("fetch_class"); console.log(teacher); @@ -135,15 +152,15 @@ Page({ wx.showLoading({ title: '加载中' }) - this.setData({current_user: AV.User.current()}); + this.setData({current_user: AV.User.current().toJSON()}); this.class_id = options.class_id; this.fetch_class.bind(this)(this.class_id) .then(()=>{ - this.pull_presence.bind(this)(); + console.log("pull_presence"); + this.pull_presence.bind(this)().then((presences) => { this.my_presence.enter(); this.presences = presences;}); wx.hideLoading(); - console.log(this.data); - }) - .then(this.my_presence.enter); + console.log("hideLoading"); + }); console.log("onLoad"); }, diff --git a/pages/classroom/classroom.json b/pages/classroom/classroom.json index 7360326..3f6c119 100644 --- a/pages/classroom/classroom.json +++ b/pages/classroom/classroom.json @@ -1,4 +1,6 @@ { - "usingComponents": {}, + "usingComponents": { + "myicon": "/components/icon/myicon" + }, "enablePullDownRefresh": true } \ No newline at end of file diff --git a/pages/classroom/classroom.wxml b/pages/classroom/classroom.wxml index 7d592b0..a6d4e57 100644 --- a/pages/classroom/classroom.wxml +++ b/pages/classroom/classroom.wxml @@ -1,47 +1,33 @@ - - - - - - - {{student.username}} - - - {{student.username}} - - - {{student.username}} - - - - - - - - - - - - - - - - - - - - - - - - + + 课程名称:{{class_name}}\t教员姓名:{{teacher.name}} - - 姓名:{{student.name}} 用户名:{{student.username}} - 是否出席:{{student.present}} 提问状态:{{student.isasking}} - + + + + + + + + + diff --git a/pages/classroom/classroom.wxss b/pages/classroom/classroom.wxss index 9314b42..ccd02b4 100644 --- a/pages/classroom/classroom.wxss +++ b/pages/classroom/classroom.wxss @@ -47,4 +47,52 @@ } .sco { margin: 20rpx 50rpx; -} \ No newline at end of file +} + + +.student-list{ + display: -webkit-flex; + display: flex; + align-items: center; + justify-content: space-between; + flex-wrap: wrap; + width: 100%; +} +.student{ + flex: 0 0 auto; + width: 23%; + text-align: center; + color: #797979; + padding: 40rpx 0; + font-size: 30rpx; +} + +.present{ + color: green; +} +.selectable:hover{ + border-style: inset; + border-color: green; + opacity: .6; +} +.tappable{ + color: #1aad19; + padding: 0 12px; + position: absolute; +} +button{ + margin: 10px 36px; +} + +.footer { + background: white; + position: fixed; + bottom: 0; + height: 44px; + width: 100%; + line-height: 44px; + color: #666; + border-top: 1px solid #eee; + font-size: 16px; + text-align: center; +} diff --git a/pages/user/user.js b/pages/user/user.js index c15d380..d0a1e16 100644 --- a/pages/user/user.js +++ b/pages/user/user.js @@ -6,7 +6,6 @@ Page({ username: '', password: '', error: null, - authData: '', }, onLoad: function() { const user = User.current(); @@ -14,7 +13,6 @@ Page({ this.setData({ name: user.get("name"), username: user.get('username'), - authData: JSON.stringify(user.get('authData'), undefined, 2), }); } }, diff --git a/pages/user/user.wxml b/pages/user/user.wxml index e2d6617..18db8b9 100644 --- a/pages/user/user.wxml +++ b/pages/user/user.wxml @@ -15,6 +15,4 @@ {{error}} - 当前用户 authData: -