index.js 1.74 KB
// pages/home/teacher/index.js
const request = require('../../../api/teacher.js')
const utils = require('../../../utils/util.js')
Page({

  /**
   * 页面的初始数据
   */
  data: {
    signIcon:"/src/img/signin.png",
    userIcon:"/src/img/defaut_teacher_icon.png",
    records:[],

  },

  operateTap: function (event) {
    console.log(event._relatedInfo.anchorTargetText)
    wx.navigateTo({
      url: '/pages/add_record/index',
    })
  },

  signTap: function (e) {
    wx.navigateTo({
      url: '/pages/home/sign/index',
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    // 设置日期
    let date = new Date()
    let dateStr = utils.formatDate(date)
    this.setData({
      dateStr: dateStr
    })
    


    request.querySignSummary("4028048267a65d0f0167a69ae1910058", "4028048267a5969b0167a5b22f3807f8").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
      })

    })

     

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})