parent
160b27dc15
commit
01771b1c50
@ -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');
|
||||
}
|
||||
}
|
||||
})
|
@ -0,0 +1,4 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
<!--components/icon/myicon.wxml-->
|
||||
<view
|
||||
class="custom-class iconfont myicon-{{ type }}"
|
||||
style="{{ color ? 'color: ' + color : '' }}; {{ size ? 'font-size: ' + size + 'px' : '' }}"
|
||||
bind:tap="onClick">
|
||||
<view wx:if="{{ info !== null }}" class="myicon__info">{{ info }}</view>
|
||||
</view>
|
@ -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,d09GMgABAAAAAAcoAAsAAAAADOAAAAbaAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHEIGVgCDSAqMQIooATYCJAMYCw4ABCAFhG0HahvwChFVpJWT/RhwN6bvicrMSrUYPYtc3yJlmXlxR7hlswnhaIxwxqm1TdVPJW3DURMJrUPrEaQqgtSUFxF4+P9Dve/9kaRjbox3Uo9XCxLAEmzQghahFq5ZCVWFWaFKshZ9n3Q+NwHaA/z5Y6mXTYf5rmouF/Wu0xZVO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GgEAAA=') 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;
|
||||
}
|
@ -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 () {
|
||||
|
||||
}
|
||||
})
|
@ -0,0 +1,7 @@
|
||||
{
|
||||
"navigationBarTitleText": "未加入的课程",
|
||||
"usingComponents": {
|
||||
"myicon": "/components/icon/myicon"
|
||||
},
|
||||
"enablePullDownRefresh": true
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
<!--pages/addclass/addclass.wxml-->
|
||||
<view class="container">
|
||||
<view class="class-list form-wrap">
|
||||
<block wx:for="{{classes}}" wx:for-item="class" wx:key="objectId">
|
||||
<view hidden="{{class.present}}" bindtap="add_class" class="class-item flex-wrap" data-id="{{class.objectId}}" data-name="{{class.name}}">
|
||||
<myicon class="class-icon" type="internet_class" size="26"></myicon>
|
||||
<text>{{class.name}}</text>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
<view class="create-class">
|
||||
<text>创建我的课程</text>
|
||||
<view class="flex-wrap input-wrap">
|
||||
<text class="label">课程名称:</text>
|
||||
<input value="{{new_classname}}" bindinput="updateName" id="name" class="info-input"/>
|
||||
</view>
|
||||
<view class="flex-wrap input-wrap">
|
||||
<text class="label">教师用户名:</text>
|
||||
<input value="{{new_class_teacher_username}}" id="teacher_name" class="info-input disabled" disabled="true"/>
|
||||
</view>
|
||||
<button bindtap="create_class">创建新课程</button>
|
||||
</view>
|
||||
</view>
|
@ -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;
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
{
|
||||
"navigationBarTitleText": "课程列表",
|
||||
"usingComponents": {},
|
||||
"navigationBarTitleText": "我的课程",
|
||||
"usingComponents": {
|
||||
"myicon": "/components/icon/myicon"
|
||||
},
|
||||
"enablePullDownRefresh": true
|
||||
}
|
@ -1,4 +1,6 @@
|
||||
{
|
||||
"usingComponents": {},
|
||||
"usingComponents": {
|
||||
"myicon": "/components/icon/myicon"
|
||||
},
|
||||
"enablePullDownRefresh": true
|
||||
}
|
@ -1,47 +1,33 @@
|
||||
<!--pages/classroom/classroom.wxml-->
|
||||
<view class="index">
|
||||
<view class="grid-cell">
|
||||
<view class="grid-view">
|
||||
<view class="grid-cell" wx:for="{{students}}" wx:for-item="student" wx:key="objectId" bindtap="rep">
|
||||
<view wx:if="{{student.isasking==0}}">
|
||||
<text>{{student.username}}</text>
|
||||
</view>
|
||||
<view wx:elif="{{student.isasking==1}}">
|
||||
<text class="reed">{{student.username}}</text>
|
||||
</view>
|
||||
<view wx:elif="{{student.isasking==2}}">
|
||||
<text class="gre">{{student.username}}</text>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- -->
|
||||
<view wx:if="{{current_user.objectId!=teacher.objectId}}">
|
||||
<view class="sco">
|
||||
<button bindtap="ask">提问</button>
|
||||
</view>
|
||||
</view>
|
||||
<view wx:else>
|
||||
<button data-id='{{students.username}}' bindtap="sco1">打1分</button>
|
||||
<button data-id='{{students.username}}' bindtap="sco2">打2分</button>
|
||||
<button data-id='{{students.username}}' bindtap="sco3">打3分</button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<view class="containner">
|
||||
<view bindtap="select_stu" data-id="none">
|
||||
<text class="hint">课程名称:{{class_name}}\t教员姓名:{{teacher.name}}</text>
|
||||
<view class="student-list">
|
||||
<block wx:for="{{students}}" wx:for-item="student" wx:key="objectId">
|
||||
<view class="student">
|
||||
<text>姓名:{{student.name}} 用户名:{{student.username}}
|
||||
是否出席:{{student.present}} 提问状态:{{student.isasking}}
|
||||
</text>
|
||||
<view class="{{teacher.objectId==current_user.objectId?'student selectable':'student'}}" hidden="{{teacher.objectId==student.objectId}}" catchtap="select_stu" data-id="{{student.objectId}}">
|
||||
<myicon wx:if="{{!student.present}}" class="student-icon" type="absent_student" size="36"></myicon>
|
||||
<myicon wx:elif="{{student.isasking==1}}" class="student-icon" type="question" size="36" color="red"></myicon>
|
||||
<myicon wx:elif="{{student.isasking==0}}" class="student-icon" type="present_student" color="#00ff00" size="36"></myicon>
|
||||
<myicon wx:elif="{{student.isasking==2}}" class="student-icon" type="answer" color="#0000ff" size="36"></myicon>
|
||||
<text class="{{student.present?'present':'absent'}}">{{student.name+'\n'}}</text>
|
||||
<text>{{student.mark}}分</text>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
<view class="operation-list">
|
||||
<view class="teacher-operation" hidden="{{teacher.objectId!=current_user.objectId || select_stu_id==''}}">
|
||||
<button type="primary" catchtap="add_mark" data-id="{{select_stu_id}}" data-mark="{{-1}}">减一分</button>
|
||||
<button type="primary" catchtap="add_mark" data-id="{{select_stu_id}}" data-mark="{{1}}">加一分</button>
|
||||
<button type="primary" catchtap="add_mark" data-id="{{select_stu_id}}" data-mark="{{2}}">加两分</button>
|
||||
<button type="primary" catchtap="set_isasking" data-id="{{select_stu_id}}" data-status="{{2}}">请起立</button>
|
||||
</view>
|
||||
<view class="student-operation" hidden="{{teacher.objectId==current_user.objectId}}">
|
||||
<button hidden="{{current_user.isasking!=0}}" type="primary" catchtap="set_isasking" data-id="{{current_user.objectId}}" data-status="{{1}}">我要提问/回答</button>
|
||||
<button hidden="{{current_user.isasking!=1}}" type="primary" catchtap="set_isasking" data-id="{{current_user.objectId}}" data-status="{{0}}">取消提问</button>
|
||||
<text hidden="{{current_user.isasking!=2}}" class="warning">请起立提问/回答</text>
|
||||
<button hidden="{{current_user.isasking!=2}}" type="primary" catchtap="set_isasking" data-id="{{current_user.objectId}}" data-status="{{0}}">完成回答</button>
|
||||
</view>
|
||||
</view>
|
||||
<view class="{{teacher.objectId!=current_user.objectId?'footer':''}}">
|
||||
<!--text hidden="{{teacher.objectId==current_user.objectId}}">测试</text-->
|
||||
<text hidden="{{teacher.objectId==current_user.objectId}}">我的得分:{{current_user.mark}}分</text>
|
||||
</view>
|
||||
</view>
|
||||
|
Loading…
Reference in new issue