index.js 3.47 KB
Newer Older
张杰's avatar
张杰 committed
1
// pages/home/reviewer/index.js
2
const request = require('../../../api/teacher.js')
张杰's avatar
张杰 committed
3
const app = getApp()
张杰's avatar
张杰 committed
4 5
const utils = require('../../../utils/util.js')

张杰's avatar
张杰 committed
6 7 8 9 10 11
Page({

  /**
   * 页面的初始数据
   */
  data: {
12
    selectIndex: 0,
张杰's avatar
张杰 committed
13 14
    teacherId: "",
    classList: [],
15
    classId: "",
张杰's avatar
张杰 committed
16
    records: [],
张杰's avatar
张杰 committed
17
    userIcon: ""
张杰's avatar
张杰 committed
18
    
19
  },
张杰's avatar
张杰 committed
20

21 22 23 24 25 26
  tapClass: function(e) {
    console.log(e)
    this.setData({
        selectIndex: e.target.dataset.index,
        classId: e.currentTarget.id
      }),
张杰's avatar
张杰 committed
27
    this.querySignSummary()
张杰's avatar
张杰 committed
28 29
  },

张杰's avatar
张杰 committed
30

张杰's avatar
张杰 committed
31
  tapStudent: function(e) {
张杰's avatar
张杰 committed
32 33 34
    let student = this.data.records[e.currentTarget.dataset.index]


张杰's avatar
张杰 committed
35
    wx.navigateTo({
张杰's avatar
张杰 committed
36
      url: '/pages/review_student/index?signSummaryId=' + student.id + '&pictureIds=' + JSON.stringify(student.arrIds) + '&remark=' + (student.remark ? student.remark : '') + '&picRemark=' + (student.pictureRemark ? student.pictureRemark : '') + '&studentName=' + student.signStudentName + '&sex=' + student.signStudentSex + '&studentPicture=' + student.studentPicture
张杰's avatar
张杰 committed
37 38 39 40 41 42 43 44
    })
  },

  previewPic: function (e) {
    var current = this.data.records[e.target.dataset.index].arrPic[e.target.dataset.picIndex]
    wx.previewImage({
      current: current,
      urls: this.data.records[e.target.dataset.index].arrPic
张杰's avatar
张杰 committed
45
    })
张杰's avatar
张杰 committed
46

张杰's avatar
张杰 committed
47 48
  },

49
  querySignSummary: function() {
张杰's avatar
张杰 committed
50
    request.querySignSummaryByClass(this.data.classId).then(res => {
51 52 53 54
      console.log(res)
      for (var i = 0; i < res.length; i++) {
        var item = res[i]
        item.signDate = item.signDate.substr(0, 10)
张杰's avatar
张杰 committed
55 56
        let paymentType = app.globalData.studentPaymentTypes[item.studentPaymentType]
        item.signStudentName = item.signStudentName + ' (' + paymentType + ')'
张杰's avatar
张杰 committed
57 58 59 60 61 62 63 64 65 66 67 68 69 70
        //图片
        var arrPic = []
        let arrIds = []
        if (item.picture != null && item.picture != '') {
          arrIds = item.picture.split(",")
          for (var j = 0; j < arrIds.length; j++) {

            let id = arrIds[j]
            arrPic.push(utils.handleImgShow(id))
          }
        }
        console.log(arrPic)
        item.arrIds = arrIds
        item.arrPic = arrPic
71 72 73 74 75 76 77 78 79 80 81 82 83
      }
      this.setData({
        records: res
      })
    }).catch(err => {
      wx.showToast({
        title: err.message,
        icon: 'none',
        duration: 2000
      })
    })
  },

张杰's avatar
张杰 committed
84 85 86
  /**
   * 生命周期函数--监听页面加载
   */
87
  onLoad: function(options) {
张杰's avatar
张杰 committed
88 89 90
    // 设置日期
    let date = new Date()
    let dateStr = utils.formatDate(date)
张杰's avatar
张杰 committed
91 92 93 94
    this.setData({
      teacherId: app.globalData.login.user.id,
      classList: app.globalData.login.classes,
      reviewerName: app.globalData.login.user.name,
张杰's avatar
张杰 committed
95
      userIcon: app.globalData.login.wxaUser.avatarUrl,
张杰's avatar
张杰 committed
96 97
      kindergarten: app.globalData.login.preschoolName,
      dateStr: dateStr
张杰's avatar
张杰 committed
98 99 100 101

    })

    if (this.data.classList.length > 0) {
102 103
      this.data.classId = this.data.classList[0].id
    }
张杰's avatar
张杰 committed
104
    
张杰's avatar
张杰 committed
105 106 107 108 109
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
110
  onReady: function() {
张杰's avatar
张杰 committed
111 112 113 114 115 116

  },

  /**
   * 生命周期函数--监听页面显示
   */
117
  onShow: function() {
张杰's avatar
张杰 committed
118
    this.querySignSummary()
张杰's avatar
张杰 committed
119 120 121 122 123
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
124
  onHide: function() {
张杰's avatar
张杰 committed
125 126 127 128 129 130

  },

  /**
   * 生命周期函数--监听页面卸载
   */
131
  onUnload: function() {
张杰's avatar
张杰 committed
132 133 134 135 136 137

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
138
  onPullDownRefresh: function() {
张杰's avatar
张杰 committed
139 140 141 142 143 144

  },

  /**
   * 页面上拉触底事件的处理函数
   */
145
  onReachBottom: function() {
张杰's avatar
张杰 committed
146 147 148 149 150 151

  },

  /**
   * 用户点击右上角分享
   */
152
  onShareAppMessage: function() {
张杰's avatar
张杰 committed
153 154 155

  }
})