parent
4d03f53a91
commit
0ae21cc29d
@ -0,0 +1,25 @@
|
||||
module.exports = (subscription, initialStats, onChange) => {
|
||||
let stats = [...initialStats]
|
||||
const remove = value => {
|
||||
stats = stats.filter(target => target.id !== value.id)
|
||||
return onChange(stats)
|
||||
}
|
||||
const upsert = value => {
|
||||
let existed = false;
|
||||
stats = stats.map(target => (target.id === value.id ? ((existed = true), value) : target))
|
||||
if (!existed) stats = [value, ...stats]
|
||||
return onChange(stats)
|
||||
}
|
||||
subscription.on('create', upsert)
|
||||
subscription.on('update', upsert)
|
||||
subscription.on('enter', upsert)
|
||||
subscription.on('leave', remove)
|
||||
subscription.on('delete', remove)
|
||||
return () => {
|
||||
subscription.off('create', upsert)
|
||||
subscription.off('update', upsert)
|
||||
subscription.off('enter', upsert)
|
||||
subscription.off('leave', remove)
|
||||
subscription.off('delete', remove)
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
const AV = require('../lib/av-live-query-weapp-min');
|
||||
const Presence = require("./presence")
|
||||
|
||||
class Class extends AV.Object{
|
||||
get name(){
|
||||
return this.get("name");
|
||||
}
|
||||
set name(value){
|
||||
this.set("name", value);
|
||||
}
|
||||
get students(){
|
||||
|
||||
}
|
||||
add_student(user){
|
||||
|
||||
}
|
||||
del_student(user){
|
||||
let students = this.get("students");
|
||||
if(user.id in students){
|
||||
this.remove(user.id);
|
||||
}
|
||||
}
|
||||
enter() {
|
||||
this.leave();
|
||||
console.log("class.enter");
|
||||
console.log(AV.User.current());
|
||||
this._presence = new Presence({
|
||||
user: AV.User.current(),
|
||||
class: this
|
||||
});
|
||||
this._presence.save();
|
||||
}
|
||||
leave() {
|
||||
if (this._presence != null) {
|
||||
this._presence.destroy();
|
||||
}
|
||||
}
|
||||
present_students() {
|
||||
var query = new AV.Query("Presence");
|
||||
//query.equalTo("class", this._class.id);
|
||||
let students = query.find();
|
||||
console.log(students);
|
||||
return students;
|
||||
}
|
||||
}
|
||||
|
||||
AV.Object.register(Class, "Class_");
|
||||
module.exports = Class;
|
@ -0,0 +1,43 @@
|
||||
const AV = require('../lib/av-live-query-weapp-min');
|
||||
|
||||
//数据储存模板--分数
|
||||
class Grade extends AV.Object {
|
||||
get mark() {
|
||||
return this.get('done');
|
||||
}
|
||||
set mark(value) {
|
||||
this.set('mark', value);
|
||||
}
|
||||
get student(){
|
||||
return this.get("student");
|
||||
}
|
||||
set student(value){
|
||||
this.set("student". value);
|
||||
}
|
||||
|
||||
get class() {
|
||||
return this.get('class');
|
||||
}
|
||||
|
||||
set class(value){
|
||||
this.set("class", value);
|
||||
}
|
||||
get content(){
|
||||
return this.get("content");
|
||||
}
|
||||
set content(value) {
|
||||
this.set('content', value);
|
||||
}
|
||||
get date(){
|
||||
return this.get("date");
|
||||
}
|
||||
set date(value){
|
||||
this.set("date", value)
|
||||
}
|
||||
add_mark(value){
|
||||
this.increment(value);
|
||||
}
|
||||
}
|
||||
|
||||
AV.Object.register(Grade, 'Grade');
|
||||
module.exports = Grade;
|
@ -0,0 +1,25 @@
|
||||
const AV = require('../lib/av-live-query-weapp-min');
|
||||
|
||||
class Presence extends AV.Object{
|
||||
set user(value){
|
||||
this.set("user", value);
|
||||
}
|
||||
get user(){
|
||||
return this.get("user");
|
||||
}
|
||||
set class(value){
|
||||
this.set("class", value);
|
||||
}
|
||||
get class(){
|
||||
return this.get("class");
|
||||
}
|
||||
set isasking(value){
|
||||
this.set("isasking", value);
|
||||
}
|
||||
get isasking(){
|
||||
return this.get("isasking");
|
||||
}
|
||||
}
|
||||
|
||||
AV.Object.register(Presence, "Presence");
|
||||
module.exports = Presence;
|
@ -0,0 +1,17 @@
|
||||
const AV = require("../..//lib/av-live-query-weapp-min")
|
||||
|
||||
|
||||
class StudentClassMap extends AV.Object{
|
||||
get class(){
|
||||
return this.get("class");
|
||||
}
|
||||
set class(value){
|
||||
this.set("class", value);
|
||||
}
|
||||
get user(){
|
||||
return this.get("user");
|
||||
}
|
||||
set user(value){
|
||||
this.set("user", value);
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
const AV = require("../lib/av-live-query-weapp-min")
|
||||
|
||||
function login() {
|
||||
return AV.Promise.resolve(AV.User.current()).then(user =>
|
||||
user ? (user.isAuthenticated().then(authed => authed ? user : null)) : null
|
||||
).then(user => user ? user : AV.User.loginWithWeapp({
|
||||
preferUnionId: true,
|
||||
})).catch(error => console.error(error.message));
|
||||
}
|
||||
|
||||
module.exports = login;
|
@ -0,0 +1,4 @@
|
||||
{
|
||||
"usingComponents": {},
|
||||
"enablePullDownRefresh": true
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
<!--
|
||||
所有的页面数据见同目录classes.js中Page.data定义部分
|
||||
classes: 课程列表 type: Array
|
||||
元素class: 课程信息 class.objectId 唯一
|
||||
class.objectId 唯一键
|
||||
class.name 课程名称
|
||||
-->
|
||||
<view class="class-list">
|
||||
<block wx:for="{{classes}}" wx:for-item="class" wx:key="objectId">
|
||||
<view class="flex-wrap classroom" data-class_id="{{class.objectId}}" data-class_name="{{class.name}}" bindtap="enter_class">
|
||||
<text>{{class.name}}</text>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
@ -0,0 +1,28 @@
|
||||
.header {
|
||||
height: 54px;
|
||||
align-items: center;
|
||||
background-color: #FFF;
|
||||
}
|
||||
|
||||
.class-list {
|
||||
padding: 4px 6px 48px;
|
||||
}
|
||||
|
||||
.classroom {
|
||||
font-size: 18px;
|
||||
height: 30px;
|
||||
padding: 10px 12px;
|
||||
overflow: hidden;
|
||||
align-items: center;
|
||||
background-color: #fff;
|
||||
margin: 1px 0;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.classroom text {
|
||||
white-space: nowrap;
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 50px;
|
||||
line-height: 17px;
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
{
|
||||
"usingComponents": {},
|
||||
"enablePullDownRefresh": true
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
<!--pages/classroom/classroom.wxml-->
|
||||
<view class="index">
|
||||
<view class="grid-celll">
|
||||
<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}}">
|
||||
</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>
|
||||
<text>{{student.username}}</text>
|
||||
</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>
|
@ -1,3 +1,3 @@
|
||||
{
|
||||
"navigationBarTitleText": "腾讯云实验室"
|
||||
"navigationBarTitleText": "积分教室"
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
const isPlainObject = target =>
|
||||
target &&
|
||||
target.toString() == '[object Object]' &&
|
||||
Object.getPrototypeOf(target) == Object.prototype;
|
||||
const _jsonify = target => {
|
||||
if (target && typeof target.toJSON === 'function') return target.toJSON();
|
||||
if (Array.isArray(target)) return target.map(_jsonify);
|
||||
return target;
|
||||
};
|
||||
|
||||
exports.jsonify = target =>
|
||||
isPlainObject(target)
|
||||
? Object.keys(target).reduce(
|
||||
(result, key) => ({
|
||||
...result,
|
||||
[key]: _jsonify(target[key])
|
||||
}),
|
||||
{}
|
||||
)
|
||||
: _jsonify(target);
|
@ -1,11 +1,15 @@
|
||||
登录微信公众平台,前往 设置 > 开发设置 > 服务器配置 > 「修改」 链接,增加下述域名为白名单中的域名
|
||||
# 后台数据交互部分日志
|
||||
|
||||
## 已完成-登录微信公众平台,前往 设置 > 开发设置 > 服务器配置 > 「修改」 链接,增加下述域名为白名单中的域名
|
||||
request合法域名
|
||||
fqcxn98z.api.lncldglobal.com
|
||||
fqcxn98z.engine.lncldglobal.com
|
||||
fqcxn98z.rtm.lncldglobal.com
|
||||
fqcxn98z.push.lncldglobal.com
|
||||
app-router.leancloud.cn
|
||||
socket合法域名
|
||||
us-w1-backend2.leancloud.cn
|
||||
us-w1-backend3.leancloud.cn
|
||||
us-w1-backend4.leancloud.cn
|
||||
us-w1-backend5.leancloud.cn
|
||||
us-w1-backend6.leancloud.cn
|
||||
us-w1-backend6.leancloud.cn
|
||||
|
Loading…
Reference in new issue