// pages/home/reviewer/index.js const request = require('../../../api/teacher.js') Page({ /** * 页面的初始数据 */ data: { selectIndex: 0, classList: [{ "id": "4028048267a5969b0167a5b22f3807f8", "code": "001", "name": "一班" }, { "id": "00002", "code": "002", "name": "二班" }, { "id": "00003", "code": "003", "name": "三班" }, { "id": "00004", "code": "004", "name": "四班" }, { "id": "00005", "code": "005", "name": "五班" } ], teacherId: "4028048267a65d0f0167a69ae1910058", classId: "", records: [] }, tapClass: function(e) { console.log(e) this.setData({ selectIndex: e.target.dataset.index, classId: e.currentTarget.id }), this.querySignSummary() }, tapStudent: function(e) { wx.navigateTo({ url: '/pages/review_student/index?signSummaryId=' + e.currentTarget.id }) }, querySignSummary: function() { request.querySignSummary(this.data.teacherId, this.data.classId).then(res => { console.log(res) for (var i = 0; i < res.length; i++) { var item = res[i] item.signDate = item.signDate.substr(0, 10) } this.setData({ records: res }) }).catch(err => { wx.showToast({ title: err.message, icon: 'none', duration: 2000 }) }) }, /** * 生命周期函数--监听页面加载 */ onLoad: function(options) { if (this.data.classList.length > 0){ this.data.classId = this.data.classList[0].id } this.querySignSummary() }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function() { }, /** * 生命周期函数--监听页面显示 */ onShow: function() { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function() { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function() { }, /** * 用户点击右上角分享 */ onShareAppMessage: function() { } })