You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

102 lines
2.0 KiB

5 years ago
const { Class } = require("../../model/class");
const login = require("../../model/user");
const AV = require("../../lib/av-live-query-weapp-min.js");
const { jsonify } = require('../../utils/leancloudutils');
// pages/class/class.js
const getDataForRender = class_ => ({
name: class_.get('name'),
objectId: class_.get('objectId')
});
Page({
/**
页面的初始数据data用于与.wxlm文件绑定
classes: 课程列表 type: Array
元素class: 课程信息 class.objectId 唯一
class.objectId 课程唯一主键
class.name 课程名称
*/
data: {
classes: [
]
},
classes: [],
enter_class: function(event){
console.log(event);
var class_id = event.currentTarget.dataset.class_id;
var class_name = event.currentTarget.dataset.class_name;
wx.navigateTo({
url: "../classroom/classroom?class_id="+class_id+"&"+"class_name="+class_name,
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
login().then((user)=>{
console.log(user);
console.log(AV.User.current());
});
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
var query = new AV.Query("Class_");
query.find().then((classes) => {
this.classes = classes
this.setData(jsonify({ classes }));
})
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
var query = new AV.Query("Class_");
query.find().then((classes) => {
this.classes = classes
this.setData(jsonify({classes}));
})
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})