add function

smart_class
educoder_weapp 5 years ago
parent bafeb81743
commit 6b69e12239

@ -1 +0,0 @@
export const marster_key = ""; //to be completed

@ -1,4 +1,5 @@
const AV = require('../lib/av-live-query-weapp-min'); const AV = require('../lib/av-live-query-weapp-min');
const Presence = require("./presence")
class Class extends AV.Object{ class Class extends AV.Object{
get name(){ get name(){

@ -6,4 +6,4 @@ function login() {
})).catch(error => console.error(error.message)); })).catch(error => console.error(error.message));
} }
export{login}; module.exports=login;

@ -1,66 +0,0 @@
// pages/class/class.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})

@ -1,3 +0,0 @@
{
"usingComponents": {}
}

@ -1,16 +1,27 @@
// pages/classroom/classroom.js // pages/classroom/classroom.js
const AV = require("../../lib/av-live-query-weapp-min.js") const AV = require("../../lib/av-live-query-weapp-min")
const { jsonify } = require('../../utils/leancloudutils');
Page({ Page({
/** /**
* 页面的初始数据 * 页面的初始数据
*/ */
presence: null,
students: [],
present_students: [],
class: null, class: null,
data: { data: {
present_students: [],
students: [],
unpresent_students: [],
class_name: "", class_name: "",
class_id: "", class_id: "",
}, },
fetch_present: function(){
var query = new AV.Query("Presence");
query.include("user");
return query.find();
},
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
@ -18,36 +29,46 @@ Page({
onLoad: function (options) { onLoad: function (options) {
this.class = AV.Object.createWithoutData("Class_", options.class_id); this.class = AV.Object.createWithoutData("Class_", options.class_id);
this.class.fetch().then((class_)=>{ this.class.fetch().then((class_)=>{
console.log(this.class);
this.setData(this.class.get("name")); this.setData(this.class.get("name"));
}) })
console.log("onLoad");
}, },
/** /**
* 生命周期函数--监听页面初次渲染完成 * 生命周期函数--监听页面初次渲染完成
*/ */
onReady: function () { onReady: function () {
this.fetch_present().then((presents)=>{
console.log({students: presents.map((present)=>{return present.get("user")})});
this.setData(jsonify({students: presents.map((present)=>{return present.get("user")})}));
})
console.log("onReady");
}, },
/** /**
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow: function () { onShow: function () {
console.log("onShow");
this.class.enter();
}, },
/** /**
* 生命周期函数--监听页面隐藏 * 生命周期函数--监听页面隐藏
*/ */
onHide: function () { onHide: function () {
this.class.leave();
console.log("onHide");
}, },
/** /**
* 生命周期函数--监听页面卸载 * 生命周期函数--监听页面卸载
*/ */
onUnload: function () { onUnload: function () {
this.class.leave();
console.log("onUnload");
}, },
/** /**
@ -68,6 +89,6 @@ Page({
* 用户点击右上角分享 * 用户点击右上角分享
*/ */
onShareAppMessage: function () { onShareAppMessage: function () {
console.log("onShareAppMessage");
} }
}) })

@ -2,41 +2,8 @@
<text>pages/classroom/classroom.wxml</text> <text>pages/classroom/classroom.wxml</text>
<view class="students"> <view class="students">
<view class="grid-view"> <view class="grid-view">
<view class="grid-cell"> <view class="grid-cell" wx:for="{{students}}" wx:for-item="student" wx:key="objectId">
<icon class="iconfont icon-shouye"></icon> <text>{{student.username}}</text>
<view>Home</view>
</view>
<view class="grid-cell">
<icon class="iconfont icon-xinfeng"></icon>
<view>Email</view>
</view>
<view class="grid-cell">
<icon class="iconfont icon-duihuaxinxi"></icon>
<view>Chat</view>
</view>
<view class="grid-cell">
<icon class="iconfont icon-dibiao"></icon>
<view>location</view>
</view>
<view class="grid-cell">
<icon type="search" size='30'></icon>
<view>search</view>
</view>
<view class="grid-cell">
<icon class="iconfont icon-dianhua"></icon>
<view>phone</view>
</view>
<view class="grid-cell">
<icon class="iconfont icon-shezhi"></icon>
<view>setting</view>
</view>
<view class="grid-cell">
<icon type="info" size='30' color='#797979'></icon>
<view>about</view>
</view>
<view class="grid-cell">
<icon class="iconfont icon-gengduotianchong"></icon>
<view>more</view>
</view> </view>
</view> </view>
</view> </view>

@ -1,66 +0,0 @@
// pages/outside.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})

@ -1,3 +0,0 @@
{
"usingComponents": {}
}

@ -4,8 +4,8 @@
"ignore": [] "ignore": []
}, },
"setting": { "setting": {
"urlCheck": false, "urlCheck": true,
"es6": true, "es6": false,
"postcss": true, "postcss": true,
"minified": true, "minified": true,
"newFeature": true, "newFeature": true,
@ -22,8 +22,8 @@
}, },
"compileType": "miniprogram", "compileType": "miniprogram",
"libVersion": "2.8.3", "libVersion": "2.8.3",
"appid": "wx2a901996834ef5fb", "appid": "wxfacd79888fb03788",
"projectname": "miniprogram-3", "projectname": "smart-class",
"debugOptions": { "debugOptions": {
"hidedInDevtools": [] "hidedInDevtools": []
}, },

Loading…
Cancel
Save